From cf558b868d4e410af11bdbca6ae74cf96dd64500 Mon Sep 17 00:00:00 2001 From: paulbettner Date: Mon, 22 Dec 2025 13:00:48 -0600 Subject: [PATCH] feat: Tag Task-spawned agents with role:subagent (#343) --- src/agent/create.ts | 7 ++++++- src/agent/subagents/manager.ts | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/agent/create.ts b/src/agent/create.ts index bce49a9..ae5bed3 100644 --- a/src/agent/create.ts +++ b/src/agent/create.ts @@ -206,6 +206,11 @@ export async function createAgent( const systemPromptContent = await resolveSystemPrompt(systemPromptId); // Create agent with all block IDs (existing + newly created) + const tags = ["origin:letta-code"]; + if (process.env.LETTA_CODE_AGENT_ROLE === "subagent") { + tags.push("role:subagent"); + } + const agent = await client.agents.create({ agent_type: "letta_v1_agent" as AgentType, system: systemPromptContent, @@ -216,7 +221,7 @@ export async function createAgent( context_window_limit: contextWindow, tools: toolNames, block_ids: blockIds, - tags: ["origin:letta-code"], + tags, // should be default off, but just in case include_base_tools: false, include_base_tool_rules: false, diff --git a/src/agent/subagents/manager.ts b/src/agent/subagents/manager.ts index 1938c4f..707623b 100644 --- a/src/agent/subagents/manager.ts +++ b/src/agent/subagents/manager.ts @@ -387,7 +387,11 @@ async function executeSubagent( const lettaCmd = process.env.LETTA_CODE_BIN || "letta"; const proc = spawn(lettaCmd, cliArgs, { cwd: process.cwd(), - env: process.env, + env: { + ...process.env, + // Tag Task-spawned agents for easy filtering. + LETTA_CODE_AGENT_ROLE: "subagent", + }, }); // Set up abort handler to kill the child process