Skip to content

fix(session): fail empty assistant responses instead of recording success - #41898

Open
patil2001 wants to merge 1 commit into
anomalyco:devfrom
patil2001:fix/runner-fail-empty-assistant-response
Open

fix(session): fail empty assistant responses instead of recording success#41898
patil2001 wants to merge 1 commit into
anomalyco:devfrom
patil2001:fix/runner-fail-empty-assistant-response

Conversation

@patil2001

Copy link
Copy Markdown

Issue for this PR

Closes #37372

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

V2 records a reasoning-only assistant response with no visible text and no tool calls as a successful execution. When a provider settles a step with an empty completion (six output tokens but no publishable content), the runner emits session.step.ended.1 with finish: "stop" followed by session.execution.succeeded.1 — the user gets neither an answer nor a surfaced failure, and the client stops its typing state silently.

The fix makes the runner judge a settled step by its usable assistant output instead of its token count. The event publisher now records whether a step produced non-empty text, non-empty reasoning, or a tool call. When a step settles with no usable output, the runner publishes Step.Failed with a typed "Provider returned an empty response" error rather than a successful Step.Ended, so clients can surface the failure to the user. Non-empty reasoning-only turns (which providers legitimately emit and existing tests cover) still settle as a successful step. The two runner tests that modeled a completely empty second turn now expect the error.

How did you verify your code works?

  • bun test --timeout 30000 in packages/core passes (1080 pass / 0 fail), including new publisher tests for usable output (text / reasoning / tool call) and empty output (empty text fragment, empty reasoning).
  • tsgo --noEmit clean in packages/core.
  • Confirmed the two previously-passing tests that modeled empty continuation turns now assert the empty-response error.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…cess

A terminal assistant step that produces no usable output (no text, no
tool calls, no non-empty reasoning) was recorded as a successful
execution. This surfaced as a silent no-op turn for the user.

Treat a settled step with no usable output as a typed empty-response
failure so clients can surface the error instead of stopping silently.
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on the search results, I found a potentially related PR that should be reviewed:

Related PR

PR #37843: fix(core): fail empty provider output

This appears to address a very similar issue — failing when providers return empty output. It's worth checking if this PR overlaps with or duplicates the current PR #41898, as both deal with handling empty provider responses in the core session logic.

The other PRs found (like #40531, #37732, #37110, #26167) are related to empty responses in various contexts but appear to be addressing different scope areas (opencode retries, model responses, tool loops) rather than the specific session V2 execution flow that #41898 targets.

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.

v2: empty reasoning-only response is recorded as successful completion

1 participant