Skip to content

Commit 40f328b

Browse files
committed
fix(cli): MCP agentChat — task-bound session creation
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).
1 parent 08d907c commit 40f328b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

packages/cli-v3/src/mcp/tools/agentChat.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,17 @@ export const startAgentChatTool = {
115115

116116
// Create (or upsert) the backing Session. Idempotent via externalId —
117117
// two MCP clients targeting the same chatId converge to the same row.
118+
// Sessions are now task-bound: taskIdentifier + triggerConfig are
119+
// required, and the server reuses them for every run scheduled by
120+
// this session (initial + continuations after run termination).
118121
const session = await apiClient.createSession({
119122
type: "chat.agent",
120123
externalId: chatId,
124+
taskIdentifier: input.agentId,
125+
triggerConfig: {
126+
basePayload: { chatId, ...(input.clientData ?? {}) },
127+
tags: [`chat:${chatId}`],
128+
},
121129
});
122130

123131
if (input.preload) {

0 commit comments

Comments
 (0)