fix(session): tighten empty-step guard so genuine empty tool calls always halt#1726
Closed
wqymi wants to merge 0 commit into
Closed
fix(session): tighten empty-step guard so genuine empty tool calls always halt#1726wqymi wants to merge 0 commit into
wqymi wants to merge 0 commit into
Conversation
8182ae3 to
8aff671
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
processor.tsBEFORE the doom-loop check: genuine empty tool calls (undefined/null/empty object, even with_metafields) are always counted, regardless of error/summary/structured/finish stateemptyStepCounthitsEMPTY_STEP_THRESHOLD=3, throws to halt the stream and setsassistant.errorChanges
packages/opencode/src/session/processor.ts: AddedEMPTY_STEP_THRESHOLD = 3,isEmptyInput()helper (filters_meta-prefixed keys),emptyStepCounttoProcessorContext, and the guard logic in thetool-callhandlerpackages/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'andassistant.erroris setWhy
The doom-loop check only catches last-3 SAME tool name + identical serialized input. The
prompt.ts:2734-2742passthrough 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 typecheckEXIT0bun test test/session/processor-effect.test.ts— 12 pass, 1 skip (pre-existing), 0 fail