Skip to content

fix(atlas): restore agent mismatch guard for subagent boulder continuation#2751

Merged
code-yeongyu merged 1 commit intocode-yeongyu:devfrom
sjawhar:fix/atlas-subagent-agent-guard
Mar 25, 2026
Merged

fix(atlas): restore agent mismatch guard for subagent boulder continuation#2751
code-yeongyu merged 1 commit intocode-yeongyu:devfrom
sjawhar:fix/atlas-subagent-agent-guard

Conversation

@sjawhar
Copy link
Copy Markdown
Contributor

@sjawhar sjawhar commented Mar 23, 2026

Summary

Restores the agent mismatch guard for boulder continuation that was accidentally removed on Mar 9 (vmxzmltv / 53337ad6), preventing worker subagent sessions from receiving plan-scoped continuation that overrides their single-task constraint.

  • Add agent check in idle-event.ts: subagent sessions only get boulder continuation if their agent matches the boulder's required agent (atlas/sisyphus)
  • Orchestrator sessions (not in subagentSessions) bypass the check entirely
  • Add 3 new tests + update existing adoption test to cover agent-based filtering

Closes #18681

Problem

The atlas hook's resolveActiveBoulderSession() adopts task-spawned subagent sessions into the boulder via lineage walking. Once adopted, BOULDER_CONTINUATION_PROMPT ("read the plan file, do all tasks") is injected regardless of the subagent's agent type.

This causes worker subagents running as sisyphus-junior, oracle, explore, etc. to override their single-task constraint and race through the entire plan in parallel, stepping on each other's file edits.

Root Cause

The original atlas hook had a shouldSkipForAgentMismatch guard that only allowed sessions whose agent matched the boulder's required agent. This guard was removed in commit vmxzmltv ("fix(atlas): append idle subagent sessions to active boulder") when the adoption mechanism was refactored. The subsequent lineage restriction (kovyrtor) did not restore it.

Fix

Add an agent mismatch guard in handleAtlasSessionIdle() after the adoption/append log block and before continuation injection:

  • If session is in subagentSessions (task-spawned), verify agent matches boulder's required agent
  • Allow sisyphus for atlas-agent boulders (original pre-regression allowance)
  • Sessions NOT in subagentSessions (the orchestrator) always bypass the check
  • The adoption mechanism (lineage check + appendSessionId) remains intact for tracking purposes

Testing

  • 91 atlas tests pass (0 fail)
  • bun run typecheck clean
  • 3 new tests added:
    • Non-matching agent subagent → adopted but NO continuation
    • Matching agent subagent → adopted + continuation
    • Tracked boulder session with any agent → always gets continuation
  • Existing adoption test updated to set matching agent

Summary by cubic

Restore the agent mismatch guard for boulder continuation so only matching subagents receive continuation; prevents worker subagents from bypassing their single-task constraint. Addresses Linear #18681.

  • Bug Fixes
    • Reintroduce guard in handleAtlasSessionIdle: for sessions in subagentSessions, require agent match with boulder agent; allow sisyphus when boulder agent is atlas.
    • Orchestrator sessions bypass the check.
    • Add 3 tests (match, mismatch, tracked session) and update adoption test.

Written for commit 5777bf9. Summary will update on new commits.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Restores a previously removed agent mismatch guard to prevent subagents from incorrectly continuing boulders, fixing a known regression with comprehensive test coverage.

@code-yeongyu code-yeongyu added the triage:bug-fix PR: Bug fix label Mar 24, 2026
@code-yeongyu code-yeongyu merged commit cd04e6a into code-yeongyu:dev Mar 25, 2026
3 checks passed
@sjawhar sjawhar deleted the fix/atlas-subagent-agent-guard branch March 26, 2026 13:48
sjawhar added a commit to sjawhar/oh-my-opencode that referenced this pull request Mar 26, 2026
Rebased onto dev@upstream (v3.13.1). Dropped fix/look-at-respect-configured-model and fix/atlas-subagent-agent-guard (merged upstream as PRs code-yeongyu#2686 and code-yeongyu#2751).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage:bug-fix PR: Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants