feat: add parentAgentId to MCP create_agent tool

Add parentAgentId optional parameter to the create_agent MCP tool input
schema so agents can create child agents with explicit parent references.
Also update registerSession() to copy parentAgentId from config to the
managed agent object.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Mohamed Boudra
2025-12-21 17:18:19 +00:00
co-authored by Claude Opus 4.5
parent a574429a7b
commit dd697defbb
3 changed files with 11 additions and 1 deletions
@@ -727,6 +727,7 @@ export class AgentManager {
historyPrimed: false,
lastUserMessageAt: null,
attention: { requiresAttention: false },
parentAgentId: config.parentAgentId,
} as ActiveManagedAgent;
this.agents.set(agentId, managed);
@@ -220,6 +220,12 @@ export async function createAgentMcpServer(
.describe(
"Run agent in background. If false (default), waits for completion or permission request. If true, returns immediately."
),
parentAgentId: z
.string()
.optional()
.describe(
"Optional parent agent ID. When set, this agent is a child of the specified parent agent."
),
},
outputSchema: {
agentId: z.string(),
@@ -246,6 +252,7 @@ export async function createAgentMcpServer(
worktreeName,
background = false,
title,
parentAgentId,
}) => {
let resolvedCwd = expandPath(cwd);
@@ -265,6 +272,7 @@ export async function createAgentMcpServer(
cwd: resolvedCwd,
modeId: initialMode,
title: normalizedTitle ?? undefined,
parentAgentId,
});
if (initialPrompt) {