refactor(task): drop session_id resume alias
This commit is contained in:
@@ -143,7 +143,7 @@ describe("createToolExecuteBeforeHandler", () => {
|
||||
expect(output.args.subagent_type).toBe("sisyphus-junior")
|
||||
})
|
||||
|
||||
test("resolves subagent_type from session first message when session_id provided without subagent_type", async () => {
|
||||
test("resolves subagent_type from session first message when task_id is provided without subagent_type", async () => {
|
||||
//#given
|
||||
const ctx = createCtxWithSessionMessages([
|
||||
{ info: { role: "user" } },
|
||||
@@ -152,7 +152,7 @@ describe("createToolExecuteBeforeHandler", () => {
|
||||
])
|
||||
const handler = createToolExecuteBeforeHandler({ ctx, hooks: emptyHooks })
|
||||
const input = { tool: "task", sessionID: "ses_123", callID: "call_1" }
|
||||
const output = { args: { session_id: "ses_abc123", description: "Continue task", prompt: "fix it" } as Record<string, unknown> }
|
||||
const output = { args: { task_id: "ses_abc123", description: "Continue task", prompt: "fix it" } as Record<string, unknown> }
|
||||
|
||||
//#when
|
||||
await handler(input, output)
|
||||
@@ -186,7 +186,7 @@ describe("createToolExecuteBeforeHandler", () => {
|
||||
])
|
||||
const handler = createToolExecuteBeforeHandler({ ctx, hooks: emptyHooks })
|
||||
const input = { tool: "task", sessionID: "ses_123", callID: "call_1" }
|
||||
const output = { args: { session_id: "ses_abc123", description: "Continue task", prompt: "fix it" } as Record<string, unknown> }
|
||||
const output = { args: { task_id: "ses_abc123", description: "Continue task", prompt: "fix it" } as Record<string, unknown> }
|
||||
|
||||
//#when
|
||||
await handler(input, output)
|
||||
@@ -195,12 +195,12 @@ describe("createToolExecuteBeforeHandler", () => {
|
||||
expect(output.args.subagent_type).toBe("continue")
|
||||
})
|
||||
|
||||
test("preserves subagent_type when session_id is provided with explicit subagent_type", async () => {
|
||||
test("preserves subagent_type when task_id is provided with explicit subagent_type", async () => {
|
||||
//#given
|
||||
const ctx = createCtxWithSessionMessages()
|
||||
const handler = createToolExecuteBeforeHandler({ ctx, hooks: emptyHooks })
|
||||
const input = { tool: "task", sessionID: "ses_123", callID: "call_1" }
|
||||
const output = { args: { session_id: "ses_abc123", subagent_type: "explore", description: "Continue explore" } as Record<string, unknown> }
|
||||
const output = { args: { task_id: "ses_abc123", subagent_type: "explore", description: "Continue explore" } as Record<string, unknown> }
|
||||
|
||||
//#when
|
||||
await handler(input, output)
|
||||
@@ -223,7 +223,7 @@ describe("createToolExecuteBeforeHandler", () => {
|
||||
expect(output.args.subagent_type).toBeUndefined()
|
||||
})
|
||||
|
||||
test("does not set subagent_type when neither category nor session_id is provided and subagent_type is present", async () => {
|
||||
test("does not set subagent_type when neither category nor task_id is provided and subagent_type is present", async () => {
|
||||
//#given
|
||||
const ctx = createCtxWithSessionMessages()
|
||||
const handler = createToolExecuteBeforeHandler({ ctx, hooks: emptyHooks })
|
||||
|
||||
@@ -100,16 +100,7 @@ export function createToolExecuteBeforeHandler(args: {
|
||||
const argsObject = output.args
|
||||
const category = typeof argsObject.category === "string" ? argsObject.category : undefined
|
||||
const subagentType = typeof argsObject.subagent_type === "string" ? argsObject.subagent_type : undefined
|
||||
const taskId =
|
||||
typeof argsObject.task_id === "string"
|
||||
? argsObject.task_id
|
||||
: typeof argsObject.session_id === "string"
|
||||
? argsObject.session_id
|
||||
: undefined
|
||||
|
||||
if (taskId && typeof argsObject.task_id !== "string") {
|
||||
argsObject.task_id = taskId
|
||||
}
|
||||
const taskId = typeof argsObject.task_id === "string" ? argsObject.task_id : undefined
|
||||
|
||||
if (category) {
|
||||
argsObject.subagent_type = "sisyphus-junior"
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
sync-task.ts → sync-session-creator.ts → sync-prompt-sender.ts → sync-session-poller.ts → sync-result-fetcher.ts
|
||||
```
|
||||
|
||||
Each file handles one step. `sync-continuation.ts` handles session continuation (resume with session_id).
|
||||
Each file handles one step. `sync-continuation.ts` handles session continuation (resume with task_id).
|
||||
|
||||
## BACKGROUND EXECUTION
|
||||
|
||||
@@ -40,7 +40,7 @@ Each file handles one step. `sync-continuation.ts` handles session continuation
|
||||
background-task.ts → BackgroundManager.launch() → (async polling) → background-continuation.ts
|
||||
```
|
||||
|
||||
`background-continuation.ts` handles `session_id` resume for existing background tasks.
|
||||
`background-continuation.ts` handles `task_id` resume for existing background tasks.
|
||||
|
||||
## CATEGORY RESOLUTION
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ describe("executeBackgroundContinuation - subagent metadata", () => {
|
||||
}
|
||||
|
||||
const args = {
|
||||
session_id: "ses_resumed_123",
|
||||
task_id: "ses_resumed_123",
|
||||
prompt: "continue working",
|
||||
description: "resume oracle",
|
||||
load_skills: [],
|
||||
@@ -76,7 +76,7 @@ describe("executeBackgroundContinuation - subagent metadata", () => {
|
||||
}
|
||||
|
||||
const args = {
|
||||
session_id: "ses_resumed_456",
|
||||
task_id: "ses_resumed_456",
|
||||
prompt: "continue",
|
||||
description: "resume task",
|
||||
load_skills: [],
|
||||
|
||||
@@ -122,7 +122,7 @@ describe("metadata model unification", () => {
|
||||
const ctx = makeMockCtx()
|
||||
const args: DelegateTaskArgs = {
|
||||
description: "continue", prompt: "keep going",
|
||||
load_skills: [], run_in_background: true, session_id: "ses_resumed",
|
||||
load_skills: [], run_in_background: true, task_id: "ses_resumed",
|
||||
}
|
||||
|
||||
await executeBackgroundContinuation(args, ctx, {
|
||||
@@ -144,7 +144,7 @@ describe("metadata model unification", () => {
|
||||
const ctx = makeMockCtx()
|
||||
const args: DelegateTaskArgs = {
|
||||
description: "continue", prompt: "keep going",
|
||||
load_skills: [], run_in_background: false, session_id: "ses_cont",
|
||||
load_skills: [], run_in_background: false, task_id: "ses_cont",
|
||||
}
|
||||
|
||||
const deps = {
|
||||
|
||||
@@ -86,7 +86,7 @@ describe("executeSyncContinuation - toast cleanup error paths", () => {
|
||||
}
|
||||
|
||||
const args = {
|
||||
session_id: "ses_test_12345678",
|
||||
task_id: "ses_test_12345678",
|
||||
prompt: "test prompt",
|
||||
description: "test task",
|
||||
load_skills: [],
|
||||
@@ -148,7 +148,7 @@ describe("executeSyncContinuation - toast cleanup error paths", () => {
|
||||
}
|
||||
|
||||
const args = {
|
||||
session_id: "ses_test_12345678",
|
||||
task_id: "ses_test_12345678",
|
||||
prompt: "test prompt",
|
||||
description: "test task",
|
||||
load_skills: [],
|
||||
@@ -214,7 +214,7 @@ describe("executeSyncContinuation - toast cleanup error paths", () => {
|
||||
}
|
||||
|
||||
const args = {
|
||||
session_id: "ses_test_12345678",
|
||||
task_id: "ses_test_12345678",
|
||||
prompt: "test prompt",
|
||||
description: "test task",
|
||||
load_skills: [],
|
||||
@@ -278,7 +278,7 @@ describe("executeSyncContinuation - toast cleanup error paths", () => {
|
||||
}
|
||||
|
||||
const args = {
|
||||
session_id: "ses_test_12345678",
|
||||
task_id: "ses_test_12345678",
|
||||
prompt: "test prompt",
|
||||
description: "test task",
|
||||
load_skills: [],
|
||||
@@ -335,7 +335,7 @@ describe("executeSyncContinuation - toast cleanup error paths", () => {
|
||||
}
|
||||
|
||||
const args = {
|
||||
session_id: "ses_test_12345678",
|
||||
task_id: "ses_test_12345678",
|
||||
prompt: "test prompt",
|
||||
description: "test task",
|
||||
load_skills: [],
|
||||
@@ -395,7 +395,7 @@ describe("executeSyncContinuation - toast cleanup error paths", () => {
|
||||
}
|
||||
|
||||
const args = {
|
||||
session_id: "ses_test_12345678",
|
||||
task_id: "ses_test_12345678",
|
||||
prompt: "continue working",
|
||||
description: "resume oracle task",
|
||||
load_skills: [],
|
||||
@@ -449,7 +449,7 @@ describe("executeSyncContinuation - toast cleanup error paths", () => {
|
||||
}
|
||||
|
||||
const args = {
|
||||
session_id: "ses_test_12345678",
|
||||
task_id: "ses_test_12345678",
|
||||
prompt: "continue working",
|
||||
description: "resume task",
|
||||
load_skills: [],
|
||||
@@ -514,7 +514,7 @@ describe("executeSyncContinuation - toast cleanup error paths", () => {
|
||||
}
|
||||
|
||||
const args = {
|
||||
session_id: "ses_test_12345678",
|
||||
task_id: "ses_test_12345678",
|
||||
prompt: "continue working",
|
||||
description: "resume explore task",
|
||||
load_skills: [],
|
||||
@@ -584,7 +584,7 @@ describe("executeSyncContinuation - toast cleanup error paths", () => {
|
||||
}
|
||||
|
||||
const args = {
|
||||
session_id: "ses_test_12345678",
|
||||
task_id: "ses_test_12345678",
|
||||
prompt: "continue researching",
|
||||
description: "resume librarian task",
|
||||
load_skills: [],
|
||||
@@ -654,7 +654,7 @@ describe("executeSyncContinuation - toast cleanup error paths", () => {
|
||||
}
|
||||
|
||||
const args = {
|
||||
session_id: "ses_test_12345678",
|
||||
task_id: "ses_test_12345678",
|
||||
prompt: "continue planning",
|
||||
description: "resume prometheus task",
|
||||
load_skills: [],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { DelegateTaskArgs } from "./types"
|
||||
|
||||
export function getTaskID(args: Pick<DelegateTaskArgs, "task_id" | "session_id">): string | undefined {
|
||||
return args.task_id ?? args.session_id
|
||||
export function getTaskID(args: Pick<DelegateTaskArgs, "task_id">): string | undefined {
|
||||
return args.task_id
|
||||
}
|
||||
|
||||
@@ -1359,7 +1359,7 @@ describe("sisyphus-task", () => {
|
||||
)).rejects.toThrow("Invalid arguments: 'run_in_background' parameter is REQUIRED")
|
||||
})
|
||||
|
||||
test("#given session_id without run_in_background #when executing #then throws required parameter error", async () => {
|
||||
test("#given task_id without run_in_background #when executing #then throws required parameter error", async () => {
|
||||
// given
|
||||
const { createDelegateTask } = require("./tools")
|
||||
const mockManager = { resume: async () => ({ id: "task-1", sessionID: "ses_1", status: "running" }) }
|
||||
@@ -1381,14 +1381,14 @@ describe("sisyphus-task", () => {
|
||||
{
|
||||
description: "Continue without run flag",
|
||||
prompt: "Continue",
|
||||
session_id: "ses_existing",
|
||||
task_id: "ses_existing",
|
||||
load_skills: [],
|
||||
},
|
||||
{ sessionID: "parent-session", messageID: "parent-message", agent: "sisyphus", abort: new AbortController().signal }
|
||||
)).rejects.toThrow("Invalid arguments: 'run_in_background' parameter is REQUIRED")
|
||||
})
|
||||
|
||||
test("#given no category no subagent_type no session_id and no run_in_background #when executing #then throws required parameter error", async () => {
|
||||
test("#given no category no subagent_type no task_id and no run_in_background #when executing #then throws required parameter error", async () => {
|
||||
// given
|
||||
const { createDelegateTask } = require("./tools")
|
||||
const mockManager = { launch: async () => ({}) }
|
||||
@@ -1719,8 +1719,8 @@ describe("sisyphus-task", () => {
|
||||
}, { timeout: 10000 })
|
||||
})
|
||||
|
||||
describe("session_id with background parameter", () => {
|
||||
test("session_id with background=false should wait for result and return content", async () => {
|
||||
describe("task_id with background parameter", () => {
|
||||
test("task_id with background=false should wait for result and return content", async () => {
|
||||
// Note: This test needs extended timeout because the implementation has MIN_STABILITY_TIME_MS = 5000
|
||||
// given
|
||||
const { createDelegateTask } = require("./tools")
|
||||
@@ -1808,7 +1808,7 @@ describe("sisyphus-task", () => {
|
||||
{
|
||||
description: "Continue test",
|
||||
prompt: "Continue the task",
|
||||
session_id: "ses_continue_test",
|
||||
task_id: "ses_continue_test",
|
||||
run_in_background: false,
|
||||
load_skills: ["git-master"],
|
||||
},
|
||||
@@ -1905,7 +1905,7 @@ describe("sisyphus-task", () => {
|
||||
{
|
||||
description: "Continue with variant",
|
||||
prompt: "Continue the task",
|
||||
session_id: "ses_var_test",
|
||||
task_id: "ses_var_test",
|
||||
run_in_background: false,
|
||||
load_skills: [],
|
||||
},
|
||||
@@ -1920,7 +1920,7 @@ describe("sisyphus-task", () => {
|
||||
expect(callArgs.body.model).toEqual({ providerID: "anthropic", modelID: "claude-opus-4-6" })
|
||||
}, { timeout: 10000 })
|
||||
|
||||
test("session_id with background=true should return immediately without waiting", async () => {
|
||||
test("task_id with background=true should return immediately without waiting", async () => {
|
||||
// given
|
||||
const { createDelegateTask } = require("./tools")
|
||||
|
||||
@@ -1964,7 +1964,7 @@ describe("sisyphus-task", () => {
|
||||
{
|
||||
description: "Continue bg test",
|
||||
prompt: "Continue in background",
|
||||
session_id: "ses_bg_continue",
|
||||
task_id: "ses_bg_continue",
|
||||
run_in_background: true,
|
||||
load_skills: ["git-master"],
|
||||
},
|
||||
|
||||
@@ -85,7 +85,6 @@ export function createDelegateTask(options: DelegateTaskToolOptions): ToolDefini
|
||||
- subagent_type: Use specific agent directly (explore, librarian, oracle, metis, momus)
|
||||
- run_in_background: REQUIRED. true=async (returns task_id), false=sync (waits). Use background=true ONLY for parallel exploration with 5+ independent queries.
|
||||
- task_id: Existing task to continue (from previous task output). Continues the same subagent session with FULL CONTEXT PRESERVED.
|
||||
- session_id: Deprecated alias for task_id. Accepted for backward compatibility.
|
||||
- command: The command that triggered this task (optional, for slash command tracking).
|
||||
|
||||
**WHEN TO USE task_id:**
|
||||
@@ -105,14 +104,10 @@ export function createDelegateTask(options: DelegateTaskToolOptions): ToolDefini
|
||||
category: tool.schema.string().optional().describe(`REQUIRED if subagent_type not provided. Do NOT provide both category and subagent_type.`),
|
||||
subagent_type: tool.schema.string().optional().describe("REQUIRED if category not provided. Do NOT provide both category and subagent_type."),
|
||||
task_id: tool.schema.string().optional().describe("Existing task to continue. Canonical resume identifier."),
|
||||
session_id: tool.schema.string().optional().describe("Deprecated alias for task_id. Existing task to continue."),
|
||||
command: tool.schema.string().optional().describe("The command that triggered this task"),
|
||||
},
|
||||
async execute(args: DelegateTaskArgs, toolContext) {
|
||||
const ctx = toolContext as ToolContextWithMetadata
|
||||
if (!args.task_id && args.session_id) {
|
||||
args.task_id = args.session_id
|
||||
}
|
||||
|
||||
if (args.category) {
|
||||
if (args.subagent_type && args.subagent_type !== SISYPHUS_JUNIOR_AGENT) {
|
||||
@@ -163,7 +158,7 @@ export function createDelegateTask(options: DelegateTaskToolOptions): ToolDefini
|
||||
|
||||
const parentContext = await resolveParentContext(ctx, options.client)
|
||||
|
||||
if (args.task_id || args.session_id) {
|
||||
if (args.task_id) {
|
||||
if (runInBackground) {
|
||||
return executeBackgroundContinuation(args, ctx, options, parentContext)
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ export interface DelegateTaskArgs {
|
||||
subagent_type?: string
|
||||
run_in_background: boolean
|
||||
task_id?: string
|
||||
/** @deprecated Use task_id instead. */
|
||||
session_id?: string
|
||||
command?: string
|
||||
load_skills: string[]
|
||||
execute?: {
|
||||
|
||||
Reference in New Issue
Block a user