fix(checkpoints): replace resume with fresh continuation agents

Resume fails when subagents use parallel tool calls due to Claude Code
serialization bug (consecutive assistant entries with same message ID).

Solution: Subagents return structured checkpoint state, orchestrator
spawns fresh agent with continuation-prompt template instead of resuming.

New files:
- templates/checkpoint-return.md: Structured format with completed tasks table
- templates/continuation-prompt.md: Template for spawning continuation agent

Updated:
- templates/subagent-task-prompt.md: Reference checkpoint-return, remove resume language
- workflows/execute-phase.md: Replace Task(resume=id) with fresh agent spawn
- workflows/execute-plan.md: Update checkpoint_return_for_orchestrator step

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Lex Christopherson
2026-01-13 17:44:43 -06:00
parent 601e67e0f2
commit 69300f975f
5 changed files with 544 additions and 58 deletions

View File

@@ -211,55 +211,70 @@ Plans with `autonomous: false` require user interaction.
2. **Agent runs until checkpoint:**
- Executes auto tasks normally
- Reaches checkpoint task (e.g., `type="checkpoint:human-verify"`)
- Agent returns with checkpoint details in its response
- Reaches checkpoint task (e.g., `type="checkpoint:human-verify"`) or auth gate
- Agent returns with structured checkpoint (see checkpoint-return.md template)
3. **Agent return includes:**
- Checkpoint type (human-verify, decision, human-action)
- Checkpoint details (what-built, options, instructions)
- Agent ID for resumption
- Progress so far (tasks completed)
3. **Agent return includes (structured format):**
- Completed Tasks table with commit hashes and files
- Current task name and blocker
- Checkpoint type and details for user
- What's awaited from user
4. **Orchestrator presents checkpoint to user:**
Extract and display the "Checkpoint Details" and "Awaiting" sections from agent return:
```
## Checkpoint: Visual Verification Required
## Checkpoint: [Type]
**Plan:** 03-03 Dashboard Layout
**Progress:** 2/3 tasks complete
**What was built:**
Responsive dashboard with sidebar navigation
[Checkpoint Details section from agent return]
**Please verify:**
1. Run: npm run dev
2. Visit: http://localhost:3000/dashboard
3. Desktop (>1024px): Verify sidebar left, content right
4. Mobile (375px): Verify single column layout
Type "approved" to continue, or describe issues to fix.
[Awaiting section from agent return]
```
5. **User responds:**
- "approved" → resume agent
- Description of issues → resume agent with feedback
- "approved" / "done" → spawn continuation agent
- Description of issues → spawn continuation agent with feedback
- Decision selection → spawn continuation agent with choice
6. **Resume agent:**
6. **Spawn continuation agent (NOT resume):**
Use the continuation-prompt.md template:
```
Task(resume="{agent_id}", prompt="User response: {user_input}")
Task(
prompt=filled_continuation_template,
subagent_type="general-purpose"
)
```
7. **Agent continues from checkpoint:**
- If approved: proceed to next task
- If issues: fix and re-present checkpoint, or ask for clarification
Fill template with:
- `{completed_tasks_table}`: From agent's checkpoint return
- `{resume_task_number}`: Current task from checkpoint
- `{resume_task_name}`: Current task name from checkpoint
- `{user_response}`: What user provided
- `{resume_instructions}`: Based on checkpoint type (see continuation-prompt.md)
7. **Continuation agent executes:**
- Verifies previous commits exist
- Continues from resume point
- May hit another checkpoint (repeat from step 4)
- Or completes plan
8. **Repeat until plan completes or user stops**
**Why fresh agent instead of resume:**
Resume relies on Claude Code's internal serialization which breaks with parallel tool calls.
Fresh agents with explicit state are more reliable and maintain full context.
**Checkpoint in parallel context:**
If a plan in a parallel wave has a checkpoint:
- Spawn as normal
- Agent pauses at checkpoint and returns
- Agent pauses at checkpoint and returns with structured state
- Other parallel agents may complete while waiting
- Handle checkpoint, resume agent
- Present checkpoint to user
- Spawn continuation agent with user response
- Wait for all agents to finish before next wave
</step>

View File

@@ -1155,36 +1155,72 @@ See ~/.claude/get-shit-done/references/checkpoints.md for complete checkpoint gu
<step name="checkpoint_return_for_orchestrator">
**When spawned by an orchestrator (execute-phase or execute-plan command):**
If you were spawned via Task tool and hit a checkpoint, you cannot directly interact with the user. Instead, RETURN to the orchestrator with checkpoint details so it can present to the user and resume you.
If you were spawned via Task tool and hit a checkpoint, you cannot directly interact with the user. Instead, RETURN to the orchestrator with structured checkpoint state so it can present to the user and spawn a fresh continuation agent.
**Return format for checkpoints:**
Use the structured format from:
@~/.claude/get-shit-done/templates/checkpoint-return.md
**Required in your return:**
1. **Completed Tasks table** - Tasks done so far with commit hashes and files created
2. **Current Task** - Which task you're on and what's blocking it
3. **Checkpoint Details** - User-facing content (verification steps, decision options, or action instructions)
4. **Awaiting** - What you need from the user
**Example return:**
```
## CHECKPOINT REACHED
**Type:** [human-verify | decision | human-action]
**Plan:** {phase}-{plan}
**Progress:** {completed}/{total} tasks complete
**Type:** human-action
**Plan:** 01-01
**Progress:** 1/3 tasks complete
[Checkpoint content - same as checkpoint_protocol display above]
### Completed Tasks
**Awaiting:** [Resume signal from the task]
| Task | Name | Commit | Files |
|------|------|--------|-------|
| 1 | Initialize Next.js 15 project | d6fe73f | package.json, tsconfig.json, app/ |
### Current Task
**Task 2:** Initialize Convex backend
**Status:** blocked
**Blocked by:** Convex CLI authentication required
### Checkpoint Details
**Automation attempted:**
Ran `npx convex dev` to initialize Convex backend
**Error encountered:**
"Error: Not authenticated. Run `npx convex login` first."
**What you need to do:**
1. Run: `npx convex login`
2. Complete browser authentication
3. Run: `npx convex dev`
4. Create project when prompted
**I'll verify after:**
`cat .env.local | grep CONVEX` returns the Convex URL
### Awaiting
Type "done" when Convex is authenticated and project created.
```
**After you return:**
The orchestrator will:
1. Parse your return
2. Present the checkpoint to the user
1. Parse your structured return
2. Present checkpoint details to the user
3. Collect user's response
4. Resume you with: `Task(resume=your_agent_id, prompt="User response: {their_input}")`
4. Spawn a FRESH continuation agent with your completed tasks state
**When resumed after checkpoint:**
You will receive a prompt like: `"User response: approved"` or `"User response: option-a"`
- Parse the user's response
- If approved/done: continue to next task
- If issues described: address them, then continue or re-present checkpoint
- If option selected: proceed with that choice
You will NOT be resumed. A new agent continues from where you stopped, using your Completed Tasks table to know what's done.
**How to know if you were spawned:**