Skip to content

Commit 606a86a

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 149c1b3 commit 606a86a

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
@@ -693,6 +693,23 @@ describe("list_agents", () => {
693693
});
694694

695695
describe("spawn_agent parity with task", () => {
696+
test("uses the parent tool call id as the session id", async () => {
697+
const deps = makeDeps(async () => ({ report: "done" }));
698+
const spawn = createSpawnAgentTool(deps);
699+
if (spawn.kind !== "full") throw new Error("expected full tool");
700+
const result = await spawn.handler(
701+
{
702+
id: "call-fixed-id",
703+
name: "spawn_agent",
704+
arguments: { description: "job", prompt: "do it", intent: "explore" },
705+
},
706+
new AbortController().signal,
707+
);
708+
const content = typeof result.content === "string" ? result.content : "";
709+
expect(JSON.parse(content).agent_id).toBe("call-fixed-id");
710+
expect(deps.sessions.get("call-fixed-id")).toBeDefined();
711+
});
712+
696713
test("refuses skywalker as a spawned worker", async () => {
697714
const deps = makeDeps(async () => ({ report: "no" }));
698715
const spawn = createSpawnAgentTool(deps);

src/subagent/agent-fleet.ts

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

516516
const session = deps.sessions.start({
517+
id: call.id,
517518
description,
518519
agentId: resolved.directorId,
519520
brief,

0 commit comments

Comments
 (0)