Repository navigation
fix(chat): recover an empty answer only once a run, the kind picked by its cause - #2113
Merged
Merged
Conversation
… cause A provider error retry (ansvisor#2064) and the ask for the answer (ansvisor#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]>
…ly 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, ansvisor#2052), and a change-only job that stops on "No change" once its reading ends (ansvisor#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
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.
Summary
A run with no answer had two separate recoveries, each with its own once-a-run flag: the retry of a step the provider ended in an error with nothing in it (#2064), and the ask for the answer when a reply has only next moves or nothing (#2040). One empty answer could therefore take 3 model calls, or 4 with the language rewrite. Now a run gets one recovery, and its cause picks the kind:
progress.recovered('retry' | 'answer') replacesstepRetriedandanswerAsked(web/src/lib/chat/engine.ts).ANSWER_NOTEand without the next moves tool, keeping that reply's moves (as before).Checked against what main now has:
run_agentcard and then goes on as the same run, so a recovery it spent before the card stays spent after it. The called agent's run is its own chat run, with its own single recovery.agent-calls.tshas no empty-answer handling of its own: the engine's model loop is the only place.The second commit adds a test for each of these.
Tests (
web/src/lib/chat/engine.test.ts): an empty reply after a retry isn't asked for the answer; an errored step after the ask isn't run again; an errored reading step leaves the retry to the writer; the one recovery holds across a card; and a change-only job's errored reading still stops on "No change" with no retry.No Help change: Help doesn't describe how Chat recovers an empty answer. People see the same thing as before, an answer or none, with fewer model calls behind it.
One small thing to know: a run that was waiting on a card when this ships keeps its old
answerAskedorstepRetriedin its saved progress. The new code doesn't read those flags. Such a run can recover once more after it is approved. That costs at most one more model call, and changes nothing else.Related issue
None. Follow-up to #2040 and #2064.
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 && npx vitest run src/lib/chat/engine.test.ts. The two describe blocks to look at are "a step the provider ends in an error, with nothing in it" and "Notify only if the answer changed".Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)help/(or no user-visible change) — see help/README.mdChecked locally on 07fa34a, after merging main (cce9967):
format:checkandlintpass. Lint has 0 errors and 7 warnings, all in files this PR doesn't touch.typecheckpasses.yarn buildpasses with CI's placeholder env.Nothing under
server/,skills/orsupabase/changed.Generated by Claude Code