Skip to content

Name the model to try when a request fails, and bound a streamed request by its silence - #594

Merged
neuromechanist merged 10 commits into
developfrom
feature/issue-593-suggest-models-and-idle-timeout
Oct 7, 2026
Merged

neuromechanist merged 10 commits into
developfrom
feature/issue-593-suggest-models-and-idle-timeout

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

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

  • The message names a model.
    "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 error event carries suggested_model (id and label) 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.
  • A run that used all its steps says so.
    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." and suggested_model.
    It is a WARNING with no traceback on the streams and on /ask and /chat with stream: false, which used to log an ERROR with a traceback and tell the caller to contact support.
  • A button on the failed reply.
    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.
  • A streamed request is bounded by its silence.
    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/resume run 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

  • The Cloudflare worker.
    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.
  • The CLI: its 120 s read timeout is between chunks, which is already a bound on silence.
    It sends no model, so the suggestion is only text there.
  • Keepalives: the server sends none on the chat stream, so a model that is quiet for more than 60 s before its first word (Qwen3 Next streams no reasoning) is given up on.
    A model that streams its reasoning sends thinking events.
  • What the server records when a reader leaves: an abandoned request leaves no failure line or outcome row (the generator is cancelled, and the handlers catch Exception, not cancellation).
    That was already so with the 120 s abort and is a separate piece of work.
  • The step limit itself (langgraph's 25) and longer model read timeouts: neither helps a stall, and the first is a cost decision for each community.

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 /ask and /chat with 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/resume idle 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 of suggested_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).

…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.
…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.
@neuromechanist neuromechanist added the enhancement New feature or request label Oct 7, 2026
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.
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://feature-issue-593-suggest-mo-demo.osc.earth
Branch feature/issue-593-suggest-models-and-idle-timeout
Commit 3929bcc

This preview will be updated automatically when you push new commits.

@neuromechanist
neuromechanist merged commit fe0c776 into develop Oct 7, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-593-suggest-models-and-idle-timeout branch October 7, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant