Skip to content

fix(atlas): schedule delayed retry when cooldown blocks boulder continuation#2335

Merged
code-yeongyu merged 10 commits intodevfrom
fix/boulder-continuation-abort
Mar 6, 2026
Merged

fix(atlas): schedule delayed retry when cooldown blocks boulder continuation#2335
code-yeongyu merged 10 commits intodevfrom
fix/boulder-continuation-abort

Conversation

@code-yeongyu
Copy link
Copy Markdown
Owner

@code-yeongyu code-yeongyu commented Mar 6, 2026

Summary

  • Fixes boulder continuation getting permanently stuck when the model's response is immediately aborted after atlas injects a continuation prompt
  • Root cause: After abort, OpenCode fires a burst of session.idle events within milliseconds, all blocked by 5s cooldown. After the burst stops, no more idle events come (state-change based, not periodic) — session stuck forever
  • Fix: Schedule a one-shot setTimeout (cooldown + 1s = 6s) when cooldown blocks an idle event for a boulder with incomplete plan. Timer re-checks boulder state/plan/continuation-stopped before injecting. Deduped via pendingRetryTimer field. Cleaned up on session.deleted/session.compacted

Changes

  • src/hooks/atlas/types.ts: Added pendingRetryTimer field to SessionState
  • src/hooks/atlas/event-handler.ts: Added delayed retry timer in cooldown skip branch + timer cleanup in session.deleted/compacted handlers
  • src/hooks/atlas/index.test.ts: 5 new TDD tests covering retry scheduling, dedup, plan-complete bailout, and cleanup on delete/compact

Test Results

All 46 tests pass (41 existing + 5 new). Typecheck clean.


Summary by cubic

Prevents atlas boulder continuation from getting stuck after an aborted response by scheduling a delayed retry once the cooldown passes. Also tightens retry checks, adds model‑routed prompts, the Final Verification Wave, QA scenario checks, and updates fallbacks to prefer gpt‑5.4.

  • Bug Fixes

    • Atlas: schedule a 6s delayed retry when cooldown blocks idle, preventing permanent stalls after abort-driven idle bursts.
    • Retry callback: re-checks failure backoff count, boulder session membership, and running tasks before injecting; one timer per session; cleared on session.deleted/compacted.
    • Tests: use fake timers to intercept delayed retries and speed up runs; added coverage for retry scheduling, dedup, bailout on completed plans, and timer cleanup.
    • Start‑Work: remove “Worktree Setup Required” when unspecified; when a worktree exists, inject a concise “Worktree Active” block with strict path rules.
  • New Features

    • Hephaestus agent: new GPT‑specific prompt variants (gpt‑5.4, gpt‑5.3‑codex, generic) with auto routing and tests.
    • Sisyphus‑Junior: adds GPT‑5.4 and GPT‑5.3‑codex prompts with model‑based routing.
    • Atlas prompts: add Final Verification Wave tracking and todos.
    • Metis & Momus: enforce executable QA scenarios for each task.
    • Model selection: “unspecified‑high” now prefers gpt‑5.4; fallbacks updated and add opencode provider to glm‑5; CLI snapshots aligned.

Written for commit b062fc4. Summary will update on new commits.

code-yeongyu and others added 8 commits March 6, 2026 14:20
…trong worktree active instructions

When no worktree is specified in boulder, stop injecting 'Worktree Setup Required'
instructions. When worktree IS present, inject emphatic instructions ensuring the
agent and all subagents operate exclusively within the worktree directory.
…, gpt-5-3-codex, generic gpt)

Split GPT prompt into three variants with model-based routing:
- gpt-5-4.ts: GPT-5.4 optimized (expert coding agent framing, prose-first)
- gpt-5-3-codex.ts: GPT-5.3-Codex optimized (Hephaestus-style Senior Engineer)
- gpt.ts: Generic GPT fallback (Hephaestus-style, for any other GPT model)

Routing: gpt-5.4 → gpt-5-4 | gpt-5.3-codex → gpt-5-3-codex | other GPT → gpt

🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
… routing

Split monolithic hephaestus.ts into directory with model-specific prompt
variants (gpt-5-4.ts, gpt-5-3-codex.ts, gpt.ts) mirroring the
sisyphus-junior pattern. Generic gpt.ts uses pre-codex-tuning prompt as
fallback for non-specific GPT models.

Also adds isGpt5_4Model and isGpt5_3CodexModel helpers to types.ts.
…nuation

When atlas injects a boulder continuation via promptAsync() and the
model's response is immediately aborted (MessageAbortedError), OpenCode
fires a burst of session.idle events within milliseconds. Atlas blocks
all of them due to the 5-second cooldown. After the burst, OpenCode
stops generating session.idle events (it's state-change based, not
periodic), leaving the session stuck forever.

