Repository navigation
fix(chat): run a model step again once when the provider ends it in an error with nothing in it - #2064
Conversation
…n error with nothing in it Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # web/src/lib/chat/engine.test.ts # web/src/lib/chat/engine.ts
|
Note on the 3 model calls with #2040 (read from head ad9fca2; no push from us during the merge wave). Why it happens: two independent once-per-run flags.
Both can fire in one run:
With #2062's language rewrite, the worst case is 4. Also, a Suggested merge: one recovery per run for an empty answer.
That caps the final answer at 2 calls, or 3 with the language rewrite. Tests to keep: error → empty = 2 calls; empty → error = 2 calls; a read-phase If you'd rather we write this, say so after the wave and we'll open it as a new PR on top of main, not as a push here. 🤖 Generated with Claude Code |
…y its cause (#2113) * fix(chat): recover an empty answer once a run, the kind picked by its cause A provider error retry (#2064) and the ask for the answer (#2040) each had their own once-a-run flag, so one empty answer could take 3 model calls (4 with the language rewrite). One flag, progress.recovered, now holds the run's single recovery: a writing step the provider ended in an error runs again as it was; the model's own empty or next-moves-only reply is asked for the answer with ANSWER_NOTE and no next moves tool. A reading step with nothing in it no longer spends the retry: it moves on to writing anyway. A recovery step that is empty too ends the run as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(chat): hold the run's one recovery across a card and a change-only job's reading Main now has two paths the single recovery meets: a run that waits on a card and goes on as the same run (an agent's run_agent too, #2052), and a change-only job that stops on "No change" once its reading ends (#2015). The recovery a run spent before its card stays spent after it, and a reading step the provider ended with nothing in it is taken as read enough: the job still stops on "No change" with no retry and no writing step. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9 --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
A Chat answer could come out empty when the provider ended a model step in an error with nothing in it.
Chat's model test set (W4-35) found this with Gemini 3.5 Flash Lite through OpenRouter. A step finished
other(rawerror) with no text, no tool call and no output token. The engine read it as the model's reply, so the run went on from there and could enddonewith no answer.Fix (
modelLoopandmodelStepinweb/src/lib/chat/engine.ts):progress.stepRetried). A second such step goes on as before.In the test set, this was the last cause of an empty answer after #2040.
Related issue
None. Found by the Chat Wave 4 model test set (W4-35).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd web && yarn vitest run src/lib/chat/engine.test.ts -t "provider ends in an error". Two tests:No migration. No new environment variables. No Help change.
Checklist
yarn lintpassesyarn typecheckpassesyarn format:checkpasseshelp/(or no user-visible change)CI passed on this branch (e39a0bd), run on the fork (https://github.com/cihan-gyk/ansvisor/actions/runs/41599168256): schema is up to date; web
format:check, lint, typecheck, all tests andyarn buildpass; server lint,format:checkand all tests pass.🤖 Generated with Claude Code