From c9fab347068284d8a88bce805f0ec79f3bdee3bf Mon Sep 17 00:00:00 2001 From: Charles Packer Date: Thu, 15 Jan 2026 22:39:53 -0800 Subject: [PATCH] fix: Task tool subagent spawn and isolated block labels (#561) Co-authored-by: Letta --- src/agent/subagents/builtin/recall.md | 2 +- src/agent/subagents/manager.ts | 2 +- src/cli/components/SubagentGroupDisplay.tsx | 2 +- src/headless.ts | 16 ++++++++-- src/tests/headless-input-format.test.ts | 34 +++++++++++++++++++++ 5 files changed, 50 insertions(+), 6 deletions(-) diff --git a/src/agent/subagents/builtin/recall.md b/src/agent/subagents/builtin/recall.md index 161359a..e0378e6 100644 --- a/src/agent/subagents/builtin/recall.md +++ b/src/agent/subagents/builtin/recall.md @@ -3,7 +3,7 @@ name: recall description: Search conversation history to recall past discussions, decisions, and context tools: Skill, Bash, Read, BashOutput model: haiku -memoryBlocks: human, persona +memoryBlocks: human, persona, skills, loaded_skills mode: stateless --- diff --git a/src/agent/subagents/manager.ts b/src/agent/subagents/manager.ts index 25d2bc4..34e1ca8 100644 --- a/src/agent/subagents/manager.ts +++ b/src/agent/subagents/manager.ts @@ -308,7 +308,7 @@ function buildSubagentArgs( userPrompt: string, ): string[] { const args: string[] = [ - "--new", + "--new-agent", "--system", type, "--model", diff --git a/src/cli/components/SubagentGroupDisplay.tsx b/src/cli/components/SubagentGroupDisplay.tsx index 2072386..598eeea 100644 --- a/src/cli/components/SubagentGroupDisplay.tsx +++ b/src/cli/components/SubagentGroupDisplay.tsx @@ -290,7 +290,7 @@ export const SubagentGroupDisplay = memo(() => { const hasErrors = agents.some((a) => a.status === "error"); return ( - + + initBlocks.includes(label as string), + ); + if (specifiedConversationId) { // User specified a conversation to resume try { @@ -496,7 +506,7 @@ export async function handleHeadlessCommand( // Conversation no longer exists, create new const conversation = await client.conversations.create({ agent_id: agent.id, - isolated_block_labels: [...ISOLATED_BLOCK_LABELS], + isolated_block_labels: isolatedBlockLabels, }); conversationId = conversation.id; } @@ -504,7 +514,7 @@ export async function handleHeadlessCommand( // No matching session, create new conversation const conversation = await client.conversations.create({ agent_id: agent.id, - isolated_block_labels: [...ISOLATED_BLOCK_LABELS], + isolated_block_labels: isolatedBlockLabels, }); conversationId = conversation.id; } @@ -513,7 +523,7 @@ export async function handleHeadlessCommand( // This ensures isolated message history per CLI invocation const conversation = await client.conversations.create({ agent_id: agent.id, - isolated_block_labels: [...ISOLATED_BLOCK_LABELS], + isolated_block_labels: isolatedBlockLabels, }); conversationId = conversation.id; } diff --git a/src/tests/headless-input-format.test.ts b/src/tests/headless-input-format.test.ts index 8a6eae7..1148bb2 100644 --- a/src/tests/headless-input-format.test.ts +++ b/src/tests/headless-input-format.test.ts @@ -453,4 +453,38 @@ describe("input-format stream-json", () => { }, { timeout: 200000 }, ); + + test( + "Task tool with explore subagent works", + async () => { + // Prescriptive prompt to ensure Task tool is used + const objects = (await runBidirectional( + [ + JSON.stringify({ + type: "user", + message: { + role: "user", + content: + "You MUST use the Task tool with subagent_type='explore' to find TypeScript files (*.ts) in the src directory. " + + "Return only the subagent's report, nothing else.", + }, + }), + ], + [], + 300000, // 5 min timeout - subagent spawn + execution can be slow + )) as WireMessage[]; + + // Should have a successful result + const result = objects.find( + (o): o is ResultMessage => o.type === "result", + ); + expect(result).toBeDefined(); + expect(result?.subtype).toBe("success"); + + // Should have auto_approval events (Task tool was auto-approved via --yolo) + const autoApprovals = objects.filter((o) => o.type === "auto_approval"); + expect(autoApprovals.length).toBeGreaterThan(0); + }, + { timeout: 320000 }, + ); });