Skip to content

Commit 85c7716

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 387962f commit 85c7716

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
@@ -924,6 +924,23 @@ describe("list_agents", () => {
924924
});
925925

926926
describe("spawn_agent parity with task", () => {
927+
test("uses the parent tool call id as the session id", async () => {
928+
const deps = makeDeps(async () => ({ report: "done" }));
929+
const spawn = createSpawnAgentTool(deps);
930+
if (spawn.kind !== "full") throw new Error("expected full tool");
931+
const result = await spawn.handler(
932+
{
933+
id: "call-fixed-id",
934+
name: "spawn_agent",
935+
arguments: { description: "job", prompt: "do it", intent: "explore" },
936+
},
937+
new AbortController().signal,
938+
);
939+
const content = typeof result.content === "string" ? result.content : "";
940+
expect(JSON.parse(content).agent_id).toBe("call-fixed-id");
941+
expect(deps.sessions.get("call-fixed-id")).toBeDefined();
942+
});
943+
927944
test("refuses skywalker as a spawned worker", async () => {
928945
const deps = makeDeps(async () => ({ report: "no" }));
929946
const spawn = createSpawnAgentTool(deps);

src/subagent/agent-fleet.ts

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

522522
const session = deps.sessions.start({
523+
id: call.id,
523524
description,
524525
agentId: resolved.directorId,
525526
brief,

0 commit comments

Comments
 (0)