fix(subagent-session-spawning): resolved subagent parent id propagation
- Forwarded `parentAgentId` through task and eval launch paths when spawning subagents. - Mapped `parentAgentId` to `parentId` in `createAgentSession`. - Passed each caller's session `getAgentId` (or `MAIN_AGENT_ID`) as the parent for spawned agents.
This commit is contained in:
@@ -351,6 +351,12 @@ export interface ExecutorOptions {
|
||||
parentTelemetry?: AgentTelemetryConfig;
|
||||
/** Skills to autoload via sendCustomMessage before the first prompt */
|
||||
autoloadSkills?: Skill[];
|
||||
/**
|
||||
* Registry id of the spawning agent, recorded as this subagent's parent.
|
||||
* Forwarded verbatim to the SDK; the executor never derives it (the spawner
|
||||
* passes its own `getAgentId()`).
|
||||
*/
|
||||
parentAgentId?: string;
|
||||
}
|
||||
|
||||
function parseStringifiedJson(value: unknown): unknown {
|
||||
@@ -2021,6 +2027,7 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
|
||||
parentHindsightSessionState: options.parentHindsightSessionState,
|
||||
parentMnemopiSessionState: options.parentMnemopiSessionState,
|
||||
parentTaskPrefix: id,
|
||||
parentAgentId: options.parentAgentId,
|
||||
agentId: id,
|
||||
agentDisplayName: subagentDisplayName,
|
||||
enableLsp: lspEnabled,
|
||||
|
||||
@@ -46,7 +46,7 @@ import "../tools/review";
|
||||
import type { AsyncJobManager } from "../async";
|
||||
import type { LocalProtocolOptions } from "../internal-urls";
|
||||
import { loadOverallPlanReference } from "../plan-mode/plan-handoff";
|
||||
import { AgentRegistry } from "../registry/agent-registry";
|
||||
import { AgentRegistry, MAIN_AGENT_ID } from "../registry/agent-registry";
|
||||
import { generateCommitMessage } from "../utils/commit-message-generator";
|
||||
import * as git from "../utils/git";
|
||||
import { type DiscoveryResult, discoverAgents, getAgent } from "./discovery";
|
||||
@@ -1300,6 +1300,7 @@ export class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskToolDetai
|
||||
parentMnemopiSessionState: this.session.getMnemopiSessionState?.(),
|
||||
parentTelemetry: this.session.getTelemetry?.(),
|
||||
parentEvalSessionId,
|
||||
parentAgentId: this.session.getAgentId?.() ?? MAIN_AGENT_ID,
|
||||
};
|
||||
|
||||
const runTask = async (): Promise<SingleResult> => {
|
||||
|
||||
Reference in New Issue
Block a user