Skip to content

fix(chat): recover an empty answer only once a run, the kind picked by its cause - #2113

Merged
gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:fix/chat-single-recovery
Nov 4, 2026
Merged

gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:fix/chat-single-recovery

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

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:

  • One flag: progress.recovered ('retry' | 'answer') replaces stepRetried and answerAsked (web/src/lib/chat/engine.ts).
  • A writing step the provider ended in an error, with nothing in it runs again as it was: the same prompt and the same tools.
  • The model's own empty reply, or next moves alone, is asked for the answer with ANSWER_NOTE and without the next moves tool, keeping that reply's moves (as before).
  • A reading step the provider ended in an error no longer spends the retry: it is taken as "read enough" and the run moves on to writing, as a reading step that throws already did.
  • A recovery step that is empty too ends the run, as before.

Checked against what main now has:

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 answerAsked or stepRetried in 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 feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Run 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".
  2. Optional, by hand: in Chat, pick one of the models fix(chat): ask once for the answer when a reply has only next moves or nothing, as GPT and Gemini do #2040 found answering "hi" with next moves alone, and send "hi". Chat still answers in words, with its next moves under the answer.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR
  • Help article updated under help/ (or no user-visible change) — see help/README.md

Checked locally on 07fa34a, after merging main (cce9967):

  • web format:check and lint pass. Lint has 0 errors and 7 warnings, all in files this PR doesn't touch.
  • typecheck passes.
  • All tests pass: 930 files, 9977 passed, 1 skipped.
  • yarn build passes with CI's placeholder env.

Nothing under server/, skills/ or supabase/ changed.


Generated by Claude Code

cihan-gyk and others added 3 commits November 3, 2026 23:00
… 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

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@gkhngyk
gkhngyk merged commit 35e4acd into ansvisor:main Nov 4, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants