Skip to content

fix(agents): prevent orchestrator from rushing ahead of background agents#2328

Merged
code-yeongyu merged 2 commits intocode-yeongyu:devfrom
mrosnerr:fix/background-result-collection-wait-behavior
Mar 9, 2026
Merged

fix(agents): prevent orchestrator from rushing ahead of background agents#2328
code-yeongyu merged 2 commits intocode-yeongyu:devfrom
mrosnerr:fix/background-result-collection-wait-behavior

Conversation

@mrosnerr
Copy link
Contributor

@mrosnerr mrosnerr commented Mar 5, 2026

Summary

  • Tighten Sisyphus prompt's Background Result Collection instructions so the model waits for explore/librarian results instead of duplicating their work and delivering premature answers.

Changes

  • src/agents/sisyphus.ts: Remove Continue working immediately instruction (which models interpreted as "do ALL work yourself, ignore agents"). Restructure Background Result Collection steps to: (1) launch agents, (2) do DIFFERENT independent work if any, (3) otherwise END RESPONSE and wait for system-reminder, (4-6) collect results and clean up.
  • src/agents/dynamic-agent-prompt-builder.ts: Add not for files you already know to explore section header to reduce duplicate reads when the parent already knows file locations.

Testing

Tested locally with 3 models via opencode run --format json:

Scenario Claude Opus 4.6 Gemini 2.5 Pro GPT-4.1
Broad discovery (unknown files) ✅ Fires bg agents, waits ✅ 4 bg agents, waits ✅ 2 bg agents, waits
Known directory question ✅ Direct tools only ✅ Direct tools only ✅ Direct tools only
bun run typecheck  # ✅ passes
bun test           # ✅ 639 tests pass
bun run build      # ✅ succeeds

Related Issues

Closes #2124
Closes #1967


Summary by cubic

Make the orchestrator wait for explore/librarian background agents before proceeding, preventing duplicate work and premature answers (fixes #2124, #1967). Also scope the Explore Agent to discovery-only when file locations are already known.

  • Bug Fixes
    • Sisyphus prompts (all variants): removed “Continue working immediately”; clarified to only do different independent work while waiting, otherwise end response and wait for the system reminder; then collect via background_output and clean up with background_cancel.
    • Explore prompt builder: added “not for files you already know” to reduce duplicate reads.

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

Copy link

@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 2 files

Confidence score: 5/5

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

Auto-approved: Prompt adjustments tighten orchestration logic to prevent race conditions and duplicate work, with verified test results across multiple models.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

@mrosnerr
Copy link
Contributor Author

mrosnerr commented Mar 5, 2026

I have read the CLA Document and I hereby sign the CLA

@mrosnerr mrosnerr force-pushed the fix/background-result-collection-wait-behavior branch from 45f54d1 to 62abecd Compare March 5, 2026 17:57
github-actions bot added a commit that referenced this pull request Mar 5, 2026
@specialfortificationgoods-cpu

Hopefully this fix would help with the subagents in general, ie rushing sisyphus-junior subagents

Copy link
Collaborator

@acamq acamq left a comment

Choose a reason for hiding this comment

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

LGTM

@acamq acamq requested a review from code-yeongyu March 9, 2026 00:30
mrosnerr and others added 2 commits March 9, 2026 12:41
…ents

Tighten Background Result Collection instructions so the model waits
for explore/librarian results instead of duplicating their work and
delivering premature answers.

- Remove 'Continue working immediately' which models interpreted as
  'do ALL work yourself, ignore agents'
- Clarify step 2: only do DIFFERENT independent work while waiting
- Add explicit step 3: end response when no other work remains
- Add 'not for files you already know' to explore section header

Fixes code-yeongyu#2124, fixes code-yeongyu#1967
…hus variants

The prompt update from sisyphus.ts was not applied to the gpt-5-4 and
default variant files. This aligns all three sisyphus prompt variants
to use the updated background result handling guidance.
@code-yeongyu code-yeongyu force-pushed the fix/background-result-collection-wait-behavior branch from 62abecd to f1f682c Compare March 9, 2026 04:16
@code-yeongyu code-yeongyu merged commit 9e07f1d into code-yeongyu:dev Mar 9, 2026
7 checks passed
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.

[Bug]: Plan agent not wait Explore agent [Feature]: Removing orchestrator rushing thorough executors

4 participants