Skip to content

Commit 45f54d1

Browse files
author
mrosnerr
committed
fix(agents): prevent orchestrator from rushing ahead of background agents
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 #2124, fixes #1967
1 parent 7e0a1a1 commit 45f54d1

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/agents/dynamic-agent-prompt-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export function buildExploreSection(agents: AvailableAgent[]): string {
116116

117117
return `### Explore Agent = Contextual Grep
118118
119-
Use it as a **peer tool**, not a fallback. Fire liberally.
119+
Use it as a **peer tool**, not a fallback. Fire liberally for discovery, not for files you already know.
120120
121121
**Use Direct Tools when:**
122122
${avoidWhen.map((w) => `- ${w}`).join("\n")}

src/agents/sisyphus.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,18 +333,17 @@ task(subagent_type="explore", run_in_background=true, load_skills=[], descriptio
333333
// Reference Grep (external)
334334
task(subagent_type="librarian", run_in_background=true, load_skills=[], description="Find JWT security docs", prompt="I'm implementing JWT auth and need current security best practices to choose token storage (httpOnly cookies vs localStorage) and set expiration policy. Find: OWASP auth guidelines, recommended token lifetimes, refresh token rotation strategies, common JWT vulnerabilities. Skip 'what is JWT' tutorials — production security guidance only.")
335335
task(subagent_type="librarian", run_in_background=true, load_skills=[], description="Find Express auth patterns", prompt="I'm building Express auth middleware and need production-quality patterns to structure my middleware chain. Find how established Express apps (1000+ stars) handle: middleware ordering, token refresh, role-based access control, auth error propagation. Skip basic tutorials — I need battle-tested patterns with proper error handling.")
336-
// Continue working immediately. System notifies on completion — collect with background_output then.
337-
338336
// WRONG: Sequential or blocking
339337
result = task(..., run_in_background=false) // Never wait synchronously for explore/librarian
340338
\`\`\`
341339
342340
### Background Result Collection:
343341
1. Launch parallel agents \u2192 receive task_ids
344-
2. Continue immediate work
345-
3. System sends \`<system-reminder>\` on each task completion — then call \`background_output(task_id="...")\`
346-
4. Need results not yet ready? **End your response.** The notification will trigger your next turn.
347-
5. Cleanup: Cancel disposable tasks individually via \`background_cancel(taskId="...")\`
342+
2. If you have DIFFERENT independent work \u2192 do it now
343+
3. Otherwise \u2192 **END YOUR RESPONSE.**
344+
4. System sends \`<system-reminder>\` on completion \u2192 triggers your next turn
345+
5. Collect via \`background_output(task_id="...")\`
346+
6. Cleanup: Cancel disposable tasks individually via \`background_cancel(taskId="...")\`
348347
349348
### Search Stop Conditions
350349

0 commit comments

Comments
 (0)