feat: Tag Task-spawned agents with role:subagent (#343)

This commit is contained in:
paulbettner
2025-12-22 13:00:48 -06:00
committed by GitHub
parent 31db2be5d7
commit cf558b868d
2 changed files with 11 additions and 2 deletions

View File

@@ -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,

View File

@@ -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