Repository navigation
Description
Observed
In a TUI session, two Invalid tool call: websearch repairs (websearch exists and has been loaded — call it again, the deferred-tool retry path in packages/opencode/src/session/llm.ts experimental_repairToolCall) were immediately followed by the doom_loop permission prompt ("Continue after repeated failures"). The user had to unblock a session that was not in a loop.
Source-qualified causal conditions (dev-vibecoded @ 3d4c83f)
packages/opencode/src/session/processor.ts, tool-call case, DOOM_LOOP_THRESHOLD = 3:
const recentParts = parts.slice(-DOOM_LOOP_THRESHOLD)
if (recentParts.length !== DOOM_LOOP_THRESHOLD ||
!recentParts.every((part) =>
part.type === "tool" &&
part.tool === value.name &&
part.state.status !== "pending" &&
JSON.stringify(part.state.input) === JSON.stringify(input))) {
return
}
yield* permission.ask({ permission: "doom_loop", ... })Three structural problems vs the stated intent (the inline comment says "three identical failures", ref #186):
- No failure requirement: the check accepts any
status !== "pending"— successful calls, and calls that never executed (e.g.invalidrepair placeholders), count toward "repeated failures". - No batch/step distinction: parallel tool calls from the SAME assistant step (one fan-out, zero intervening model turns) are indistinguishable from the same call repeated across three separate no-progress iterations. A single batch of 3 identical calls trips the guard mid-batch.
- Lazy-load retry interacts: the deferred-tool repair explicitly instructs an identical retry ("call it again"). The retry is the designed recovery, yet its identical name+input is exactly what the guard counts.
The intended protection (stop a sequential, no-progress, repeated-failure loop) is correct and must be preserved.
Fix directions (no bypass, no heuristic weakening)
- Count only tool executions that actually ran and produced an outcome; exclude
invalidrepair placeholders. - Require repetitions across distinct generation steps (intervening assistant output), not members of one parallel batch.
- Keep the identical name+input comparison, the threshold, and the
doom_looppermission with its countdown semantics (feat(permission): auto-deny permission prompts after a countdown #186) for true loops. - Deterministic tests: (a) 3 identical calls in one batch → no prompt; (b) same call failing across 3 separate steps → prompt fires; (c) deferred-tool repair followed by its instructed retry → no prompt from the repair pair.
Found via user report with a session screenshot (kept private); description here is source-verified.
Activity
test(opencode): isolate doom-loop identity and pagination probes (Refs …
Merge dev-vibecoded into processor stream restoration (Refs #725)
fix(opencode): count doom-loop failures per step (Refs #725) (#767)