Skip to content

fix(opencode): keep doom-loop guard to real failures across steps - #728

Closed
agenteinstinct1-max wants to merge 1 commit into
dev-vibecodedfrom
arena/0e022085-silvercode
Closed

agenteinstinct1-max wants to merge 1 commit into
dev-vibecodedfrom
arena/0e022085-silvercode

Conversation

@agenteinstinct1-max

Copy link
Copy Markdown
Collaborator

Refs #725

The doom_loop guard in packages/opencode/src/session/processor.ts fired on identical tool parts with status !== "pending", so it also counted calls that never ran, calls that succeeded, members of one parallel batch, and the deferred-tool repair placeholder. It now counts only evidence of a sequential no-progress loop.

What changed

  • Evidence = executions that actually ran to a terminal outcome (completed/error) and are not the invalid placeholder experimental_repairToolCall substitutes for a deferred tool (that placeholder never executed; its input instructs the retry).
  • Repetitions must span distinct generation steps: a step is a new assistant message or a later step-start inside one, so N identical calls fanned out in one response share a step and never trip the guard. Earlier messages are read back within the current user turn (a new user message is progress, not a loop).
  • Preserved: identical name+input comparison, DOOM_LOOP_THRESHOLD = 3 (the third identical attempt asks), the doom_loop permission ask with its always/ruleset/countdown semantics (feat(permission): auto-deny permission prompts after a countdown #186), and the lazy-load repair message and retry path in llm.ts (untouched).
  • A success in the evidence window breaks the streak, so only failures count.

Tests (deterministic, packages/opencode/test/session/processor-effect.test.ts)

Each test stubs Permission.Service to record asks and LLM.Service to replay scripted event streams, so there is no prompt countdown or network involved.

  • (a) 3 identical failing calls in one batch → no doom ask.
  • (b) the same call failing across 3 separate model turns → exactly one doom_loop ask for lookup.
  • (c) deferred-tool repair placeholders (back-to-back and across steps) plus the instructed retry → no ask.
  • (d) identical calls alternating error/completed/error/error → no ask until the two preceding executions are both failures across separate steps, then one ask.
  • plus: a repair placeholder between two real failures neither counts nor breaks a genuine streak.

All five fail against the pre-fix guard (verified by stashing the source change), and mutation checks confirm each rule is covered: dropping the distinct-step condition fails (a); accepting non-failures fails (d); not excluding invalid fails the placeholder test.

Verification

  • bun test test/session/processor-effect.test.ts -t "doom loop" → 5 pass.
  • bun test test/session → 834 pass, 8 skip, 1 todo, 1 environment timeout (model-switch during retry > no model switch, 5381 ms against a 5 s limit; passes in isolation).
  • Package-wide bun run typecheck cannot complete in the sandbox (node OOM at the 2 GB heap limit — also at the unmodified base commit). Scoped tsc --noEmit --skipLibCheck projects including src/session/processor.ts and the test file (full import graph) both exit clean.
  • oxlint on both files: 0 errors, no new warnings.

@github-actions

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant