Skip to content

Commit 14f450b

Browse files
committed
refactor: sync delegate_task schema with OpenCode Task tool (resume→session_id, add command param)
1 parent 5a1da39 commit 14f450b

10 files changed

Lines changed: 108 additions & 100 deletions

File tree

src/agents/atlas.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,32 +323,32 @@ delegate_task(
323323
**If verification fails**: Resume the SAME session with the ACTUAL error output:
324324
\`\`\`typescript
325325
delegate_task(
326-
resume="ses_xyz789", // ALWAYS use the session from the failed task
326+
session_id="ses_xyz789", // ALWAYS use the session from the failed task
327327
load_skills=[...],
328328
prompt="Verification failed: {actual error}. Fix."
329329
)
330330
\`\`\`
331331
332332
### 3.5 Handle Failures (USE RESUME)
333333
334-
**CRITICAL: When re-delegating, ALWAYS use \`resume\` parameter.**
334+
**CRITICAL: When re-delegating, ALWAYS use \`session_id\` parameter.**
335335
336336
Every \`delegate_task()\` output includes a session_id. STORE IT.
337337
338338
If task fails:
339339
1. Identify what went wrong
340340
2. **Resume the SAME session** - subagent has full context already:
341-
\`\`\`typescript
342-
delegate_task(
343-
resume="ses_xyz789", // Session from failed task
344-
load_skills=[...],
345-
prompt="FAILED: {error}. Fix by: {specific instruction}"
346-
)
347-
\`\`\`
341+
\`\`\`typescript
342+
delegate_task(
343+
session_id="ses_xyz789", // Session from failed task
344+
load_skills=[...],
345+
prompt="FAILED: {error}. Fix by: {specific instruction}"
346+
)
347+
\`\`\`
348348
3. Maximum 3 retry attempts with the SAME session
349349
4. If blocked after 3 attempts: Document and continue to independent tasks
350350
351-
**Why resume is MANDATORY for failures:**
351+
**Why session_id is MANDATORY for failures:**
352352
- Subagent already read all files, knows the context
353353
- No repeated exploration = 70%+ token savings
354354
- Subagent knows what approaches already failed
@@ -493,7 +493,7 @@ You are the QA gate. Subagents lie. Verify EVERYTHING.
493493
- Parallelize independent tasks
494494
- Verify with your own tools
495495
- **Store session_id from every delegation output**
496-
- **Use \`resume="{session_id}"\` for retries, fixes, and follow-ups**
496+
- **Use \`session_id="{session_id}"\` for retries, fixes, and follow-ups**
497497
</critical_overrides>
498498
`
499499

src/agents/sisyphus.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,15 @@ AFTER THE WORK YOU DELEGATED SEEMS DONE, ALWAYS VERIFY THE RESULTS AS FOLLOWING:
209209
210210
Every \`delegate_task()\` output includes a session_id. **USE IT.**
211211
212-
**ALWAYS resume when:**
212+
**ALWAYS continue when:**
213213
| Scenario | Action |
214214
|----------|--------|
215-
| Task failed/incomplete | \`resume="{session_id}", prompt="Fix: {specific error}"\` |
216-
| Follow-up question on result | \`resume="{session_id}", prompt="Also: {question}"\` |
217-
| Multi-turn with same agent | \`resume="{session_id}"\` - NEVER start fresh |
218-
| Verification failed | \`resume="{session_id}", prompt="Failed verification: {error}. Fix."\` |
215+
| Task failed/incomplete | \`session_id="{session_id}", prompt="Fix: {specific error}"\` |
216+
| Follow-up question on result | \`session_id="{session_id}", prompt="Also: {question}"\` |
217+
| Multi-turn with same agent | \`session_id="{session_id}"\` - NEVER start fresh |
218+
| Verification failed | \`session_id="{session_id}", prompt="Failed verification: {error}. Fix."\` |
219219
220-
**Why resume is CRITICAL:**
220+
**Why session_id is CRITICAL:**
221221
- Subagent has FULL conversation context preserved
222222
- No repeated file reads, exploration, or setup
223223
- Saves 70%+ tokens on follow-ups
@@ -228,10 +228,10 @@ Every \`delegate_task()\` output includes a session_id. **USE IT.**
228228
delegate_task(category="quick", prompt="Fix the type error in auth.ts...")
229229
230230
// CORRECT: Resume preserves everything
231-
delegate_task(resume="ses_abc123", prompt="Fix: Type error on line 42")
231+
delegate_task(session_id="ses_abc123", prompt="Fix: Type error on line 42")
232232
\`\`\`
233233
234-
**After EVERY delegation, STORE the session_id for potential resume.**
234+
**After EVERY delegation, STORE the session_id for potential continuation.**
235235
236236
### Code Changes:
237237
- Match existing patterns (if codebase is disciplined)

src/hooks/atlas/index.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ describe("atlas hook", () => {
141141
// #then - standalone verification reminder appended
142142
expect(output.output).toContain("Task completed successfully")
143143
expect(output.output).toContain("MANDATORY:")
144-
expect(output.output).toContain("delegate_task(resume=")
144+
expect(output.output).toContain("delegate_task(session_id=")
145145

146146
cleanupMessageStorage(sessionID)
147147
})
@@ -180,7 +180,7 @@ describe("atlas hook", () => {
180180
expect(output.output).toContain("SUBAGENT WORK COMPLETED")
181181
expect(output.output).toContain("test-plan")
182182
expect(output.output).toContain("LIE")
183-
expect(output.output).toContain("delegate_task(resume=")
183+
expect(output.output).toContain("delegate_task(session_id=")
184184

185185
cleanupMessageStorage(sessionID)
186186
})
@@ -332,7 +332,7 @@ describe("atlas hook", () => {
332332
cleanupMessageStorage(sessionID)
333333
})
334334

335-
test("should include resume and checkbox instructions in reminder", async () => {
335+
test("should include session_id and checkbox instructions in reminder", async () => {
336336
// #given - boulder state, Atlas caller
337337
const sessionID = "session-resume-test"
338338
setupMessageStorage(sessionID, "atlas")
@@ -361,8 +361,8 @@ describe("atlas hook", () => {
361361
output
362362
)
363363

364-
// #then - should include resume instructions and verification
365-
expect(output.output).toContain("delegate_task(resume=")
364+
// #then - should include session_id instructions and verification
365+
expect(output.output).toContain("delegate_task(session_id=")
366366
expect(output.output).toContain("[x]")
367367
expect(output.output).toContain("MANDATORY:")
368368

src/hooks/atlas/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,13 @@ If you were NOT given **exactly ONE atomic task**, you MUST:
179179
`
180180

181181
function buildVerificationReminder(sessionId: string): string {
182-
return `${VERIFICATION_REMINDER}
182+
return `${VERIFICATION_REMINDER}
183183
184184
---
185185
186186
**If ANY verification fails, use this immediately:**
187187
\`\`\`
188-
delegate_task(resume="${sessionId}", prompt="fix: [describe the specific failure]")
188+
delegate_task(session_id="${sessionId}", prompt="fix: [describe the specific failure]")
189189
\`\`\``
190190
}
191191

@@ -711,8 +711,8 @@ export function createAtlasHook(
711711
return
712712
}
713713

714-
const outputStr = output.output && typeof output.output === "string" ? output.output : ""
715-
const isBackgroundLaunch = outputStr.includes("Background task launched") || outputStr.includes("Background task resumed")
714+
const outputStr = output.output && typeof output.output === "string" ? output.output : ""
715+
const isBackgroundLaunch = outputStr.includes("Background task launched") || outputStr.includes("Background task continued")
716716

717717
if (isBackgroundLaunch) {
718718
return

src/hooks/task-resume-info/index.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ function extractSessionId(output: string): string | null {
1616
}
1717

1818
export function createTaskResumeInfoHook() {
19-
const toolExecuteAfter = async (
20-
input: { tool: string; sessionID: string; callID: string },
21-
output: { title: string; output: string; metadata: unknown }
22-
) => {
23-
if (!TARGET_TOOLS.includes(input.tool)) return
24-
if (output.output.startsWith("Error:") || output.output.startsWith("Failed")) return
25-
if (output.output.includes("\nto resume:")) return
19+
const toolExecuteAfter = async (
20+
input: { tool: string; sessionID: string; callID: string },
21+
output: { title: string; output: string; metadata: unknown }
22+
) => {
23+
if (!TARGET_TOOLS.includes(input.tool)) return
24+
if (output.output.startsWith("Error:") || output.output.startsWith("Failed")) return
25+
if (output.output.includes("\nto continue:")) return
2626

27-
const sessionId = extractSessionId(output.output)
28-
if (!sessionId) return
27+
const sessionId = extractSessionId(output.output)
28+
if (!sessionId) return
2929

30-
output.output = output.output.trimEnd() + `\n\nto resume: delegate_task(resume="${sessionId}", prompt="...")`
31-
}
30+
output.output = output.output.trimEnd() + `\n\nto continue: delegate_task(session_id="${sessionId}", prompt="...")`
31+
}
3232

33-
return {
34-
"tool.execute.after": toolExecuteAfter,
35-
}
33+
return {
34+
"tool.execute.after": toolExecuteAfter,
35+
}
3636
}

src/tools/background-task/tools.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,18 +442,18 @@ export function createBackgroundCancel(manager: BackgroundManager, client: Openc
442442
.map(t => `| \`${t.id}\` | ${t.description} | ${t.status} | ${t.sessionID ? `\`${t.sessionID}\`` : "(not started)"} |`)
443443
.join("\n")
444444

445-
const resumableTasks = cancelledInfo.filter(t => t.sessionID)
446-
const resumeSection = resumableTasks.length > 0
447-
? `\n## Resume Instructions
445+
const resumableTasks = cancelledInfo.filter(t => t.sessionID)
446+
const resumeSection = resumableTasks.length > 0
447+
? `\n## Continue Instructions
448448
449-
To resume a cancelled task, use:
449+
To continue a cancelled task, use:
450450
\`\`\`
451-
delegate_task(resume="<session_id>", prompt="Continue: <your follow-up>")
451+
delegate_task(session_id="<session_id>", prompt="Continue: <your follow-up>")
452452
\`\`\`
453453
454-
Resumable sessions:
454+
Continuable sessions:
455455
${resumableTasks.map(t => `- \`${t.sessionID}\` (${t.description})`).join("\n")}`
456-
: ""
456+
: ""
457457

458458
return `Cancelled ${cancellableTasks.length} background task(s):
459459

src/tools/call-omo-agent/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ export const CALL_OMO_AGENT_DESCRIPTION = `Spawn explore/librarian agent. run_in
44
55
Available: {agents}
66
7-
Pass \`resume=session_id\` to continue previous agent with full context. Prompts MUST be in English. Use \`background_output\` for async results.`
7+
Pass \`session_id=<id>\` to continue previous agent with full context. Prompts MUST be in English. Use \`background_output\` for async results.`

src/tools/delegate-task/tools.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -594,16 +594,16 @@ describe("sisyphus-task", () => {
594594
}, { timeout: 20000 })
595595
})
596596

