Skip to content

fix(llm): use a JSON-serializable per-turn model timeout#803

Merged
0xallam merged 2 commits into
mainfrom
devin/1784342490-fix-timeout-serialization
Jul 18, 2026
Merged

fix(llm): use a JSON-serializable per-turn model timeout#803
0xallam merged 2 commits into
mainfrom
devin/1784342490-fix-timeout-serialization

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

#802's per-turn timeout put an httpx.Timeout object into ModelSettings.extra_args. The Chat Completions and LiteLLM model paths build their tracing generation span from ModelSettings.to_json_dict() (evaluated even with tracing disabled), and pydantic cannot JSON-serialize httpx.Timeout:

model_settings.to_json_dict() → PydanticSerializationError:
Unable to serialize unknown type: <class 'openai.Timeout'>

This fails every model turn on those paths (only the Responses path, which doesn't serialize settings, was unaffected). Fix: pass the timeout as a plain float —

-return {"timeout": httpx.Timeout(timeout_s, connect=min(timeout_s, 30.0))}
+return {"timeout": timeout_s}

httpx-based clients apply a scalar as the read (inactivity) timeout, so the stalled-stream protection from #802 is preserved. Added a regression test asserting to_json_dict() succeeds with the timeout set.

Link to Devin session: https://app.devin.ai/sessions/dad023e379e942f287bcf6822463b7a4
Requested by: @0xallam

@0xallam 0xallam self-assigned this Jul 18, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

0xallam added 2 commits July 18, 2026 02:44
An httpx.Timeout in ModelSettings.extra_args crashes
ModelSettings.to_json_dict() (PydanticSerializationError) on the Chat
Completions and LiteLLM model paths, which serialize settings for their
tracing generation span — failing every model turn on those paths. Pass
the timeout as a plain float, which httpx-based clients apply as the
read (inactivity) timeout.
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1784342490-fix-timeout-serialization branch from cd52e0d to 5b38457 Compare July 18, 2026 02:44
@greptile-apps

greptile-apps Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes the per-turn model timeout JSON-serializable and applies it to model requests. The main changes are:

  • Adds a scalar timeout helper for model settings.
  • Passes the configured timeout through scan and deduplication requests.
  • Adds tests for serialization, propagation, disabled values, and retries.

Confidence Score: 4/5

The connection-timeout regression should be fixed before merging.

  • The scalar value fixes ModelSettings serialization.
  • Scan and deduplication requests receive the configured timeout.
  • Failed connection attempts can now wait for the full model timeout instead of the former 30-second cap.

strix/config/models.py

Important Files Changed

Filename Overview
strix/config/models.py Adds the serializable timeout helper, but the scalar value removes the previous connection-timeout cap.
strix/core/inputs.py Adds timeout propagation to shared model settings and preserves it across setting resolution.
strix/core/runner.py Passes the configured LLM timeout into scan model settings.
strix/report/dedupe.py Adds the configured timeout to deduplication model requests.
tests/test_inputs.py Tests timeout propagation, omission, and preservation during reasoning resolution.
tests/test_model_retry.py Adds coverage for retrying timeout and network errors.
tests/test_models.py Tests timeout conversion and ModelSettings JSON serialization.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
strix/config/models.py:28
**Connection Timeout Loses Its Cap**

A scalar HTTPX timeout applies to connection establishment as well as reads. With the default 300-second setting, an unreachable provider can now consume up to 300 seconds per connection attempt instead of the previous 30-second cap, and retries can multiply that delay.

Reviews (1): Last reviewed commit: "chore(llm): shorten timeout helper docst..." | Re-trigger Greptile

Comment thread strix/config/models.py
@0xallam
0xallam merged commit 7d5a67d into main Jul 18, 2026
1 check passed
@0xallam
0xallam deleted the devin/1784342490-fix-timeout-serialization branch July 18, 2026 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant