Skip to content

Commit 1f243e4

Browse files
committed
Reuse the parent tool call id as the spawn session id
task() correlated Agents-strip progress with the parent tool call by using that call id as the session id. spawn_agent minted a fresh id, so a task() wrapper would break that correlation.
1 parent 5fc0e36 commit 1f243e4

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/subagent/agent-fleet.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,23 @@ describe("interrupt_agent unblocks wait_agents", () => {
574574
});
575575

576576
describe("spawn_agent parity with task", () => {
577+
test("uses the parent tool call id as the session id", async () => {
578+
const deps = makeDeps(async () => ({ report: "done" }));
579+
const spawn = createSpawnAgentTool(deps);
580+
if (spawn.kind !== "full") throw new Error("expected full tool");
581+
const result = await spawn.handler(
582+
{
583+
id: "call-fixed-id",
584+
name: "spawn_agent",
585+
arguments: { description: "job", prompt: "do it", intent: "explore" },
586+
},
587+
new AbortController().signal,
588+
);
589+
const content = typeof result.content === "string" ? result.content : "";
590+
expect(JSON.parse(content).agent_id).toBe("call-fixed-id");
591+
expect(deps.sessions.get("call-fixed-id")).toBeDefined();
592+
});
593+
577594
test("refuses skywalker as a spawned worker", async () => {
578595
const deps = makeDeps(async () => ({ report: "no" }));
579596
const spawn = createSpawnAgentTool(deps);

src/subagent/agent-fleet.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ export function createSpawnAgentTool(deps: AgentFleetDeps): AgentTool {
500500
});
501501

502502
const session = deps.sessions.start({
503+
id: call.id,
503504
description,
504505
agentId: resolved.directorId,
505506
brief,

0 commit comments

Comments
 (0)