Skip to content

fix(coding-agent): reject empty advisor stop completions#5216

Merged
can1357 merged 1 commit into
mainfrom
farm/1734a004/advisor-empty-stop-failure
Jul 14, 2026
Merged

fix(coding-agent): reject empty advisor stop completions#5216
can1357 merged 1 commit into
mainfrom
farm/1734a004/advisor-empty-stop-failure

Conversation

@roboomp

@roboomp roboomp commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Repro

A focused advisor-runtime regression models a provider returning HTTP 200 with finish_reason: stop, content: [], zero usage, no advise tool call, and no state.error. On the pre-fix HEAD worktree, bun test packages/coding-agent/src/advisor/__tests__/advisor.test.ts -t "treats an empty stop turn without advise as a failed advisor turn" failed with Expected length: 3, Received length: 1, showing the first empty stop was accepted as success instead of retried.

Cause

packages/coding-agent/src/advisor/runtime.ts only inspected agent.state.error after AdvisorAgent.prompt(). Empty successful-looking assistant turns with stopReason: "stop" and no content/tool call left state.error undefined, so AdvisorRuntime.#drain() marked the batch successful, reset consecutive failures, and decremented backlog.

Fix

  • Added advisor-turn validation after each prompt to reject empty stop responses or turns that append only the user batch without any assistant result.
  • Reused the existing advisor failure path so empty responses trigger rollback, onTurnError, retry, and the three-failure backlog drop + notifyFailure warning.
  • Added a regression test covering the reporter's empty stop response shape, retry count, failure hooks, rollback behavior, and no-advice output.
  • Added an Unreleased changelog entry for the advisor failure handling fix.

Verification

bun test packages/coding-agent/src/advisor/__tests__/advisor.test.ts -t "treats an empty stop turn without advise as a failed advisor turn" passed with 1 test and 36 assertions. bun test packages/coding-agent/src/advisor/__tests__/advisor.test.ts passed with 73 tests and 299 assertions. bun run fix passed after adding the exhaustive callback return. The pre-publish gate in gh_push_branch completed and pushed 8608395eefb2. Fixes #5212

Treat content-less advisor stop completions as failed turns so the advisor retry/drop path handles silent provider responses instead of accepting them as successful reviews.

Fixes #5212
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouched Passed the vouch gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Advisor accepts endless empty stop completions as successful reviews

2 participants