Repository navigation
fix(session): detect periodic tool-call cycles - #47797
yixiao5428 wants to merge 1 commit into
Conversation
Detect three repeated tool-call blocks with periods up to ten using bounded processor-local state instead of persisted message history. Share admission state across active call record copies so metadata updates cannot skip or double-count normalized calls. Preserve existing doom_loop permission behavior and cover call ordering, replay while active, and concurrent metadata updates. Co-Authored-By: Claude <noreply@anthropic.com>
|
The following comment was made by an LLM, it may be inaccurate: Potential Related PRs FoundThe search identified two related PRs that address similar cycle/loop detection concerns:
Important Note: The current PR (47797) is explicitly designed to complement rather than duplicate these PRs:
|
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #47759
Type of change
What does this PR do?
The current guard catches
A,A,Abut misses cycles such asA,B,A,B,A,B. This change detects three consecutive repetitions of an ordered tool-call block of length 1–10 within one processor, using the existingdoom_looppermission flow.Related approaches:
Key properties:
How did you verify your code works?
Validated the exact contribution in a fresh frozen-lockfile installation with Bun 1.3.14:
bun test --cwd packages/opencode --timeout 30000 test/session test/permission test/provider/transform.test.ts bun run --cwd packages/opencode typecheck bun run typecheckResults: 1,116 passed, 0 failed, 7 skipped, 1 todo; package typecheck passed; workspace typecheck 30/30 passed with no cache hits. Tests cover an independent suffix-block oracle, exact trigger boundaries, duplicate delivery, metadata races, history isolation, and permission outcomes. The periodic-cycle and metadata regressions were demonstrated failing before their corresponding fixes.
Screenshots / recordings
Not applicable; no UI changes.
Checklist
🤖 Generated with Claude Code