Skip to content

fix(session): tighten empty-step guard so genuine empty tool calls always halt#1726

Closed
wqymi wants to merge 0 commit into
mainfrom
fix-empty-step-guard
Closed

fix(session): tighten empty-step guard so genuine empty tool calls always halt#1726
wqymi wants to merge 0 commit into
mainfrom
fix-empty-step-guard

Conversation

@wqymi

@wqymi wqymi commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add unconditional empty-step guard in processor.ts BEFORE the doom-loop check: genuine empty tool calls (undefined/null/empty object, even with _meta fields) are always counted, regardless of error/summary/structured/finish state
  • When emptyStepCount hits EMPTY_STEP_THRESHOLD=3, throws to halt the stream and sets assistant.error

Changes

  • packages/opencode/src/session/processor.ts: Added EMPTY_STEP_THRESHOLD = 3, isEmptyInput() helper (filters _meta-prefixed keys), emptyStepCount to ProcessorContext, and the guard logic in the tool-call handler
  • packages/opencode/test/session/processor-effect.test.ts: Regression test — single LLM response with 3 consecutive empty tool calls (one with {_meta:'harmless'}), asserts processor returns 'stop' and assistant.error is set

Why

The doom-loop check only catches last-3 SAME tool name + identical serialized input. The prompt.ts:2734-2742 passthrough returns 'none' (skipping empty detection) when assistant has error/summary/structured or finish=content-filter/error. Genuine empty tool calls slip through both guards.

Verification

  • bun typecheck EXIT0
  • bun test test/session/processor-effect.test.ts — 12 pass, 1 skip (pre-existing), 0 fail

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.

1 participant