Repository navigation
Release 0.8.16 review follow-ups: one warning per reply, empty replies, error classification - #568
Merged
Conversation
httpx errors, the built-in TimeoutError and any ConnectionError were labelled 'Model call failed', logged at WARNING with no traceback, and a 404 from a tool's fetch told the reader retrying will not help. langgraph's ToolNode re-raises uncaught tool errors, so a tool failure was misattributed. An exception now counts as the model call's only when its class comes from a provider library (Anthropic, OpenAI/LiteLLM, the vendored httpx2) or, for the built-in ConnectionError, when langchain-aws raised it. Anything else keeps ERROR and its traceback. Tested: real tools raising each error through the ask and chat streams, and the real Bedrock client for the langchain-aws ConnectionError.
… a full context to a new conversation A reply with no text, no code and no parked call ended in an empty done (which the widget drops silently) unless it had hit the output limit: a refusal, content filter, guardrail or malformed tool use left the reader with nothing. It is now an error for any stop reason, with its own message per reason, the stop reason in the log and the metrics row, and a 502 on the non-streamed endpoints. A conversation that filled the context window was told to try again or ask it to continue, which fails again; it now says to start a new conversation. Tested: every stop reason in the registry through the streamed and non-streamed ask and chat paths on the Bedrock, Anthropic and OpenRouter shapes. The client-tool streaming tests that ended a turn on text now stream it, as a provider does.
…g is fine The server treated every resumed browser run as code the widget would keep on the reply. The widget records a run only when the tool is not get_full_output, so a reply whose only run read output back and whose last run hit the output limit with no text got a warning and an empty done, which the widget drops: a banner and no answer. The parked call now carries how many of its runs are code (PendingClientCall.code_runs_before, runs_code), and only those make an empty ending a warning; otherwise it is an error. Tested: through the real /chat/resume endpoint for each provider shape (read-back only, code, code earlier in the reply) and the run counts carried across parked calls.
A reply cut off in a long conversation got the cut-off warning and then the 'Conversation is getting long' warning straight after it. The widget keeps one warning element, so the second overwrote the first unread, in exactly the conversations where truncation is likeliest. They are now one event. Every warning event also carries an optional code (cut_off, long_conversation; codes lists both when both apply) so a client can act on the kind; message is unchanged, so existing clients work as before. Tested: through the streamed chat with a conversation filled past the token budget on each provider shape (combined, long only, cut off only, full context window), the ask stream, and the event builder directly.
…ge short The error events for an empty or cut-off reply carried no request_id or error_id, so a reader's report could not be tied to the 502 row in the metrics or to its log line. They now carry both (the error id is also in the log line), and so do model-call failure events. The cannot-retry message held a UUID in text the widget shows for five seconds; the error id is now only a field of the event and the log, and the message fits at a glance. Tested: ids on the error event match the metrics row and the log record on each provider shape, ask and chat streams, and every permanent model failure.
Both endpoints return 502 when the model wrote no answer, but their route declarations listed only 200, 400 and 500, so the OpenAPI schema did not say so. Tested: the generated schema for both routes.
The streaming ask and chat printed a warning as its event arrived, above the answer; the batch paths printed it below. The streaming paths now hold warnings until the answer is printed. An error event's request and error ids are shown as a hint to quote in a report. Tested: the printed order on all four paths with both consoles writing to one buffer, several warnings, a stream with no answer, and the id hint.
The state a non-streamed /chat gets back holds the session's whole history, and extract_token_usage summed the usage of every model message in it. A session that had a browser turn keeps the model's own messages (replace_history adopts the graph state whole), so later requests were billed for those runs again. The usage is now read from the messages after the last human one, the same slice the cut-off check already used. Tested: a session holding two earlier model runs with usage, then a non-streamed chat on each provider shape; the cost row is the request's own (was three times it).
… provider takes it A turn that ends on an error leaves the reader's message with no reply, and the next message lands right behind it. That stays as it is; the comment where the turn ends says so, and a test reads what each provider sends for two human messages in a row. Bedrock merges them (merge_message_runs) and so does Anthropic (its own _merge_messages); the OpenRouter path sends two consecutive user messages. Tested: the real /chat endpoint twice per provider, the first request failing, through the real Bedrock, Anthropic and LiteLLM clients with only the network staged.
11 tasks
10 of 11 tasks
neuromechanist
added a commit
that referenced
this pull request
Sep 30, 2026
* Widget: stack warnings so a second one does not replace the first showWarning wrote every warning into one text node, so a cut-off notice and the long-conversation notice that follows it were never both readable. Each warning is now its own line with its own 10 s timer; the banner hides with the last line; identical text restarts the one line's timer. Tested: new cases in frontend/test-widget-paced-streaming.js (failed before the change); bun frontend/test-widget-color-scheme.js unchanged. * Widget: mark a cut-off reply in place and keep the mark across a reload When a warning arrives before done and says the reply was cut off (code cut_off when the server sends one, else the server's wording), the reply gets a cutOff mark. The message draws the existing italic 'Response may be incomplete' note from that mark once its text is fully shown, so the done event's canonical text does not replace it. The mark is saved with the conversation and read back only as a boolean. Tested: new cases in frontend/test-widget-paced-streaming.js (failed before the change), including a saved-and-reloaded conversation. * Widget: keep a cut-off reply that has no text and no run record applyDoneEvent kept an empty reply only if it had entries in executions, but answerToolRequest records only code that ran, so a reply whose only run was get_full_output had none. The server sends a warning and a done with empty content for it (the run counts as code there), and the bubble was dropped, leaving the 10 s banner as the only explanation. A reply marked cutOff is now kept and draws the explanation the mark carries. Tested: frontend/test-streaming.js and frontend/test-widget-paced-streaming.js (new cases failed before the change). * Widget: show the warnings of a non-streamed response The non-streamed fallback ignored data.warnings, so a cut-off answer arrived unmarked. Warnings (strings, or objects with a message and an optional code) now go through the same function as a stream's warning events: the banner, and the cutOff mark on the reply, which is saved with it. A missing or malformed field is ignored. Tested: new cases in frontend/test-widget-paced-streaming.js (failed before the change). * Widget: do not rewrite a server error that contains the word timeout A backend error event whose text contained 'timeout' was rewritten to 'Stream timeout' in the reply when partial text was visible, and one that contained 'JSON' became 'Invalid response from server' in the banner. The error raised for an error event is now marked serverReported, and both handlers pass it through as sent before looking for failures of the stream or the page. A client-side stream failure that says timeout still reads as one. Tested: new cases in frontend/test-widget-paced-streaming.js (failed before the change). * Widget: keep a failed request's banner, hand the question back, show the error id The banner for a failed chat request lasted 5 s, and when the reply was empty (the routine no-answer error) the question was removed with it, so the reader lost both. Now, for a failed request: - the banner stays until dismissed or the next send, with a dismiss button, selectable text, and the server's error_id (when the event carries one) as text with a copy button (falling back to selecting it where the page cannot copy); - the question goes back in the input when the failure removed it from the conversation; an error after a partial reply keeps it there, as before; - an earlier message's timer no longer hides a later message's banner. Other banners (settings, feedback, storage) still go after 5 s. Tested: new cases in frontend/test-widget-paced-streaming.js (failed before the change); every frontend suite in the Frontend Tests job run locally. * Widget: read the server's cut-off warnings as #568 sends them #568 gives each warning a code and sends one combined notice (code cut_off, codes listing both) when a cut-off and a long conversation coincide, and adds a context-window cut-off whose message is 'stopped short because' and whose advice is to start a new conversation, not to ask it to continue. So: - the wording fallback for a warning with no code (a stream before #568, and a non-streamed response's warnings, which are strings) also reads that message; - the note under a cut-off reply's text says only that it was cut off, true for either cause; a reply with no text shows the server's own message for it, kept on the reply (bounded, saved and read back only as a string), so the advice is the server's and survives a reload; - tests read the server's message constants from src/api/turn_outcome.py. Tested: bun frontend/test-widget-paced-streaming.js.
This was referenced Sep 30, 2026
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.
Follow-ups to the independent review of #566 (empty and cut-off replies, stream error classification). Each finding was first confirmed against the code, with a failing test where it is a behavior bug, then fixed in its own commit.
Changes
code. A reply cut off in a long conversation got the cut-offwarningand then "Conversation is getting long" straight after it; the widget keeps one warning element, so the second hid the first. They are now one event. Everywarningcarries an optionalcode(cut_off,long_conversation); when both applycodeiscut_offandcodeslists both.messageis unchanged in shape, so existing clients work as before.code_rancounts only runs the widget keeps. The widget records an execution only when the tool is notget_full_output; the server counted every resume. Confirmed through the real/chat/resumeendpoint: a read-back-only reply whose last run hit the limit gotwarning+ an emptydone, which the widget drops. The parked call now carriescode_runs_before(PendingClientCall.runs_code), and only those runs make an empty ending a warning; otherwise it is anerror.doneunless the stop reason was a truncation (confirmed forrefusal,content_filtered,guardrail_intervened,malformed_tool_use). Now anerrorwith a message per reason (declined, malformed, other), the stop reason in the log and the metrics row. The non-streamed endpoints answer 502 for the same replies (an empty 200 was the same silence).model_context_window_exceedednow says to start a new conversation instead of "try again" / "ask it to continue".TimeoutError/ConnectionErrorand anyhttpxerror were read as the model's, logged at WARNING with no traceback, and a tool's 404 told the reader retrying will not help (confirmed with real tools raising each through both streams). An exception is now the model call's only when its class comes from a provider library (Anthropic, OpenAI/LiteLLM, the vendoredhttpx2, botocore) or, for the built-inConnectionErrorlangchain-aws raises on a stream with nomessageStop, when langchain-aws raised it. Anything else keeps ERROR and its traceback.errorevents (and model-failure events) carryrequest_idanderror_id(the log line carries the error id). The CLI holds warnings until the answer is printed on the streaming paths, matching the batch paths, and shows the ids to quote.502is declared on/askand/chat.error_idstays a field of the event and is in the log./chatusage. Verified:extract_token_usagesummed every model message in the returned state, which includes the session history, and a session that had a browser turn keeps those messages with their usage (the cost row was three times the request's in the test). It now reads only the messages after the last human one. The unanswered user message after a stream error is left as is; a comment where the turn ends documents it.Not changed
merge_message_runson every provider path": Bedrock does (langchain-aws, joins the two texts with a newline); Anthropic merges in langchain-anthropic's own_merge_messages(same effect, notmerge_message_runs); the OpenRouter path does not merge at all (LiteLLM sends two consecutive user messages, valid in the OpenAI-style format). All three are pinned intests/test_api/test_unanswered_user_message.pyagainst the real clients.frontend/,CHANGELOG.md,docs/,.env.example,deploy/and the community configs, which belong to other work. The changelog and the SSE event docs should mention the newcode/codes,error_id/request_idfields and the 502 for empty replies.Also found, not fixed
MetricsMiddlewarewrites tworequest_logrows with the samerequest_id(the middleware's 200 when the response starts, then the stream's own). It predates this PR; the tests read the last row.ScriptedChatModeldoes not stream, so a turn ending on its text has no text to the router. Five tests intest_client_tool_streaming.pythat asserteddonefor such a turn now use a streaming model.Tested
uv run ruff check . && uv run ruff format .clean.uv run pytest --ignore=tests/test_integration -m "not integration and not llm and not network" -q -p no:cacheprovider --color=no --no-cov: 4577 passed, 14 skipped.model_outcome, not hardcoded.