refactor(task): align continuation ids with task_id
This commit is contained in:
@@ -161,6 +161,23 @@ describe("createToolExecuteBeforeHandler", () => {
|
||||
expect(output.args.subagent_type).toBe("explore")
|
||||
})
|
||||
|
||||
test("normalizes task_id into the canonical resume argument", async () => {
|
||||
//#given
|
||||
const ctx = createCtxWithSessionMessages([
|
||||
{ info: { role: "assistant", agent: "oracle" } },
|
||||
])
|
||||
const handler = createToolExecuteBeforeHandler({ ctx, hooks: emptyHooks })
|
||||
const input = { tool: "task", sessionID: "ses_123", callID: "call_1" }
|
||||
const output = { args: { task_id: "ses_resume_123", description: "Continue task", prompt: "fix it" } as Record<string, unknown> }
|
||||
|
||||
//#when
|
||||
await handler(input, output)
|
||||
|
||||
//#then
|
||||
expect(output.args.task_id).toBe("ses_resume_123")
|
||||
expect(output.args.subagent_type).toBe("oracle")
|
||||
})
|
||||
|
||||
test("falls back to 'continue' when session has no agent info", async () => {
|
||||
//#given
|
||||
const ctx = createCtxWithSessionMessages([
|
||||
|
||||
@@ -100,12 +100,21 @@ 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 sessionId = typeof argsObject.session_id === "string" ? argsObject.session_id : 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
|
||||
}
|
||||
|
||||
if (category) {
|
||||
argsObject.subagent_type = "sisyphus-junior"
|
||||
} else if (!subagentType && sessionId) {
|
||||
const resolvedAgent = await resolveSessionAgent(ctx.client, sessionId)
|
||||
} else if (!subagentType && taskId) {
|
||||
const resolvedAgent = await resolveSessionAgent(ctx.client, taskId)
|
||||
argsObject.subagent_type = resolvedAgent ?? "continue"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user