Skip to content

Commit f40af00

Browse files
fix(sdk): cap createStartSessionAction tags at 5 to match schema
SessionTriggerConfig.tags allows at most 5 entries; align createChatStartSessionAction with chat.headStart and the Zod schema. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent df96c66 commit f40af00

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

packages/trigger-sdk/src/v3/ai.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9710,8 +9710,8 @@ function createChatStartSessionAction<TChat extends AnyTask = AnyTask>(
97109710
// run-list filter by chat works without the customer having to wire it
97119711
// up. Mirrors the browser-mediated `TriggerChatTransport.doStart` path.
97129712
const userTags = params.triggerConfig?.tags ?? options?.triggerConfig?.tags ?? [];
9713-
// Platform cap is 10 tags per run; the auto chat tag takes one slot.
9714-
const tags = [`chat:${params.chatId}`, ...userTags].slice(0, 10);
9713+
// SessionTriggerConfig.tags allows at most 5; the auto chat tag takes one slot.
9714+
const tags = [`chat:${params.chatId}`, ...userTags].slice(0, 5);
97159715

97169716
const clientDataMetadata =
97179717
params.clientData !== undefined ? { metadata: params.clientData } : {};

packages/trigger-sdk/src/v3/createStartSessionAction.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,25 @@ describe("chat.createStartSessionAction — runtime", () => {
9696
expect(lastStartBody?.triggerConfig.basePayload).not.toHaveProperty("metadata");
9797
});
9898

99+
it("prepends chat:{chatId} to triggerConfig.tags and caps at 5", async () => {
100+
installStartFixture();
101+
102+
const start = chat.createStartSessionAction("fake-chat", {
103+
triggerConfig: {
104+
tags: ["org:acme", "a", "b", "c", "d", "e"],
105+
},
106+
});
107+
await start({ chatId: "chat-tags" });
108+
109+
expect(lastStartBody?.triggerConfig.tags).toEqual([
110+
"chat:chat-tags",
111+
"org:acme",
112+
"a",
113+
"b",
114+
"c",
115+
]);
116+
});
117+
99118
it("keeps session-level metadata distinct from per-turn clientData", async () => {
100119
installStartFixture();
101120

0 commit comments

Comments
 (0)