diff --git a/api/streaming.py b/api/streaming.py index 9c9ea54e..03b562c7 100644 --- a/api/streaming.py +++ b/api/streaming.py @@ -6508,7 +6508,7 @@ def _terminal_turn_duration(session, *, now: float | None = None) -> float | Non try: started = float(started_at) ended = float(time.time() if now is None else now) - except (TypeError, ValueError): + except (TypeError, ValueError, OverflowError): return None if not math.isfinite(started) or not math.isfinite(ended) or started <= 0: return None diff --git a/tests/test_issue3929_error_preserves_partial.py b/tests/test_issue3929_error_preserves_partial.py index cda3931d..101c15ab 100644 --- a/tests/test_issue3929_error_preserves_partial.py +++ b/tests/test_issue3929_error_preserves_partial.py @@ -15,7 +15,7 @@ import api.streaming as streaming from api.models import Session -@pytest.mark.parametrize("started_at", [None, 0, -1, "invalid", float("nan"), float("inf"), 101.0]) +@pytest.mark.parametrize("started_at", [None, 0, -1, "invalid", float("nan"), float("inf"), 101.0, 10**400]) def test_terminal_turn_duration_omits_invalid_origin(started_at): session = types.SimpleNamespace(pending_started_at=started_at)