fix(llm): abandon a model stream that stops producing events - #978
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Greptile SummaryThe PR adds a configurable watchdog that abandons provider streams when they stop producing events, allowing the existing retry path to replay stalled turns. The latest changes disable that watchdog around non-streaming model wrappers, resolving the previously reported false timeout on valid long-running non-streaming requests.
Confidence Score: 5/5The PR appears safe to merge. The previously reported non-streaming timeout is fixed because the provider now sets the idle timeout to zero whenever it wraps an ordinary model in Important Files Changed
Reviews (2): Last reviewed commit: "fix(llm): abandon a model stream that st..." | Re-trigger Greptile |
b33c3a9 to
6855b75
Compare
6855b75 to
952bbf0
Compare
952bbf0 to
60b1d72
Compare
Summary
Stacked on #977 → #976 (same wrapper), so review those first.
A turn can stream a few tokens and then go silent forever. Nothing catches that today:
LLM_TIMEOUTbecomes httpx's read timeout, which resets on every byte received — provider keepalive/progress frames keep the connection "active" while zero content is generated, so the agent parks indefinitely on a dead generation with no error and no retry.New
LLM_STREAM_IDLE_TIMEOUT(default 300s,0disables) bounds the gap between events, not the request:Applied in
_TurnGuardModel.stream_response, i.e. around the raw provider stream — deliberately not around the run loop's event stream, where a legitimately long-running tool call also produces no events and would be killed.TimeoutErroris already classified transient by_is_transient_model_error, so the existing bounded retry replays the turn instead of failing the agent.Repro
tests/test_stream_idle_timeout.pypoints the real chat-completions model at a gateway that streams"Now"/" spawning"and then stops writing:Plus a test that a steadily-producing stream passes through untouched, and one for the setting.
Link to Devin session: https://app.devin.ai/sessions/dad023e379e942f287bcf6822463b7a4
Requested by: @0xallam