From 46189eef8a8357f348cdbf128c1719f32b75f066 Mon Sep 17 00:00:00 2001 From: justsisyphus Date: Tue, 20 Jan 2026 18:55:08 +0900 Subject: [PATCH] test(delegate-task): add tests for DEFAULT_CATEGORIES variant handling Adds test coverage for variant propagation from DEFAULT_CATEGORIES to background tasks when no user categories are defined. --- src/tools/delegate-task/tools.test.ts | 118 ++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/src/tools/delegate-task/tools.test.ts b/src/tools/delegate-task/tools.test.ts index 36f81834..5ef77ebf 100644 --- a/src/tools/delegate-task/tools.test.ts +++ b/src/tools/delegate-task/tools.test.ts @@ -345,6 +345,124 @@ describe("sisyphus-task", () => { variant: "xhigh", }) }) + + test("DEFAULT_CATEGORIES variant passes to background WITHOUT userCategories", async () => { + // #given - NO userCategories, testing DEFAULT_CATEGORIES only + const { createDelegateTask } = require("./tools") + let launchInput: any + + const mockManager = { + launch: async (input: any) => { + launchInput = input + return { + id: "task-default-variant", + sessionID: "session-default-variant", + description: "Default variant task", + agent: "Sisyphus-Junior", + status: "running", + } + }, + } + + const mockClient = { + app: { agents: async () => ({ data: [] }) }, + config: { get: async () => ({ data: { model: SYSTEM_DEFAULT_MODEL } }) }, + session: { + create: async () => ({ data: { id: "test-session" } }), + prompt: async () => ({ data: {} }), + messages: async () => ({ data: [] }), + }, + } + + // NO userCategories - must use DEFAULT_CATEGORIES + const tool = createDelegateTask({ + manager: mockManager, + client: mockClient, + }) + + const toolContext = { + sessionID: "parent-session", + messageID: "parent-message", + agent: "Sisyphus", + abort: new AbortController().signal, + } + + // #when - unspecified-high has variant: "max" in DEFAULT_CATEGORIES + await tool.execute( + { + description: "Test unspecified-high default variant", + prompt: "Do something", + category: "unspecified-high", + run_in_background: true, + skills: [], + }, + toolContext + ) + + // #then - variant MUST be "max" from DEFAULT_CATEGORIES + expect(launchInput.model).toEqual({ + providerID: "anthropic", + modelID: "claude-opus-4-5", + variant: "max", + }) + }) + + test("DEFAULT_CATEGORIES variant passes to sync session.prompt WITHOUT userCategories", async () => { + // #given - NO userCategories, testing DEFAULT_CATEGORIES for sync mode + const { createDelegateTask } = require("./tools") + let promptBody: any + + const mockManager = { launch: async () => ({}) } + + const mockClient = { + app: { agents: async () => ({ data: [] }) }, + config: { get: async () => ({ data: { model: SYSTEM_DEFAULT_MODEL } }) }, + session: { + get: async () => ({ data: { directory: "/project" } }), + create: async () => ({ data: { id: "ses_sync_default_variant" } }), + prompt: async (input: any) => { + promptBody = input.body + return { data: {} } + }, + messages: async () => ({ + data: [{ info: { role: "assistant" }, parts: [{ type: "text", text: "done" }] }] + }), + status: async () => ({ data: { "ses_sync_default_variant": { type: "idle" } } }), + }, + } + + // NO userCategories - must use DEFAULT_CATEGORIES + const tool = createDelegateTask({ + manager: mockManager, + client: mockClient, + }) + + const toolContext = { + sessionID: "parent-session", + messageID: "parent-message", + agent: "Sisyphus", + abort: new AbortController().signal, + } + + // #when - unspecified-high has variant: "max" in DEFAULT_CATEGORIES + await tool.execute( + { + description: "Test unspecified-high sync variant", + prompt: "Do something", + category: "unspecified-high", + run_in_background: false, + skills: [], + }, + toolContext + ) + + // #then - variant MUST be "max" from DEFAULT_CATEGORIES + expect(promptBody.model).toEqual({ + providerID: "anthropic", + modelID: "claude-opus-4-5", + variant: "max", + }) + }, { timeout: 20000 }) }) describe("skills parameter", () => {