From f232d23e9a7b1ab4fdeaf198f2aabd8df8fb34ed Mon Sep 17 00:00:00 2001 From: "paseo-bot[bot]" <266920839+paseo-bot[bot]@users.noreply.github.com> Date: Tue, 29 Sep 2026 06:53:14 +0200 Subject: [PATCH] fix(client): let SDK callers choose what a send does to an active turn (#5605) PaseoAgentSendOptions was a hand-copied subset of the daemon client's SendMessageOptions and dropped activeTurnBehavior, so agents.ref(id).send(text, { activeTurnBehavior: "steer" }) and run() failed to typecheck even though the value is forwarded to the daemon. The public type is now the options type send() passes through, so the two cannot drift again. Closes #4555 Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com> Co-authored-by: Daye <2077152374@qq.com> --- packages/client/examples/agents-and-providers.ts | 15 ++++++++++++++- packages/client/src/daemon-client.ts | 1 + packages/client/src/index.test.ts | 8 +++++++- packages/client/src/index.ts | 8 ++------ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/packages/client/examples/agents-and-providers.ts b/packages/client/examples/agents-and-providers.ts index c27ca1871e..e1ebfe021c 100644 --- a/packages/client/examples/agents-and-providers.ts +++ b/packages/client/examples/agents-and-providers.ts @@ -58,10 +58,23 @@ export async function runFollowUp(url: string, agentId: string): Promise { + const client = createClient(url); + + try { + await client.connect(); + await client.agents.ref(agentId).send(prompt, { activeTurnBehavior: "steer" }); + } finally { + await client.close(); + } +} diff --git a/packages/client/src/daemon-client.ts b/packages/client/src/daemon-client.ts index 23664188b7..2fe706c8ae 100644 --- a/packages/client/src/daemon-client.ts +++ b/packages/client/src/daemon-client.ts @@ -425,6 +425,7 @@ export interface DaemonClientTrace { export interface SendMessageOptions { messageId?: string; + /** What happens when the agent is mid-turn. The daemon interrupts the turn when omitted. */ activeTurnBehavior?: ActiveTurnBehavior; images?: Array<{ data: string; mimeType: string }>; attachments?: SendAgentMessageRequest["attachments"]; diff --git a/packages/client/src/index.test.ts b/packages/client/src/index.test.ts index 9aed42febc..0f60e52673 100644 --- a/packages/client/src/index.test.ts +++ b/packages/client/src/index.test.ts @@ -744,13 +744,17 @@ test("agent handles delegate create, send, timeline refetch, archive, and local expect(updatedAgents).toEqual(["Updated"]); expect(agent.current()).toEqual(updatedAgent); - const sendPromise = agent.send("hello", { messageId: "message-sdk" }); + const sendPromise = agent.send("hello", { + messageId: "message-sdk", + activeTurnBehavior: "steer", + }); const sendRequest = parseSentSessionMessage(ws.sent.at(-1)); expect(sendRequest).toMatchObject({ type: "send_agent_message_request", agentId: "agent_sdk", text: "hello", messageId: "message-sdk", + activeTurnBehavior: "steer", }); ws.message( @@ -768,6 +772,7 @@ test("agent handles delegate create, send, timeline refetch, archive, and local const runPromise = agent.run("finish the task", { messageId: "run-message-sdk", + activeTurnBehavior: "interrupt", timeoutMs: 30_000, }); const runSendRequest = parseSentSessionMessage(ws.sent.at(-1)); @@ -776,6 +781,7 @@ test("agent handles delegate create, send, timeline refetch, archive, and local agentId: "agent_sdk", text: "finish the task", messageId: "run-message-sdk", + activeTurnBehavior: "interrupt", }); ws.message( sessionMessage({ diff --git a/packages/client/src/index.ts b/packages/client/src/index.ts index e113d48667..ae868c5974 100644 --- a/packages/client/src/index.ts +++ b/packages/client/src/index.ts @@ -24,7 +24,6 @@ import type { ProjectPlacementPayload, WorkspaceProjectDescriptorPayload, RefreshProvidersSnapshotResponseMessage, - SendAgentMessageRequest, SessionOutboundMessage, WorkspaceDescriptorPayload, WorkspaceCreateRequest, @@ -55,6 +54,7 @@ import type { FetchAgentTimelineDirection, FetchAgentTimelinePayload, FetchAgentTimelineProjection, + SendMessageOptions, WaitForFinishResult, } from "./daemon-client.js"; @@ -276,11 +276,7 @@ export interface PaseoAgentTimelineRefetchOptions { requestId?: string; } -export interface PaseoAgentSendOptions { - messageId?: string; - images?: Array<{ data: string; mimeType: string }>; - attachments?: SendAgentMessageRequest["attachments"]; -} +export type PaseoAgentSendOptions = SendMessageOptions; export interface PaseoAgentRunOptions extends PaseoAgentSendOptions { timeoutMs?: number;