refactor: sync delegate_task schema with OpenCode Task tool (resume→session_id, add command param)

This commit is contained in:
justsisyphus
2026-01-25 13:28:44 +09:00
parent 5a1da39def
commit 14f450bd25
10 changed files with 108 additions and 100 deletions
+5 -5
View File
@@ -141,7 +141,7 @@ describe("atlas hook", () => {
// #then - standalone verification reminder appended
expect(output.output).toContain("Task completed successfully")
expect(output.output).toContain("MANDATORY:")
expect(output.output).toContain("delegate_task(resume=")
expect(output.output).toContain("delegate_task(session_id=")
cleanupMessageStorage(sessionID)
})
@@ -180,7 +180,7 @@ describe("atlas hook", () => {
expect(output.output).toContain("SUBAGENT WORK COMPLETED")
expect(output.output).toContain("test-plan")
expect(output.output).toContain("LIE")
expect(output.output).toContain("delegate_task(resume=")
expect(output.output).toContain("delegate_task(session_id=")
cleanupMessageStorage(sessionID)
})
@@ -332,7 +332,7 @@ describe("atlas hook", () => {
cleanupMessageStorage(sessionID)
})
test("should include resume and checkbox instructions in reminder", async () => {
test("should include session_id and checkbox instructions in reminder", async () => {
// #given - boulder state, Atlas caller
const sessionID = "session-resume-test"
setupMessageStorage(sessionID, "atlas")
@@ -361,8 +361,8 @@ describe("atlas hook", () => {
output
)
// #then - should include resume instructions and verification
expect(output.output).toContain("delegate_task(resume=")
// #then - should include session_id instructions and verification
expect(output.output).toContain("delegate_task(session_id=")
expect(output.output).toContain("[x]")
expect(output.output).toContain("MANDATORY:")
+4 -4
View File
@@ -179,13 +179,13 @@ If you were NOT given **exactly ONE atomic task**, you MUST:
`
function buildVerificationReminder(sessionId: string): string {
return `${VERIFICATION_REMINDER}
return `${VERIFICATION_REMINDER}
---
**If ANY verification fails, use this immediately:**
\`\`\`
delegate_task(resume="${sessionId}", prompt="fix: [describe the specific failure]")
delegate_task(session_id="${sessionId}", prompt="fix: [describe the specific failure]")
\`\`\``
}
@@ -711,8 +711,8 @@ export function createAtlasHook(
return
}
const outputStr = output.output && typeof output.output === "string" ? output.output : ""
const isBackgroundLaunch = outputStr.includes("Background task launched") || outputStr.includes("Background task resumed")
const outputStr = output.output && typeof output.output === "string" ? output.output : ""
const isBackgroundLaunch = outputStr.includes("Background task launched") || outputStr.includes("Background task continued")
if (isBackgroundLaunch) {
return
+14 -14
View File
@@ -16,21 +16,21 @@ function extractSessionId(output: string): string | null {
}
export function createTaskResumeInfoHook() {
const toolExecuteAfter = async (
input: { tool: string; sessionID: string; callID: string },
output: { title: string; output: string; metadata: unknown }
) => {
if (!TARGET_TOOLS.includes(input.tool)) return
if (output.output.startsWith("Error:") || output.output.startsWith("Failed")) return
if (output.output.includes("\nto resume:")) return
const toolExecuteAfter = async (
input: { tool: string; sessionID: string; callID: string },
output: { title: string; output: string; metadata: unknown }
) => {
if (!TARGET_TOOLS.includes(input.tool)) return
if (output.output.startsWith("Error:") || output.output.startsWith("Failed")) return
if (output.output.includes("\nto continue:")) return
const sessionId = extractSessionId(output.output)
if (!sessionId) return
const sessionId = extractSessionId(output.output)
if (!sessionId) return
output.output = output.output.trimEnd() + `\n\nto resume: delegate_task(resume="${sessionId}", prompt="...")`
}
output.output = output.output.trimEnd() + `\n\nto continue: delegate_task(session_id="${sessionId}", prompt="...")`
}
return {
"tool.execute.after": toolExecuteAfter,
}
return {
"tool.execute.after": toolExecuteAfter,
}
}