From e3a08c8e8a7d15aa78424fbd282e4d07aaf283dd Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 12 Apr 2026 10:56:26 +0100 Subject: [PATCH] test(agents): share subagent spawn workspace fixture --- src/agents/subagent-spawn.workspace.test.ts | 55 +++++++++------------ 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/src/agents/subagent-spawn.workspace.test.ts b/src/agents/subagent-spawn.workspace.test.ts index d556be8a415..a3dbc1fc1e2 100644 --- a/src/agents/subagent-spawn.workspace.test.ts +++ b/src/agents/subagent-spawn.workspace.test.ts @@ -148,51 +148,40 @@ describe("spawnSubagentDirect workspace inheritance", () => { }); }); - it("passes lightweight bootstrap context flags for lightContext subagent spawns", async () => { - await spawnSubagentDirect( - { - task: "inspect workspace", - lightContext: true, - }, - { - agentSessionKey: "agent:main:main", - agentChannel: "telegram", - agentAccountId: "123", - agentTo: "456", - workspaceDir: "/tmp/requester-workspace", - }, - ); + async function spawnAndReadAgentParams(task: { task: string; lightContext?: boolean }) { + await spawnSubagentDirect(task, { + agentSessionKey: "agent:main:main", + agentChannel: "telegram", + agentAccountId: "123", + agentTo: "456", + workspaceDir: "/tmp/requester-workspace", + }); const agentCall = hoisted.callGatewayMock.mock.calls.find( ([request]) => (request as { method?: string }).method === "agent", )?.[0] as { params?: Record } | undefined; + return agentCall?.params; + } - expect(agentCall?.params).toMatchObject({ + it("passes lightweight bootstrap context flags for lightContext subagent spawns", async () => { + const agentParams = await spawnAndReadAgentParams({ + task: "inspect workspace", + lightContext: true, + }); + + expect(agentParams).toMatchObject({ bootstrapContextMode: "lightweight", bootstrapContextRunKind: "default", }); }); it("omits bootstrap context flags for default subagent spawns", async () => { - await spawnSubagentDirect( - { - task: "inspect workspace", - }, - { - agentSessionKey: "agent:main:main", - agentChannel: "telegram", - agentAccountId: "123", - agentTo: "456", - workspaceDir: "/tmp/requester-workspace", - }, - ); + const agentParams = await spawnAndReadAgentParams({ + task: "inspect workspace", + }); - const agentCall = hoisted.callGatewayMock.mock.calls.find( - ([request]) => (request as { method?: string }).method === "agent", - )?.[0] as { params?: Record } | undefined; - - expect(agentCall?.params).not.toHaveProperty("bootstrapContextMode"); - expect(agentCall?.params).not.toHaveProperty("bootstrapContextRunKind"); + expect(agentParams).not.toHaveProperty("bootstrapContextMode"); + expect(agentParams).not.toHaveProperty("bootstrapContextRunKind"); }); it("deletes the provisional child session when a non-thread subagent start fails", async () => {