fix(background-task): clarify task id contracts
This commit is contained in:
+12
-9
@@ -266,14 +266,15 @@ result = task(..., run_in_background=false) // Never wait synchronously for exp
|
||||
\`\`\`
|
||||
|
||||
### Background Result Collection:
|
||||
1. Launch parallel agents \u2192 receive task_ids
|
||||
1. Launch parallel agents \u2192 receive background task IDs (\`bg_...\`) for results and continuation session IDs (\`ses_...\`) for follow-ups
|
||||
2. Continue only with non-overlapping work
|
||||
- If you have DIFFERENT independent work \u2192 do it now
|
||||
- Otherwise \u2192 **END YOUR RESPONSE.**
|
||||
3. **STOP. END YOUR RESPONSE.** The system will send \`<system-reminder>\` when tasks complete.
|
||||
4. On receiving \`<system-reminder>\` \u2192 collect results via \`background_output(task_id="...")\`
|
||||
4. On receiving \`<system-reminder>\` \u2192 collect results via \`background_output(task_id="bg_...")\`
|
||||
5. **NEVER call \`background_output\` before receiving \`<system-reminder>\`.** This is a BLOCKING anti-pattern.
|
||||
6. Cleanup: Cancel disposable tasks individually via \`background_cancel(taskId="...")\`
|
||||
7. Use \`task(task_id="ses_...")\` only to continue the same sub-agent session
|
||||
|
||||
${buildAntiDuplicationSection()}
|
||||
|
||||
@@ -328,15 +329,17 @@ AFTER THE WORK YOU DELEGATED SEEMS DONE, ALWAYS VERIFY THE RESULTS AS FOLLOWING:
|
||||
|
||||
### Session Continuity (MANDATORY)
|
||||
|
||||
Every \`task()\` output includes a task_id. **USE IT.**
|
||||
Every \`task()\` output exposes a continuation session ID (\`ses_...\`). Pass it to \`task(task_id="ses_...")\` for follow-ups. **USE IT.**
|
||||
|
||||
**ALWAYS continue when:**
|
||||
- Task failed/incomplete → \`task_id=\"{task_id}\", prompt=\"Fix: {specific error}\"\`
|
||||
- Follow-up question on result → \`task_id=\"{task_id}\", prompt=\"Also: {question}\"\`
|
||||
- Multi-turn with same agent → \`task_id=\"{task_id}\"\` - NEVER start fresh
|
||||
- Verification failed → \`task_id=\"{task_id}\", prompt=\"Failed verification: {error}. Fix.\"\`
|
||||
- Task failed/incomplete → \`task(task_id="ses_...", prompt="Fix: {specific error}")\`
|
||||
- Follow-up question on result → \`task(task_id="ses_...", prompt="Also: {question}")\`
|
||||
- Multi-turn with same agent → \`task(task_id="ses_...")\` - NEVER start fresh
|
||||
- Verification failed → \`task(task_id="ses_...", prompt="Failed verification: {error}. Fix.")\`
|
||||
|
||||
**Why task_id is CRITICAL:**
|
||||
**Keep IDs separate:** background task IDs (\`bg_...\`) are for \`background_output(task_id="bg_...")\`; continuation session IDs (\`ses_...\`) are for \`task(task_id="ses_...")\`.
|
||||
|
||||
**Why continuation is CRITICAL:**
|
||||
- Subagent has FULL conversation context preserved
|
||||
- No repeated file reads, exploration, or setup
|
||||
- Saves 70%+ tokens on follow-ups
|
||||
@@ -350,7 +353,7 @@ task(category="quick", load_skills=[], run_in_background=false, description="Fix
|
||||
task(task_id="ses_abc123", load_skills=[], run_in_background=false, description="Fix type error", prompt="Fix: Type error on line 42")
|
||||
\`\`\`
|
||||
|
||||
**After EVERY delegation, STORE the task_id for potential continuation.**
|
||||
**After EVERY delegation, STORE the \`ses_...\` continuation ID for potential continuation.**
|
||||
|
||||
### Code Changes:
|
||||
- Match existing patterns (if codebase is disciplined)
|
||||
|
||||
Reference in New Issue
Block a user