test(agents): share subagent spawn workspace fixture

This commit is contained in:
Vincent Koc
2026-04-12 10:56:26 +01:00
parent d8b6ec4abf
commit e3a08c8e8a

View File

@@ -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<string, unknown> } | 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<string, unknown> } | 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 () => {