Skip to content

fix(chat): ask once for the answer when a reply has only next moves or nothing, as GPT and Gemini do - #2040

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/chat-empty-answer
Nov 3, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/chat-empty-answer

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

With some non-Claude models, a Chat reply can end with no answer: the run finishes and the person sees nothing. GPT-6 Luna and Gemini 3.8 Flash often answer a short message like "hi" with a suggest_next_moves call alone and no text. The engine took a reply with only next moves as a finished answer (CHAT-07 §C item 6), so the run ended done with an empty message.

Where we saw it:

  • the Wave 4 model test set (W4-35): GPT-6 Luna 3 of 4 greeting runs; Gemini 3.8 Flash and Gemini 4 Argon in 6 of 18 scenarios;
  • live today, for a workspace on its own OpenAI key, where Chat runs that key's model in one phase.

Fix, in modelLoop (web/src/lib/chat/engine.ts):

  • When it applies: the run's last reply is next moves alone or nothing at all, and the run has written no words for the person.
  • What the engine does:
    • keeps that reply's next moves;
    • adds one app note (ANSWER_NOTE in rules.ts), telling the model its reply had no text and to write the answer, in the person's language, without suggesting the moves again;
    • runs one more step with the next moves tool left out, so the model can't answer with moves alone again.
  • Bound: at most once a run (progress.answerAsked). A second empty reply ends the run as before.
  • Cleanup: empty text parts are dropped from the empty reply, because Anthropic's API refuses an empty text block.
  • Claude's usual reply is unchanged: text and next moves in one step, no extra step.

Checked with real calls on top of the W4-35 test set, one greeting each:

  • GPT-6 Luna now answers "Hi. What would you like to know about Northwind?" in two steps, for $0.002;
  • Gemini 3.8 Flash passed, $0.014.

Related issue

None. Found by the Chat Wave 4 model test set (W4-35).

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. cd web && yarn vitest run src/lib/chat/engine.test.ts -t "next moves". Two new tests:
    • a reply with next moves alone gets one more step, told so and without the next moves tool, and the moves stay;
    • two empty replies end the run after the second, with no third step;
    • an answer that already has text ends with no extra step.
  2. With a workspace on its own OpenAI key (Settings › AI Providers), ask Chat "hi". The answer shows, with next moves under it.

No migration. No new environment variables. No Help change: the visible behavior is the answer that should have been there.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • yarn lint passes
  • yarn typecheck passes
  • yarn format:check passes
  • Changes are focused — one concern per PR
  • Help article updated under help/ (or no user-visible change)

CI passed on this branch (c669f73), run on the fork (https://github.com/cihan-gyk/ansvisor/actions/runs/41534312655): schema is up to date; web format:check, lint, typecheck, all tests and yarn build pass; server lint, format:check and all tests pass.

🤖 Generated with Claude Code

…r nothing, as GPT and Gemini do

Co-Authored-By: Claude Opus 5.5 <[email protected]>
gkhngyk
gkhngyk previously approved these changes Nov 3, 2026
# Conflicts:
#	web/src/lib/chat/engine.ts

@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 14e3c95 into ansvisor:main Nov 3, 2026
5 checks passed
gkhngyk pushed a commit that referenced this pull request Nov 4, 2026
…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]>
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.

2 participants