From 00a61b6887b60e733121110495a7aa1b918028f2 Mon Sep 17 00:00:00 2001 From: Eric Allam Date: Wed, 29 Apr 2026 14:25:03 +0100 Subject: [PATCH] =?UTF-8?q?fix(cli):=20MCP=20agentChat=20=E2=80=94=20task-?= =?UTF-8?q?bound=20session=20creation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CreateSessionRequestBody now requires `taskIdentifier` and `triggerConfig` because Sessions are task-bound (the server reuses the config for every run scheduled by the session — initial + continuations). The MCP `agentChat` tool was still passing only `{ type, externalId }` from the pre-Sessions-as-run-manager API. Add `taskIdentifier: input.agentId` and a minimal `triggerConfig` with `basePayload: { chatId, ...clientData }` and the `chat:{chatId}` auto-tag. Unblocks typecheck on PR #3173 (and Windows CLI v3 e2e, which builds cli-v3 in pre-test). --- packages/cli-v3/src/mcp/tools/agentChat.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/cli-v3/src/mcp/tools/agentChat.ts b/packages/cli-v3/src/mcp/tools/agentChat.ts index 49695415a..f1049032d 100644 --- a/packages/cli-v3/src/mcp/tools/agentChat.ts +++ b/packages/cli-v3/src/mcp/tools/agentChat.ts @@ -115,9 +115,17 @@ export const startAgentChatTool = { // Create (or upsert) the backing Session. Idempotent via externalId — // two MCP clients targeting the same chatId converge to the same row. + // Sessions are now task-bound: taskIdentifier + triggerConfig are + // required, and the server reuses them for every run scheduled by + // this session (initial + continuations after run termination). const session = await apiClient.createSession({ type: "chat.agent", externalId: chatId, + taskIdentifier: input.agentId, + triggerConfig: { + basePayload: { chatId, ...(input.clientData ?? {}) }, + tags: [`chat:${chatId}`], + }, }); if (input.preload) {