Stop empty assistant turns from spinning Loop forever - #146
Merged
Conversation
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.
Problem
A real OpenCode session repeatedly completed assistant turns with no visible text or tool activity. The Loop treated each completed timestamp as a successful iteration, immediately injected the next autonomous continuation, and could churn indefinitely.
Fix
empty.emptycompleted turn so finalization can handle it instead of waiting forever.runCount,lastRunAt, and a provisionally consumed--max-runsslot.emptyTurnCountso restart/reload does not erase the safety streak.Regression coverage
New
scripts/empty-turn-recovery-test.mjscovers blank/whitespace replies, text/tool activity, tool-then-blank tails, stale busy recovery, max-run refund/re-enable, one retry, second-empty pause, no success checkpoint on empty turns, and streak reset after real work.The full source check + test suite passed on Node 24, the committed single-file
src/index.jsbundle was regenerated,node --check src/index.jspassed, and the focused empty-turn recovery suite passed again against the generated bundle source head.Temporary implementation workflows/scripts used to create and validate the patch were removed; the final diff contains only product/runtime/tests/bundle changes.