Skip to content

Commit 88cae38

Browse files
committed
fix: ignore ACP-only streamTo for subagent spawns
1 parent d4ab731 commit 88cae38

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

docs/tools/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ Core parameters:
476476
- `sessions_list`: `kinds?`, `limit?`, `activeMinutes?`, `messageLimit?` (0 = none)
477477
- `sessions_history`: `sessionKey` (or `sessionId`), `limit?`, `includeTools?`
478478
- `sessions_send`: `sessionKey` (or `sessionId`), `message`, `timeoutSeconds?` (0 = fire-and-forget)
479-
- `sessions_spawn`: `task`, `label?`, `runtime?`, `agentId?`, `model?`, `thinking?`, `cwd?`, `runTimeoutSeconds?`, `thread?`, `mode?`, `cleanup?`, `sandbox?`, `streamTo?`, `attachments?`, `attachAs?`
479+
- `sessions_spawn`: `task`, `label?`, `runtime?`, `agentId?`, `model?`, `thinking?`, `cwd?`, `runTimeoutSeconds?`, `thread?`, `mode?`, `cleanup?`, `sandbox?`, `streamTo?` (ACP only), `attachments?`, `attachAs?`
480480
- `session_status`: `sessionKey?` (default current; accepts `sessionId`), `model?` (`default` clears override)
481481

482482
Notes:
@@ -488,6 +488,7 @@ Notes:
488488
- Delivery/announce happens after completion and is best-effort; `status: "ok"` confirms the agent run finished, not that the announce was delivered.
489489
- `sessions_spawn` supports `runtime: "subagent" | "acp"` (`subagent` default). For ACP runtime behavior, see [ACP Agents](/tools/acp-agents).
490490
- For ACP runtime, `streamTo: "parent"` routes initial-run progress summaries back to the requester session as system events instead of direct child delivery.
491+
- For subagent runtime, `streamTo` is ignored for compatibility and has no effect.
491492
- `sessions_spawn` starts a sub-agent run and posts an announce reply back to the requester chat.
492493
- Supports one-shot mode (`mode: "run"`) and persistent thread-bound mode (`mode: "session"` with `thread: true`).
493494
- If `thread: true` and `mode` is omitted, mode defaults to `session`.

src/agents/tools/sessions-spawn-tool.test.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ describe("sessions_spawn tool", () => {
187187
expect(hoisted.spawnSubagentDirectMock).not.toHaveBeenCalled();
188188
});
189189

190-
it('rejects streamTo when runtime is not "acp"', async () => {
190+
it('ignores streamTo when runtime is "subagent"', async () => {
191191
const tool = createSessionsSpawnTool({
192192
agentSessionKey: "agent:main:main",
193193
});
@@ -199,12 +199,17 @@ describe("sessions_spawn tool", () => {
199199
});
200200

201201
expect(result.details).toMatchObject({
202-
status: "error",
202+
status: "accepted",
203+
childSessionKey: "agent:main:subagent:1",
204+
runId: "run-subagent",
203205
});
204-
const details = result.details as { error?: string };
205-
expect(details.error).toContain("streamTo is only supported for runtime=acp");
206+
expect(hoisted.spawnSubagentDirectMock).toHaveBeenCalledWith(
207+
expect.objectContaining({
208+
task: "analyze file",
209+
}),
210+
expect.any(Object),
211+
);
206212
expect(hoisted.spawnAcpDirectMock).not.toHaveBeenCalled();
207-
expect(hoisted.spawnSubagentDirectMock).not.toHaveBeenCalled();
208213
});
209214

210215
it("keeps attachment content schema unconstrained for llama.cpp grammar safety", () => {

src/agents/tools/sessions-spawn-tool.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ export function createSessionsSpawnTool(
9898
const cleanup =
9999
params.cleanup === "keep" || params.cleanup === "delete" ? params.cleanup : "keep";
100100
const sandbox = params.sandbox === "require" ? "require" : "inherit";
101-
const streamTo = params.streamTo === "parent" ? "parent" : undefined;
101+
const streamToRequested = params.streamTo === "parent" ? "parent" : undefined;
102+
const streamTo = runtime === "acp" ? streamToRequested : undefined;
102103
// Back-compat: older callers used timeoutSeconds for this tool.
103104
const timeoutSecondsCandidate =
104105
typeof params.runTimeoutSeconds === "number"
@@ -120,13 +121,6 @@ export function createSessionsSpawnTool(
120121
}>)
121122
: undefined;
122123

123-
if (streamTo && runtime !== "acp") {
124-
return jsonResult({
125-
status: "error",
126-
error: `streamTo is only supported for runtime=acp; got runtime=${runtime}`,
127-
});
128-
}
129-
130124
if (runtime === "acp") {
131125
if (Array.isArray(attachments) && attachments.length > 0) {
132126
return jsonResult({

0 commit comments

Comments
 (0)