Skip to content

Commit c8e61c6

Browse files
cahaselerclaude
andauthored
fix: prevent orchestrator context overflow from TaskOutput polling (#187)
Subagent orchestration instructions were telling Claude to poll or wait for subagent results using TaskOutput/AgentOutputTool, which dumps the subagent's entire working context into the orchestrator's context window. Updated commands/tasks.md, commands/spotless.md, and templates/tasks-template.md to instruct the orchestrator to post a status message and STOP, letting the notification system wake it when subagents complete. Co-authored-by: Craig Haseler <cahaseler@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent ca157b3 commit c8e61c6

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

commands/spotless.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ You are investigating recent changes in {area_name} for dead code artifacts.
209209
Save your report to: .cc-track/analysis/spotless/area_reports/{area_name}_report.md
210210
```
211211

212-
**Wait** for all investigation subagents to complete.
212+
Post a status message: "Waiting for investigation subagents to complete." and **STOP**. Do NOT call TaskOutput to poll. The system will wake you when each subagent completes.
213213

214214
---
215215

@@ -251,7 +251,7 @@ You are validating a finding from dead code analysis.
251251
Save to: .cc-track/analysis/spotless/validations/{finding_id}_validation.md
252252
```
253253

254-
**Wait** for all validation subagents to complete.
254+
Post a status message: "Waiting for validation subagents to complete." and **STOP**. Do NOT call TaskOutput to poll. The system will wake you when each subagent completes.
255255

256256
---
257257

commands/tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ TaskUpdate: "P3: Tests" addBlockedBy: ["P3: Stub"]
293293
294294
**Use `TaskList`** to see what's unblocked and ready to dispatch. The native system enforces dependencies automatically - you can't accidentally start Tests before Stub completes.
295295
296-
**Pipeline flow**: As each step completes, its dependents become unblocked. Dispatch newly-unblocked tasks immediately for maximum parallelism.
296+
**Pipeline flow**: Dispatch all unblocked tasks, post a status message ("Waiting for task completion."), and **STOP**. Do NOT call TaskOutput to watch or poll subagents - this dumps their entire working context into the orchestrator's context window, causing rapid context overflow. When a subagent completes, the system wakes the orchestrator automatically. At that point, update task status, check `TaskList` for newly unblocked tasks, dispatch them, and wait again.
297297
298-
See `${CLAUDE_PLUGIN_ROOT}/templates/tasks-template.md` for additional orchestration patterns (polling fallback, dependency diagrams). These are included in the generated tasks.md.
298+
See `${CLAUDE_PLUGIN_ROOT}/templates/tasks-template.md` for additional orchestration patterns (dependency diagrams). These are included in the generated tasks.md.
299299
300300
### For Waived Phases
301301

templates/tasks-template.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,15 @@ When multiple phases are marked [P], use **pipeline flow** with native task coor
176176

177177
1. **Create all native tasks upfront** with `blockedBy` dependencies (see Setup above)
178178
2. **Use `TaskList`** to see all unblocked tasks ready to dispatch
179-
3. **Dispatch** all unblocked stub writers with `run_in_background: true` in a single message
180-
4. **Post status** to user: "Dispatched stub writers for Phases X, Y, Z."
181-
5. **Orchestration loop**:
179+
3. **Dispatch** all unblocked stub writers in a single message
180+
4. **Post status** to user: "Dispatched stub writers for Phases X, Y, Z. Waiting for task completion."
181+
5. **STOP and wait** - Do NOT call TaskOutput or poll agents. When a subagent completes, the system will wake you automatically with its results. At that point:
182+
- `TaskUpdate` the completed step's status to completed
182183
- `TaskList` to find newly unblocked tasks (e.g., Tests for completed Stubs)
183-
- Dispatch unblocked tasks, `TaskUpdate` status to in_progress
184-
- As agents complete, `TaskUpdate` status to completed
185-
- Repeat until all tasks complete
184+
- Dispatch any newly unblocked tasks, `TaskUpdate` their status to in_progress
185+
- Post another status message and wait again if tasks remain
186186

187-
The native `blockedBy` system automatically tracks what's ready - no manual dependency checking needed. As each step completes, its dependents become unblocked and appear in `TaskList`.
187+
**CRITICAL**: Never use TaskOutput to watch subagent progress. This dumps the subagent's entire working context into the orchestrator's context window, causing rapid context overflow. The notification system handles completion automatically.
188188

189189
### Dependency Enforcement
190190

0 commit comments

Comments
 (0)