597-
describe("resume with background parameter", () => {
598-
test("resume with background=false should wait for result and return content", async () => {
597+
describe("session_id with background parameter", () => {
598+
test("session_id with background=false should wait for result and return content", async () => {
599599
// Note: This test needs extended timeout because the implementation has MIN_STABILITY_TIME_MS = 5000
600600
// #given
601601
const { createDelegateTask } = require("./tools")
602602

603603
const mockTask = {
604604
id: "task-123",
605-
sessionID: "ses_resume_test",
606-
description: "Resumed task",
605+
sessionID: "ses_continue_test",
606+
description: "Continued task",
607607
agent: "explore",
608608
status: "running",
609609
}
@@ -620,7 +620,7 @@ describe("sisyphus-task", () => {
620620
data: [
621621
{
622622
info: { role: "assistant", time: { created: Date.now() } },
623-
parts: [{ type: "text", text: "This is the resumed task result" }],
623+
parts: [{ type: "text", text: "This is the continued task result" }],
624624
},
625625
],
626626
}),
@@ -646,28 +646,28 @@ describe("sisyphus-task", () => {
646646
// #when
647647
const result = await tool.execute(
648648
{
649-
description: "Resume test",
649+
description: "Continue test",
650650
prompt: "Continue the task",
651-
resume: "ses_resume_test",
651+
session_id: "ses_continue_test",
652652
run_in_background: false,
653653
load_skills: ["git-master"],
654654
},
655655
toolContext
656656
)
657657

658-
// #then - should contain actual result, not just "Background task resumed"
659-
expect(result).toContain("This is the resumed task result")
660-
expect(result).not.toContain("Background task resumed")
658+
// #then - should contain actual result, not just "Background task continued"
659+
expect(result).toContain("This is the continued task result")
660+
expect(result).not.toContain("Background task continued")
661661
}, { timeout: 10000 })
662662

663-
test("resume with background=true should return immediately without waiting", async () => {
663+
test("session_id with background=true should return immediately without waiting", async () => {
664664
// #given
665665
const { createDelegateTask } = require("./tools")
666666

667667
const mockTask = {
668668
id: "task-456",
669-
sessionID: "ses_bg_resume",
670-
description: "Background resumed task",
669+
sessionID: "ses_bg_continue",
670+
description: "Background continued task",
671671
agent: "explore",
672672
status: "running",
673673
}
@@ -701,17 +701,17 @@ describe("sisyphus-task", () => {
701701
// #when
702702
const result = await tool.execute(
703703
{
704-
description: "Resume bg test",
704+
description: "Continue bg test",
705705
prompt: "Continue in background",
706-
resume: "ses_bg_resume",
706+
session_id: "ses_bg_continue",
707707
run_in_background: true,
708708
load_skills: ["git-master"],
709709
},
710710
toolContext
711711
)
712712

713713
// #then - should return background message
714-
expect(result).toContain("Background task resumed")
714+
expect(result).toContain("Background task continued")
715715
expect(result).toContain("task-456")
716716
})
717717
})

0 commit comments

Comments
 (0)