Repository navigation
Name the model to try when a request fails, and bound a streamed request by its silence - #594
Merged
neuromechanist merged 10 commits intoOct 7, 2026
Conversation
…593) langgraph's GraphRecursionError (a model that keeps calling tools until the step limit, as GPT-OSS did on a HED annotation question) was unknown and came out as the generic error. It is now kind step_limit, retryable (another model may finish), not worth an automatic retry. Adds suggest_another_model: Claude Haiku 4.5 first, Sonnet 5.5 when Haiku is the one that failed. Tested: tests/test_core/test_model_errors.py; the kind check and the suggestion order each fail a test when removed.
… out (issue #593) "Please choose another model." now reads "Try Claude Haiku 4.5, or choose another model." (Sonnet 5.5 when Haiku failed), a run that used all its steps says so and what to try, at WARNING without a traceback, and the error event carries suggested_model {id, label} for a client that can offer the switch. A key's throttle, a refused request and an unrecognized failure carry none. Tested: tests/test_api/test_stream_failures.py through the real graph, a real tool and the real stream; six mutants of the new branches each fail a test.
… failed reply (issue #593) The widget aborted every request 120 s after it was sent, however much the run had done, and its 60 s stall timer could not fire (#564). A streamed request is now given up 60 s after the last thing it did (any event, a tool starting or finishing, text), for the first run of a reply and each later run alike; a request with no stream keeps its fixed 2 minutes. A failure a model could not finish (the server names a model in suggested_model, or the widget timed out on silence) shows a button under the message, "Try Claude Haiku 4.5", that sends the same question again on that model once, without changing the saved setting, and the model also runs the later runs of that reply. The button is only for a reply that showed nothing, whose question is back in the box, and never names the model that failed. Tested: new blocks in frontend/test-widget-paced-streaming.js (325 checks) and the drift test; eight mutants of the idle timer, the override and the button each fail a check.
…widget's event notes (issue #593) Docs and comments only.
…now (issue #593) Docs only.
…see through routing variants (issue #593) - A run that used all its steps on a request with stream: false was the generic 500 and an ERROR with a traceback; it now carries the same message as the stream, at WARNING. - Its log line says "A run used all its steps", not "Model call failed while streaming". - suggest_another_model read an OpenRouter slug with a routing variant (anthropic/claude-haiku-4.5:nitro) as unknown and could suggest the model that failed. - Docs: three WARNINGs, suggested_model in the event's returns, step_limit among the kinds, from_provider, Sonnet costs twice as much per token (not several times). Tested: tests/test_api/test_stream_failures.py through the real graph and a real tool; three mutants of the new branches each fail a test.
- An error response whose body never finishes no longer hangs the send: the timer is stopped after the body is read, not before (sendMessage and postResume). - A reply that is JSON, not a stream, gets 2 minutes from the moment it began, as documented. - A server tool that is running gets a longer allowance (2 minutes) than a quiet model (60 s), so a tool at its own 60 s limit is not raced by the widget's timer. - The button sends what is in the box (a question the reader narrowed), and is not offered when the request timed out before the server answered. - An OpenRouter slug with a routing variant is read as the model it runs. Tested: six new blocks in frontend/test-widget-paced-streaming.js (335 checks); six mutants each fail one.
…und wrong or stale The worker is unchanged: a local workerd run showed that AbortSignal.timeout does not end a body passed through unread, so the 120 s that cut long runs was the widget's. The changelog now says what the widget does (60 s of silence, 2 minutes with a tool running), which events count, the JSON fallback, /ask and /chat with streaming off, and the models that send no thinking events; the design note's 120 s ceiling is updated; the widget, test and server comments no longer say the banner lasts a few seconds or that the button names the model the message names. Comments and docs only.
Widget: the button's model wins over the saved one, for the resend and a later run of the reply; the failed model is read from the override and the community default; a /chat/resume stream is touched per chunk, given up when quiet and its error body bounded; a network error after the server answered, a request with streaming off, a blank box, a community that offers neither or only one suggested model, and odd shapes of suggested_model. Server: the step-limit log line is named for what it is, the non-streamed test proves the loop ran, and the messages when no other model is left to suggest. Replaces a test that passed for the wrong reason. Tested: 373 widget checks and 148 stream failure tests; the reviewer's 12 survivor mutants each fail one.
Contributor
Preview Deployment
This preview will be updated automatically when you push new commits. |
neuromechanist
deleted the
feature/issue-593-suggest-models-and-idle-timeout
branch
October 7, 2026 13:38
11 tasks
6 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #593, closes #564.
A model that cannot finish a request left the reader with a generic message after a long wait.
Reported in #514 (#514 (comment)): on a HED validate-and-refine question, GPT-6 Luna, GPT-OSS and Qwen all failed and only the Anthropic models finished.
This names the model to try, offers it with a button, says when a run used all its steps, and bounds a streamed request by its silence instead of its length.
Built on the decisions in #593: 60 s after the last thing the request did, Haiku first because Sonnet is dearer.
What changes
"Please choose another model." is now "Try Claude Haiku 4.5, or choose another model." (Sonnet 5.5 when Haiku is the model that failed; never the one that failed, including through an OpenRouter slug with a routing variant).
The
errorevent carriessuggested_model(idandlabel) only when the message names one: not for a caller's own rate-limited key, a refused request or key, or a failure that is not a model's.GraphRecursionError(GPT-OSS on HED) is a new failure kind,step_limit, with "The current model (X) used all its steps without finishing. Try Claude Haiku 4.5, or ask for a smaller part of the task." andsuggested_model.It is a WARNING with no traceback on the streams and on
/askand/chatwithstream: false, which used to log an ERROR with a traceback and tell the caller to contact support.The widget shows "Try Claude Haiku 4.5" under the error of a request that showed no reply.
It sends what is in the box (the question, put back there, which the reader may have narrowed) once on that model, leaves the saved model setting alone, and the model also runs the later runs of that reply.
None for a network failure, a partial reply, a timeout before the server answered, or an error that names no model.
The widget aborted every request 120 s after it was sent, however much it had done since, and its 60 s stall timer could not fire (Widget: STREAM_TIMEOUT_MS never fires, so a stalled stream is bounded only by the 120 s request timeout #564).
It now gives a request up 60 s after the last data from the server (any chunk), for the first run and each
/chat/resumerun of a reply, and 2 minutes while a server tool is running (a tool sends nothing until it ends, and an MCP tool has a 60 s limit of its own).A request sent with streaming off, and a JSON reply, have 2 minutes.
A reply that keeps sending data is not cut off by a time limit.
Not changed, and why
I first thought its
AbortSignal.timeout(120000)also cut streams and built a silence bound for it; a review ran the old pass-through shape in a local workerd and found the signal does not end a body that is passed through unread (the 2 minutes bounds only the wait for the backend to start answering).So the 120 s that cut long runs was the widget's, and the worker change was dropped from this pull request.
The review's probe was on local workerd, not the production edge.
It sends no model, so the suggestion is only text there.
A model that streams its reasoning sends
thinkingevents.Exception, not cancellation).That was already so with the 120 s abort and is a separate piece of work.
Review
Four reviewers on the Sonnet model (code, errors, tests, comments) found, and this pull request fixes:
an error response whose body never finished hanging the send; the 60 s bound racing an MCP tool's own 60 s limit; the button resending a stale question over an edited one; a JSON reply being bounded at 60 s instead of 2 minutes; the button offered for a timeout before the server answered; an OpenRouter routing variant being read as the wrong model; the step limit still being a paged 500 on
/askand/chatwith streaming off; and a changelog claim about the worker that the probe above disproved, among comment and wording fixes.The test reviewer, re-run on the final state after a usage limit cut the first run off (it ran about 70 mutants), found gaps that the tests now close: the button's model winning over a saved one (for the resend and a later run), the
/chat/resumeidle path, a network error after the server answered,stream: false, a blank box, a community that offers neither or only one suggested model, odd shapes ofsuggested_model, and a test of the later runs that passed for the wrong reason.Testing
5,038 Python tests pass (the whole suite except
test_chat_resume_endpoint.py, whose 19 of 21 tests fail with 401 identically on a clean develop here), and all 25 widget and worker suites; after the last test additions, the widget suite has 373 checks and the stream failure tests 148.New: the failure messages and events through the real graph, a real tool and the real stream; the step limit on all four endpoints; the widget's idle timer, tool allowance, button, override and error paths in happy-dom against a fake fetch that honors the abort signal.
Each new behavior was shown to fail a test when removed (about 35 mutants across the widget and server).