Repository navigation
Description
Prerequisites
- I will write this issue in English
- I have searched existing issues to avoid duplicates (closely related but distinct: 🐛 [BUG]
todo-continuation-enforcerhook causes system-directive spam loop, mid-stream text fragmentation, and unresponsive sessions #6109, [BUG] task(task_id=...) to running background subagent silently drops prompt and reports success #5966; the upstream opencode root cause is tracked in fix(provider): Anthropic normalize splits tool-call from tool-result causing dangling tool_use error anomalyco/opencode#25774 / #27594 / #14367) - I am on 4.11.1 and have verified from the latest
devsource (4.19.1) that the defect below is still present — the fix is code-reviewed, not reproduced on 4.19.1 (see "Actual Behavior") - I have read the documentation
Bug Description
The atlas boulder-continuation path infinitely re-injects [SYSTEM DIRECTIVE: OH-MY-OPENCODE - BOULDER CONTINUATION] after a compaction that fails with a non-retryable Anthropic 400, leaving the session permanently stuck.
The trigger is an opencode-core bug (a tool_use block whose paired tool_result gets split off during compaction/normalize → Anthropic invalid_request_error, tracked upstream in anomalyco/opencode#25774, #27594, #14367). oh-my-openagent cannot fix opencode's message splitting — but it can and should stop looping on it, exactly like todo-continuation-enforcer already does after #6109.
The problem is the asymmetry: todo-continuation-enforcer/idle-event.ts gained a full set of compaction/API-error guards in #6109, but the atlas boulder path (boulder-continuation-injector.ts + idle-continuation.ts) never got them, so boulder plans loop forever while todo-driven sessions now recover.
Steps to Reproduce
- Run a long Atlas boulder plan (dozens of tasks) that accumulates a large, tool-heavy history — many consecutive
tasksubagenttool_useturns with no user turn between them. - Context grows until opencode's auto-compaction triggers.
- opencode's compaction builds an invalid Anthropic request: a
tool_useblock is separated from its pairedtool_result(opencode-core bug, fix(provider): Anthropic normalize splits tool-call from tool-result causing dangling tool_use error anomalyco/opencode#25774). Anthropic returns HTTP 400invalid_request_errorwithisRetryable: false:messages.2: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_XXXX. Each `tool_use` block must have a corresponding `tool_result` block in the next message. - The compaction assistant message is persisted with an
error; the latest session state is now a failed compaction. - On idle,
atlasboulder-continuation re-injects theBOULDER CONTINUATIONdirective → opencode re-attempts the same compaction → same 400 → repeat every ~7 seconds, forever. Every subsequent turn (including a manual message) re-fires the broken compaction. The session never recovers.
Expected Behavior
Boulder continuation should behave like todo-continuation-enforcer post-#6109: when the latest assistant turn is a failed/errored compaction or a non-retryable API 400, it must stop re-injecting — skip on latestMessageWasCompaction, respect the compaction guard, honor tokenLimitDetected, and back off / mark the session stalled and surface the error, instead of looping.
Actual Behavior
Boulder continuation ignores the failed compaction and re-injects every ~7s indefinitely.
Observed in a real session (opencode 1.18.4 + oh-my-openagent 4.11.1): 8 consecutive compaction attempts, all HTTP 400 tool_use/tool_result, each followed ~7s later by a fresh BOULDER CONTINUATION directive; the plan was frozen (e.g. 22/35) and could not advance. The orphaned tool_use belonged to a completed task subagent turn (so a "pending/running tool" guard does not catch it — the pairing was broken by compaction slicing, not by an unfinished tool).
Root cause on the boulder path (verified against latest dev, 4.19.1):
-
Failure accounting is blind to compaction failures. In
boulder-continuation-injector.ts,injectBoulderContinuation()resetspromptFailureCount = 0the moment the prompt injection succeeds:sessionState.promptFailureCount = 0 markContinuationInjectedAwaitingToolProgress(sessionState) return "injected"
The compaction 400 happens afterwards, asynchronously, inside opencode's own turn processing — the injector only ever sees "prompt dispatched successfully". So
promptFailureCountnever accumulates, and theMAX_CONSECUTIVE_PROMPT_FAILURESguard inidle-continuation.ts::scheduleRetry()(if (sessionState.promptFailureCount >= MAX_CONSECUTIVE_PROMPT_FAILURES) return) never fires. -
None of the 🐛 [BUG]
todo-continuation-enforcerhook causes system-directive spam loop, mid-stream text fragmentation, and unresponsive sessions #6109 guards exist on the boulder path.todo-continuation-enforcer/idle-event.tshas all of these;atlasboulder-continuation has none:if (state.tokenLimitDetected) return— non-retryable/context-overflow skipif (latestMessageWasCompaction) { ... return }— skip when the latest message is a compaction markerif (isCompactionGuardActive(state, ...)) return— compaction-epoch guardisLastAssistantMessageAborted(...)— errored/aborted last-turn skip- exponential backoff
CONTINUATION_COOLDOWN_MS * 2 ** min(consecutiveFailures, 5)
Because the boulder path lacks both the honest failure accounting and the compaction/error skips, it loops on a deterministic, non-retryable failure until the user kills the session.
Error Logs
APIError 400 (isRetryable: false)
messages.2: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_XXXX.
Each `tool_use` block must have a corresponding `tool_result` block in the next message.
(request to https://api.anthropic.com/v1/messages)
Repeated 8× over ~5 minutes, each retry preceded by an injected [SYSTEM DIRECTIVE: OH-MY-OPENCODE - BOULDER CONTINUATION] user message ~7s apart.
Doctor Output
bunx oh-my-openagent doctor currently crashes on this machine (likely a separate minor packaging issue), so environment info is provided manually:
$ bunx oh-my-openagent doctor
.../oh-my-opencode.js:2
import { spawnSync } from "node:child_process";
^^^^^^
SyntaxError: Cannot use import statement outside a module
Node.js v20.10.0
Manual environment:
- opencode: 1.18.4
- oh-my-openagent: 4.11.1 (latest available on npm: 4.19.1)
- OS: macOS 14.2.1 (arm64)
- node: v20.10.0
- bun: 1.3.6
Suggested Fix
Give the atlas boulder-continuation path the same guards todo-continuation-enforcer already has (ideally by sharing the logic):
- Before injecting (in
idle-continuation.tsand/or thescheduleRetrytimer), fetch the latest messages and skip when the latest assistant turn is a compaction marker or carries anerror(latestMessageWasCompaction,isLastAssistantMessageAborted), and honor the compaction guard +tokenLimitDetected. - Treat a non-retryable API failure detected on the session (not just a failed injection dispatch) as a
promptFailureCountincrement / stall condition, soMAX_CONSECUTIVE_PROMPT_FAILUREScan actually trip. - When stalling, surface the compaction error to the user and stop the loop instead of silently re-firing.
Additional Context
- Upstream opencode root cause (message splitting) is already reported and unfixed: fix(provider): Anthropic normalize splits tool-call from tool-result causing dangling tool_use error anomalyco/opencode#25774 (open), #27594 (closed NOT_PLANNED), #14367; four fix PRs (#25775 / #31547 / #21613 / #16751) are all closed & unmerged. So the 400 will keep happening from opencode's side — which is exactly why the continuation loop needs to fail safe.
- Related but distinct oh-my-openagent issues: 🐛 [BUG]
todo-continuation-enforcerhook causes system-directive spam loop, mid-stream text fragmentation, and unresponsive sessions #6109 (same class of directive-spam loop, but ontodo-continuation-enforcer) and [BUG] task(task_id=...) to running background subagent silently drops prompt and reports success #5966. This report is specifically about theatlasboulder path not inheriting the 🐛 [BUG]todo-continuation-enforcerhook causes system-directive spam loop, mid-stream text fragmentation, and unresponsive sessions #6109 guards.
Activity
code-yeongyu commentedon Aug 6, 2026
[sisyphus-bot] Thanks for the detailed comparison with #6109 and the upstream Anthropic failure. The boulder path still has the reported failure mode: it resets its failure count when the directive dispatch is accepted, while the later compaction 400 is invisible to that accounting, and it lacks the todo enforcer's compaction/non-retryable-error guards. This can re-inject the directive indefinitely against the same failed compaction.
Evidence: packages/omo-opencode/src/hooks/atlas/idle-continuation.ts:143-184 retries only on promptFailureCount/stall flags and has no compaction/error guards; packages/omo-opencode/src/hooks/atlas/boulder-continuation-injector.ts:105-116 resets promptFailureCount after accepted injection. By contrast, packages/omo-opencode/src/hooks/todo-continuation-enforcer/idle-event.ts:50-75, 89-108, and 146-184 has token-limit, non-retryable-error, aborted-turn, compaction-marker, and backoff guards.
code-yeongyu commentedon Aug 6, 2026
[sisyphus-bot] Triage: this report (atlas boulder-continuation looping on failed compaction) is still open and needs maintainer investigation. We reviewed the current dev code around the reported area and could not confirm an existing fix, so we're treating it as a real open bug. Assigning to @code-yeongyu. If you can still reproduce on the latest release, any fresh logs or a minimal repro in the thread would speed up the fix. Thanks for the detailed report!