chore(llm): shorten timeout helper docstring; update tests

This commit is contained in:
Ahmed Allam
2026-07-17 19:45:32 -07:00
committed by Ahmed Allam
parent 88ad3e4472
commit 7d5a67d234
2 changed files with 3 additions and 15 deletions
+1 -13
View File
@@ -22,19 +22,7 @@ if TYPE_CHECKING:
def request_timeout_extra_args(timeout_s: float | None) -> dict[str, float] | None:
"""Per-request model timeout as ``extra_args``, forwarded to the provider call.
A stalled stream trips the timeout and is retried by ``DEFAULT_MODEL_RETRY``,
restoring pre-v1's per-turn inactivity guard.
The value MUST be a plain ``float``, not an ``httpx.Timeout``. The Chat
Completions and LiteLLM model paths build their tracing generation span from
``ModelSettings.to_json_dict()``, which pydantic-serializes ``extra_args`` in
JSON mode; an ``httpx.Timeout`` is not JSON-serializable and raises
``PydanticSerializationError`` there, failing every turn on those paths. A
scalar serializes cleanly and, on httpx-based clients, is applied as the read
(inactivity) timeout — not a total-duration deadline.
"""
"""Per-request model timeout; a plain float so ``ModelSettings.to_json_dict()`` stays serializable.""" # noqa: E501
if not timeout_s or timeout_s <= 0:
return None
return {"timeout": timeout_s}
+2 -2
View File
@@ -165,7 +165,7 @@ def test_make_model_settings_sets_request_timeout() -> None:
)
assert settings.extra_args is not None
assert settings.extra_args["timeout"].read == 300.0
assert settings.extra_args["timeout"] == 300.0
def test_make_model_settings_omits_timeout_when_unset() -> None:
@@ -184,4 +184,4 @@ def test_make_model_settings_timeout_survives_reasoning_resolve() -> None:
)
assert settings.extra_args is not None
assert settings.extra_args["timeout"].read == 120.0
assert settings.extra_args["timeout"] == 120.0