Fix: When cooldown blocks an idle event for a boulder session with an
incomplete plan, schedule a one-shot setTimeout (cooldown + 1s) to
re-attempt injection. The timer callback re-checks boulder state, plan
progress, and continuation-stopped flag before injecting. Only one timer
per session is allowed (deduped via pendingRetryTimer field). Timers are
cleaned up on session.deleted and session.compacted events.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 40 files

Confidence score: 3/5

  • There is a concrete regression risk in src/hooks/atlas/event-handler.ts: delayed retry can continue without re-running full eligibility checks, which may cause duplicate or invalid injections in real flows.
  • src/cli/model-fallback-requirements.ts is missing the opencode provider for glm-5, creating a runtime/requirements mismatch risk that can surface as provider fallback failures.
  • This lands at moderate merge risk because multiple medium-to-high severity issues are identified with high confidence, including one clearly user-impacting behavior and several maintainability/CI stability concerns.
  • Pay close attention to src/hooks/atlas/event-handler.ts, src/cli/model-fallback-requirements.ts, src/hooks/atlas/index.test.ts, and src/agents/sisyphus-junior/gpt-5-3-codex.ts - injection validity, provider consistency, test-runtime slowdown, and duplicated template logic need follow-up.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/cli/model-fallback-requirements.ts">

<violation number="1" location="src/cli/model-fallback-requirements.ts:275">
P2: Add the 'opencode' provider to the glm-5 model to remain consistent with visual-engineering and runtime requirements.</violation>
</file>

<file name="src/hooks/atlas/index.test.ts">

<violation number="1" location="src/hooks/atlas/index.test.ts:1449">
P2: Using real `setTimeout` with a 7000ms delay in unit tests adds 35 seconds of dead waiting time across these 5 new tests, significantly slowing down CI and local test execution. Consider mocking the timer (e.g., using `jest.useFakeTimers()` provided by `bun:test`, or a custom fake timer like the one used in `todo-continuation-enforcer.test.ts`) to instantly advance time instead.</violation>
</file>

<file name="src/agents/sisyphus-junior/gpt-5-3-codex.ts">

<violation number="1" location="src/agents/sisyphus-junior/gpt-5-3-codex.ts:11">
P2: This file is an exact duplicate of \`src/agents/sisyphus-junior/gpt.ts\`, with only the function names and top comment changed. The entire 150-line string template is duplicated verbatim. Consider reusing \`buildGptSisyphusJuniorPrompt\` or extracting the shared prompt string to avoid maintaining two identical copies.</violation>
</file>

<file name="src/hooks/atlas/event-handler.ts">

<violation number="1" location="src/hooks/atlas/event-handler.ts:128">
P1: Delayed retry injects continuation without re-running full eligibility checks, which can trigger duplicate or invalid injections.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread src/hooks/atlas/event-handler.ts
Comment thread src/cli/model-fallback-requirements.ts Outdated
Comment thread src/hooks/atlas/index.test.ts Outdated
@@ -0,0 +1,151 @@
/**
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This file is an exact duplicate of `src/agents/sisyphus-junior/gpt.ts`, with only the function names and top comment changed. The entire 150-line string template is duplicated verbatim. Consider reusing `buildGptSisyphusJuniorPrompt` or extracting the shared prompt string to avoid maintaining two identical copies.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/agents/sisyphus-junior/gpt-5-3-codex.ts, line 11:

<comment>This file is an exact duplicate of \`src/agents/sisyphus-junior/gpt.ts\`, with only the function names and top comment changed. The entire 150-line string template is duplicated verbatim. Consider reusing \`buildGptSisyphusJuniorPrompt\` or extracting the shared prompt string to avoid maintaining two identical copies.</comment>

<file context>
@@ -0,0 +1,151 @@
+
+import { resolvePromptAppend } from "../builtin-agents/resolve-file-uri"
+
+export function buildGpt53CodexSisyphusJuniorPrompt(
+  useTaskSystem: boolean,
+  promptAppend?: string
</file context>
Fix with Cubic

Address Cubic P1 review: timer callback now re-checks failure backoff
count, boulder session membership, and running background tasks before
injecting continuation, matching the main idle handler's eligibility
gate.
…vider to glm-5

Replace real setTimeout(7000) with fake timer interception in atlas
retry tests (35s -> 227ms). Add missing opencode provider to glm-5
fallback in unspecified-high category.
@code-yeongyu code-yeongyu merged commit cfb9435 into dev Mar 6, 2026
8 checks passed
@code-yeongyu code-yeongyu deleted the fix/boulder-continuation-abort branch March 6, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants