@trigger.dev/sdk 4.8.4 → 4.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/v3/ai.d.ts +29 -5
- package/dist/commonjs/v3/ai.js +160 -114
- package/dist/commonjs/v3/ai.js.map +1 -1
- package/dist/commonjs/v3/auth.d.ts +4 -4
- package/dist/commonjs/v3/auth.js +21 -75
- package/dist/commonjs/v3/auth.js.map +1 -1
- package/dist/commonjs/v3/chat-client.d.ts +1 -1
- package/dist/commonjs/v3/chat.d.ts +1 -1
- package/dist/commonjs/v3/prompt.js +6 -8
- package/dist/commonjs/v3/prompt.js.map +1 -1
- package/dist/commonjs/v3/runs.d.ts +5 -1
- package/dist/commonjs/v3/runs.js.map +1 -1
- package/dist/commonjs/v3/sessions.js +10 -7
- package/dist/commonjs/v3/sessions.js.map +1 -1
- package/dist/commonjs/v3/shared.d.ts +2 -2
- package/dist/commonjs/v3/shared.js +16 -15
- package/dist/commonjs/v3/shared.js.map +1 -1
- package/dist/commonjs/v3/steeringContext.d.ts +35 -10
- package/dist/commonjs/v3/steeringContext.js +35 -12
- package/dist/commonjs/v3/steeringContext.js.map +1 -1
- package/dist/commonjs/v3/streams.js +10 -8
- package/dist/commonjs/v3/streams.js.map +1 -1
- package/dist/commonjs/v3/tasks.d.ts +2 -2
- package/dist/commonjs/v3/tasks.js.map +1 -1
- package/dist/commonjs/v3/test/mock-chat-agent.js +24 -13
- package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/commonjs/v3/webhooks.d.ts +8 -2
- package/dist/commonjs/v3/webhooks.js +20 -11
- package/dist/commonjs/v3/webhooks.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/ai.d.ts +29 -5
- package/dist/esm/v3/ai.js +162 -117
- package/dist/esm/v3/ai.js.map +1 -1
- package/dist/esm/v3/auth.d.ts +4 -4
- package/dist/esm/v3/auth.js +22 -76
- package/dist/esm/v3/auth.js.map +1 -1
- package/dist/esm/v3/chat-client.d.ts +1 -1
- package/dist/esm/v3/chat.d.ts +1 -1
- package/dist/esm/v3/prompt.js +6 -8
- package/dist/esm/v3/prompt.js.map +1 -1
- package/dist/esm/v3/runs.d.ts +5 -1
- package/dist/esm/v3/runs.js.map +1 -1
- package/dist/esm/v3/sessions.js +10 -7
- package/dist/esm/v3/sessions.js.map +1 -1
- package/dist/esm/v3/shared.d.ts +2 -2
- package/dist/esm/v3/shared.js +16 -15
- package/dist/esm/v3/shared.js.map +1 -1
- package/dist/esm/v3/steeringContext.d.ts +35 -10
- package/dist/esm/v3/steeringContext.js +34 -12
- package/dist/esm/v3/steeringContext.js.map +1 -1
- package/dist/esm/v3/streams.js +10 -8
- package/dist/esm/v3/streams.js.map +1 -1
- package/dist/esm/v3/tasks.d.ts +2 -2
- package/dist/esm/v3/tasks.js.map +1 -1
- package/dist/esm/v3/test/mock-chat-agent.js +25 -14
- package/dist/esm/v3/test/mock-chat-agent.js.map +1 -1
- package/dist/esm/v3/webhooks.d.ts +8 -2
- package/dist/esm/v3/webhooks.js +20 -11
- package/dist/esm/v3/webhooks.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/ai/observability.mdx +25 -19
- package/docs/ai/prompts.mdx +25 -19
- package/docs/ai-chat/actions.mdx +1 -1
- package/docs/ai-chat/anatomy.mdx +1 -1
- package/docs/ai-chat/backend.mdx +24 -24
- package/docs/ai-chat/background-injection.mdx +5 -5
- package/docs/ai-chat/chat-local.mdx +2 -2
- package/docs/ai-chat/compaction.mdx +38 -15
- package/docs/ai-chat/custom-agents.mdx +4 -4
- package/docs/ai-chat/error-handling.mdx +4 -4
- package/docs/ai-chat/fast-starts.mdx +8 -7
- package/docs/ai-chat/frontend.mdx +6 -2
- package/docs/ai-chat/lifecycle-hooks.mdx +11 -11
- package/docs/ai-chat/migrating-from-a-route-handler.mdx +4 -4
- package/docs/ai-chat/migrating-from-hydrate-messages.mdx +1 -1
- package/docs/ai-chat/overview.mdx +1 -1
- package/docs/ai-chat/patterns/branching-conversations.mdx +1 -1
- package/docs/ai-chat/patterns/database-persistence.mdx +2 -2
- package/docs/ai-chat/patterns/human-in-the-loop.mdx +1 -1
- package/docs/ai-chat/patterns/native-compaction.mdx +29 -9
- package/docs/ai-chat/patterns/persistence-and-replay.mdx +1 -1
- package/docs/ai-chat/patterns/redacting-telemetry.mdx +2 -2
- package/docs/ai-chat/patterns/skills.mdx +2 -2
- package/docs/ai-chat/patterns/sub-agents.mdx +1 -1
- package/docs/ai-chat/patterns/tool-result-auditing.mdx +1 -1
- package/docs/ai-chat/patterns/trusted-edge-signals.mdx +2 -2
- package/docs/ai-chat/patterns/version-upgrades.mdx +2 -2
- package/docs/ai-chat/pending-messages.mdx +5 -5
- package/docs/ai-chat/prompt-caching.mdx +7 -7
- package/docs/ai-chat/quick-start.mdx +2 -2
- package/docs/ai-chat/testing.mdx +9 -9
- package/docs/ai-chat/tools.mdx +9 -5
- package/docs/ai-chat/transcript-storage.mdx +2 -2
- package/docs/ai-chat/types.mdx +10 -3
- package/docs/apikeys.mdx +2 -1
- package/docs/cli-login-commands.mdx +12 -0
- package/docs/concurrency.mdx +40 -0
- package/docs/database-connections.mdx +1 -1
- package/docs/deploy-environment-variables.mdx +84 -2
- package/docs/deployment/trusted-publishing.mdx +4 -0
- package/docs/errors-retrying.mdx +25 -18
- package/docs/github-actions.mdx +1 -1
- package/docs/github-integration.mdx +21 -0
- package/docs/how-it-works.mdx +4 -2
- package/docs/introduction.mdx +1 -1
- package/docs/mcp-introduction.mdx +7 -1
- package/docs/mcp-remote.mdx +90 -0
- package/docs/oidc/azure.mdx +81 -0
- package/docs/oidc/databricks.mdx +99 -0
- package/docs/oidc/doppler.mdx +60 -0
- package/docs/oidc/gcp.mdx +109 -0
- package/docs/oidc/hugging-face.mdx +90 -0
- package/docs/oidc/openrouter.mdx +91 -0
- package/docs/oidc/snowflake.mdx +91 -0
- package/docs/oidc/vault.mdx +71 -0
- package/docs/oidc.mdx +2 -0
- package/docs/runs/metadata.mdx +1 -1
- package/docs/self-hosting/docker.mdx +2 -0
- package/docs/self-hosting/env/webapp.mdx +4 -1
- package/docs/self-hosting/kubernetes.mdx +2 -0
- package/docs/tasks/schemaTask.mdx +26 -13
- package/docs/tasks/streams.mdx +2 -2
- package/docs/troubleshooting.mdx +7 -0
- package/docs/webhooks/channels.mdx +6 -6
- package/docs/webhooks/connect.mdx +9 -75
- package/docs/webhooks/custom-providers.mdx +87 -0
- package/docs/webhooks/deliveries.mdx +7 -7
- package/docs/webhooks/filters.mdx +2 -2
- package/docs/webhooks/how-it-works.mdx +58 -0
- package/docs/webhooks/human-in-the-loop.mdx +3 -3
- package/docs/webhooks/linear.mdx +5 -3
- package/docs/webhooks/overview.mdx +20 -71
- package/docs/webhooks/own-handler.mdx +62 -0
- package/docs/webhooks/pricing-and-limits.mdx +13 -0
- package/docs/webhooks/providers/attio.mdx +38 -0
- package/docs/webhooks/providers/autumn.mdx +40 -0
- package/docs/webhooks/providers/cal-com.mdx +41 -0
- package/docs/webhooks/providers/calendly.mdx +41 -0
- package/docs/webhooks/providers/clerk.mdx +40 -0
- package/docs/webhooks/providers/discord.mdx +45 -0
- package/docs/webhooks/providers/docusign.mdx +41 -0
- package/docs/webhooks/providers/elevenlabs.mdx +41 -0
- package/docs/webhooks/providers/firecrawl.mdx +54 -0
- package/docs/webhooks/providers/github.mdx +46 -0
- package/docs/webhooks/providers/gitlab.mdx +41 -0
- package/docs/webhooks/providers/granola.mdx +44 -0
- package/docs/webhooks/providers/hookdeck.mdx +98 -0
- package/docs/webhooks/providers/infisical.mdx +41 -0
- package/docs/webhooks/providers/jira.mdx +41 -0
- package/docs/webhooks/providers/langfuse.mdx +40 -0
- package/docs/webhooks/providers/linear.mdx +45 -0
- package/docs/webhooks/providers/loops.mdx +40 -0
- package/docs/webhooks/providers/metronome.mdx +42 -0
- package/docs/webhooks/providers/mux.mdx +40 -0
- package/docs/webhooks/providers/openai.mdx +40 -0
- package/docs/webhooks/providers/pagerduty.mdx +40 -0
- package/docs/webhooks/providers/plain.mdx +41 -0
- package/docs/webhooks/providers/planetscale.mdx +40 -0
- package/docs/webhooks/providers/recall-ai.mdx +54 -0
- package/docs/webhooks/providers/replicate.mdx +41 -0
- package/docs/webhooks/providers/resend.mdx +44 -0
- package/docs/webhooks/providers/retell.mdx +41 -0
- package/docs/webhooks/providers/sentry.mdx +41 -0
- package/docs/webhooks/providers/shopify.mdx +49 -0
- package/docs/webhooks/providers/slack.mdx +48 -0
- package/docs/webhooks/providers/square.mdx +40 -0
- package/docs/webhooks/providers/stripe.mdx +86 -0
- package/docs/webhooks/providers/supabase.mdx +41 -0
- package/docs/webhooks/providers/tailscale.mdx +43 -0
- package/docs/webhooks/providers/typeform.mdx +42 -0
- package/docs/webhooks/providers/vapi.mdx +47 -0
- package/docs/webhooks/providers/vercel.mdx +40 -0
- package/docs/webhooks/providers/whatsapp.mdx +45 -0
- package/docs/webhooks/providers/workos.mdx +41 -0
- package/docs/webhooks/providers/zendesk.mdx +41 -0
- package/docs/webhooks/providers.mdx +53 -0
- package/docs/webhooks/quick-start.mdx +131 -0
- package/docs/webhooks/session-routing.mdx +6 -6
- package/docs/webhooks/signing-secrets.mdx +80 -0
- package/docs/webhooks/slack.mdx +11 -2
- package/docs/webhooks/verification.mdx +139 -0
- package/docs/webhooks/waiters.mdx +2 -2
- package/docs/webhooks/webhook-tasks.mdx +46 -0
- package/package.json +4 -5
- package/docs/migrating-from-v3.mdx +0 -332
- package/docs/webhooks/public-beta.mdx +0 -70
- package/docs/webhooks/sources.mdx +0 -252
|
@@ -81,7 +81,7 @@ export const myChat = chat.agent({
|
|
|
81
81
|
// ... fallback initialization for non-preloaded runs
|
|
82
82
|
},
|
|
83
83
|
run: async ({ messages, signal, streamText }) => {
|
|
84
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
84
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
85
85
|
},
|
|
86
86
|
});
|
|
87
87
|
```
|
|
@@ -241,7 +241,8 @@ This is an **import-chain** problem, not a runtime one. A "we'll strip the execu
|
|
|
241
241
|
id: "my-chat",
|
|
242
242
|
run: async ({ messages, signal, streamText }) =>
|
|
243
243
|
streamText({
|
|
244
|
-
model: anthropic("claude-sonnet-
|
|
244
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
245
|
+
system: "You are a helpful assistant.",
|
|
245
246
|
messages,
|
|
246
247
|
tools: chatTools,
|
|
247
248
|
stopWhen: stepCountIs(10),
|
|
@@ -263,7 +264,7 @@ This is an **import-chain** problem, not a runtime one. A "we'll strip the execu
|
|
|
263
264
|
agentId: "my-chat",
|
|
264
265
|
run: async ({ streamText }) =>
|
|
265
266
|
streamText({
|
|
266
|
-
model: anthropic("claude-sonnet-
|
|
267
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
267
268
|
system: "You are a helpful assistant.",
|
|
268
269
|
tools: headStartTools,
|
|
269
270
|
}),
|
|
@@ -280,7 +281,7 @@ This is an **import-chain** problem, not a runtime one. A "we'll strip the execu
|
|
|
280
281
|
</Note>
|
|
281
282
|
|
|
282
283
|
<Tip>
|
|
283
|
-
Use the **same model** on both sides (route handler and `chat.agent`)
|
|
284
|
+
Use the **same model and system prompt** on both sides (route handler and `chat.agent`), with the same tool names and schemas. On Claude 5.5 models, step 1's thinking is bound to that system prompt and tool set, so a mismatch makes step 2 fail with a 400. Your LLM provider keys stay server-side in your warm process — Trigger.dev never holds them in this design.
|
|
284
285
|
</Tip>
|
|
285
286
|
|
|
286
287
|
Mount the handler in whatever framework you use — see [Mounting in your framework](#mounting-in-your-framework) below.
|
|
@@ -569,7 +570,7 @@ for await (const turn of session) {
|
|
|
569
570
|
const result = turn.handover?.isFinal
|
|
570
571
|
? undefined
|
|
571
572
|
: streamText({
|
|
572
|
-
model: anthropic("claude-sonnet-
|
|
573
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
573
574
|
messages: turn.messages,
|
|
574
575
|
abortSignal: turn.signal,
|
|
575
576
|
stopWhen: stepCountIs(10),
|
|
@@ -593,7 +594,7 @@ if (turn === 0 && payload.trigger === "handover-prepare") {
|
|
|
593
594
|
// passing originalMessages so the tool output merges into the
|
|
594
595
|
// handed-over assistant instead of starting a new message.
|
|
595
596
|
const result = streamText({
|
|
596
|
-
model: anthropic("claude-sonnet-
|
|
597
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
597
598
|
messages: conversation.modelMessages,
|
|
598
599
|
stopWhen: stepCountIs(10),
|
|
599
600
|
});
|
|
@@ -691,7 +692,7 @@ export async function POST(req: Request) {
|
|
|
691
692
|
messages, // first-turn user history
|
|
692
693
|
run: async ({ streamText }) =>
|
|
693
694
|
streamText({
|
|
694
|
-
model: anthropic("claude-sonnet-
|
|
695
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
695
696
|
system: "You are a helpful assistant.",
|
|
696
697
|
tools: headStartTools,
|
|
697
698
|
}),
|
|
@@ -267,7 +267,7 @@ Browser-supplied `clientData` is input, including after schema validation. Use i
|
|
|
267
267
|
Pass metadata with individual messages via `sendMessage`. Per-message values are merged with transport-level client data (per-message wins on conflicts):
|
|
268
268
|
|
|
269
269
|
```ts
|
|
270
|
-
sendMessage({ text: "Hello" }, { metadata: { model: "gpt-
|
|
270
|
+
sendMessage({ text: "Hello" }, { metadata: { model: "gpt-6-luna", priority: "high" } });
|
|
271
271
|
```
|
|
272
272
|
|
|
273
273
|
### Typed client data with clientDataSchema
|
|
@@ -287,7 +287,7 @@ export const myChat = chat.agent({
|
|
|
287
287
|
}),
|
|
288
288
|
run: async ({ messages, clientData, signal, streamText }) => {
|
|
289
289
|
return streamText({
|
|
290
|
-
model: anthropic("claude-sonnet-
|
|
290
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
291
291
|
system: clientData?.locale === "fr" ? "Reply in French." : "Reply in English.",
|
|
292
292
|
messages,
|
|
293
293
|
abortSignal: signal,
|
|
@@ -297,6 +297,10 @@ export const myChat = chat.agent({
|
|
|
297
297
|
});
|
|
298
298
|
```
|
|
299
299
|
|
|
300
|
+
<Note>
|
|
301
|
+
On Claude 5.5 models, each thinking block is bound to the system prompt it was produced with, so changing `system` partway through a chat makes Anthropic reject the next request with a 400 (`Invalid signature in thinking block`). If users can switch language mid-chat, start a new chat when the locale changes.
|
|
302
|
+
</Note>
|
|
303
|
+
|
|
300
304
|
The schema also types the `clientData` option on the frontend transport:
|
|
301
305
|
|
|
302
306
|
```ts
|
|
@@ -62,7 +62,7 @@ export const myChat = chat.agent({
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
run: async ({ messages, signal }) => {
|
|
65
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
65
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
66
66
|
},
|
|
67
67
|
});
|
|
68
68
|
```
|
|
@@ -101,7 +101,7 @@ export const myChat = chat.agent({
|
|
|
101
101
|
// (splice partial + first user into chain, dispatch the rest).
|
|
102
102
|
},
|
|
103
103
|
run: async ({ messages, signal }) =>
|
|
104
|
-
streamText({ model: anthropic("claude-sonnet-
|
|
104
|
+
streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal }),
|
|
105
105
|
});
|
|
106
106
|
```
|
|
107
107
|
|
|
@@ -157,7 +157,7 @@ export const myChat = chat.agent({
|
|
|
157
157
|
// ... non-preloaded chat-row initialization
|
|
158
158
|
},
|
|
159
159
|
run: async ({ messages, signal }) => {
|
|
160
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
160
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
161
161
|
},
|
|
162
162
|
});
|
|
163
163
|
```
|
|
@@ -206,7 +206,7 @@ export const myChat = chat.agent({
|
|
|
206
206
|
});
|
|
207
207
|
},
|
|
208
208
|
run: async ({ messages, signal }) => {
|
|
209
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
209
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
210
210
|
},
|
|
211
211
|
});
|
|
212
212
|
```
|
|
@@ -245,7 +245,7 @@ export const myChat = chat.agent({
|
|
|
245
245
|
return messages;
|
|
246
246
|
},
|
|
247
247
|
run: async ({ messages, signal }) => {
|
|
248
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
248
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, tools: chatTools, abortSignal: signal });
|
|
249
249
|
},
|
|
250
250
|
});
|
|
251
251
|
```
|
|
@@ -305,7 +305,7 @@ export const myChat = chat.agent({
|
|
|
305
305
|
return stored;
|
|
306
306
|
},
|
|
307
307
|
run: async ({ messages, signal }) => {
|
|
308
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
308
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
309
309
|
},
|
|
310
310
|
});
|
|
311
311
|
```
|
|
@@ -363,7 +363,7 @@ export const myChat = chat.agent({
|
|
|
363
363
|
});
|
|
364
364
|
},
|
|
365
365
|
run: async ({ messages, signal }) => {
|
|
366
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
366
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
367
367
|
},
|
|
368
368
|
});
|
|
369
369
|
```
|
|
@@ -398,7 +398,7 @@ export const myChat = chat.agent({
|
|
|
398
398
|
}
|
|
399
399
|
},
|
|
400
400
|
run: async ({ messages, signal }) => {
|
|
401
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
401
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
402
402
|
},
|
|
403
403
|
});
|
|
404
404
|
```
|
|
@@ -446,7 +446,7 @@ export const myChat = chat.agent({
|
|
|
446
446
|
]);
|
|
447
447
|
},
|
|
448
448
|
run: async ({ messages, signal }) => {
|
|
449
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
449
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
450
450
|
},
|
|
451
451
|
});
|
|
452
452
|
```
|
|
@@ -489,7 +489,7 @@ export const myChat = chat.agent({
|
|
|
489
489
|
logger.info("Resumed", { phase: event.phase });
|
|
490
490
|
},
|
|
491
491
|
run: async ({ messages, signal }) => {
|
|
492
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
492
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
493
493
|
},
|
|
494
494
|
});
|
|
495
495
|
```
|
|
@@ -523,7 +523,7 @@ export const myChat = chat.agent({
|
|
|
523
523
|
await initializeChat(chatId, clientData);
|
|
524
524
|
},
|
|
525
525
|
run: async ({ messages, signal }) => {
|
|
526
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
526
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
527
527
|
},
|
|
528
528
|
});
|
|
529
529
|
```
|
|
@@ -119,7 +119,7 @@ export async function POST(req: Request) {
|
|
|
119
119
|
if (!session) return new Response("Unauthorized", { status: 401 });
|
|
120
120
|
|
|
121
121
|
const result = streamText({
|
|
122
|
-
model: anthropic("claude-sonnet-
|
|
122
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
123
123
|
system: "You are a helpful assistant.",
|
|
124
124
|
messages: convertToModelMessages(messages),
|
|
125
125
|
tools,
|
|
@@ -148,7 +148,7 @@ export const myChat = chat.agent({
|
|
|
148
148
|
run: async ({ messages, tools, signal, streamText }) =>
|
|
149
149
|
streamText({
|
|
150
150
|
tools,
|
|
151
|
-
model: anthropic("claude-sonnet-
|
|
151
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
152
152
|
system: "You are a helpful assistant.",
|
|
153
153
|
messages,
|
|
154
154
|
abortSignal: signal,
|
|
@@ -359,7 +359,7 @@ export const myChat = chat.agent({
|
|
|
359
359
|
run: async ({ messages, tools, signal, streamText }) =>
|
|
360
360
|
streamText({
|
|
361
361
|
tools,
|
|
362
|
-
model: anthropic("claude-sonnet-
|
|
362
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
363
363
|
system: "You are a helpful assistant.",
|
|
364
364
|
messages,
|
|
365
365
|
abortSignal: signal,
|
|
@@ -469,7 +469,7 @@ Head Start brings the route handler back for exactly that first turn. It runs st
|
|
|
469
469
|
agentId: "my-chat",
|
|
470
470
|
run: async ({ streamText }) =>
|
|
471
471
|
streamText({
|
|
472
|
-
model: anthropic("claude-sonnet-
|
|
472
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
473
473
|
system: "You are a helpful assistant.",
|
|
474
474
|
tools: headStartTools,
|
|
475
475
|
}),
|
|
@@ -194,7 +194,7 @@ With `hydrateMessages`, your hook was the source of truth and the runtime wrote
|
|
|
194
194
|
storage: transcriptStorage,
|
|
195
195
|
clientDataSchema: z.object({ userId: z.string() }),
|
|
196
196
|
run: async ({ messages, signal, streamText }) =>
|
|
197
|
-
streamText({ model: anthropic("claude-sonnet-
|
|
197
|
+
streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal }),
|
|
198
198
|
});
|
|
199
199
|
```
|
|
200
200
|
</Step>
|
|
@@ -19,7 +19,7 @@ export const myChat = chat.agent({
|
|
|
19
19
|
id: "my-chat",
|
|
20
20
|
run: async ({ messages, signal, streamText }) =>
|
|
21
21
|
streamText({
|
|
22
|
-
model: anthropic("claude-sonnet-
|
|
22
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
23
23
|
messages,
|
|
24
24
|
abortSignal: signal,
|
|
25
25
|
stopWhen: stepCountIs(15),
|
|
@@ -227,7 +227,7 @@ export const myChat = chat.agent({
|
|
|
227
227
|
]);
|
|
228
228
|
},
|
|
229
229
|
run: async ({ messages, signal, streamText }) => {
|
|
230
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
230
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
231
231
|
},
|
|
232
232
|
});
|
|
233
233
|
```
|
|
@@ -298,7 +298,7 @@ export const myChat = chat.agent({
|
|
|
298
298
|
},
|
|
299
299
|
run: async ({ messages, signal, streamText }) => {
|
|
300
300
|
return streamText({
|
|
301
|
-
model: anthropic("claude-sonnet-
|
|
301
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
302
302
|
messages,
|
|
303
303
|
abortSignal: signal,
|
|
304
304
|
stopWhen: stepCountIs(15),
|
|
@@ -76,7 +76,7 @@ export const myChat = chat.withUIMessage<ChatMessage>().agent({
|
|
|
76
76
|
tools,
|
|
77
77
|
run: async ({ messages, tools, signal, streamText }) => {
|
|
78
78
|
return streamText({
|
|
79
|
-
model: anthropic("claude-sonnet-
|
|
79
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
80
80
|
messages,
|
|
81
81
|
tools,
|
|
82
82
|
abortSignal: signal,
|
|
@@ -50,23 +50,28 @@ const isToolPart = (p: { type?: string }) =>
|
|
|
50
50
|
typeof p?.type === "string" && (p.type.startsWith("tool-") || p.type === "dynamic-tool");
|
|
51
51
|
|
|
52
52
|
// Drop the oldest n tool parts, mirroring what the provider cleared. A tool call
|
|
53
|
-
// and its result live in one part, so pairing stays intact.
|
|
53
|
+
// and its result live in one part, so pairing stays intact. Once a message is
|
|
54
|
+
// edited, its thinking and every later message's thinking no longer verify on
|
|
55
|
+
// Claude 5.5 models, so those reasoning parts are dropped too.
|
|
54
56
|
function pruneOldestToolParts(messages: UIMessage[], n: number): UIMessage[] {
|
|
55
57
|
let toRemove = n;
|
|
58
|
+
let edited = false;
|
|
56
59
|
const out: UIMessage[] = [];
|
|
57
60
|
for (const m of messages) {
|
|
58
|
-
if (
|
|
61
|
+
if (m.role !== "assistant" || !m.parts) {
|
|
59
62
|
out.push(m);
|
|
60
63
|
continue;
|
|
61
64
|
}
|
|
62
65
|
const kept = m.parts.filter((p) => {
|
|
63
66
|
if (toRemove > 0 && isToolPart(p)) {
|
|
64
67
|
toRemove--;
|
|
68
|
+
edited = true;
|
|
65
69
|
return false;
|
|
66
70
|
}
|
|
67
71
|
return true;
|
|
68
72
|
});
|
|
69
|
-
|
|
73
|
+
const parts = edited ? kept.filter((p) => p.type !== "reasoning") : kept;
|
|
74
|
+
if (parts.length > 0) out.push({ ...m, parts });
|
|
70
75
|
}
|
|
71
76
|
return out;
|
|
72
77
|
}
|
|
@@ -77,7 +82,7 @@ export const nativePersist = chat.agent({
|
|
|
77
82
|
tools: { fetchRecord },
|
|
78
83
|
run: async ({ messages, chatId, tools, signal, streamText }) => {
|
|
79
84
|
return streamText({
|
|
80
|
-
model: anthropic("claude-sonnet-
|
|
85
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
81
86
|
messages,
|
|
82
87
|
tools,
|
|
83
88
|
abortSignal: signal,
|
|
@@ -126,6 +131,10 @@ Turn 1 sends the user message and accumulates six tool results. Anthropic clears
|
|
|
126
131
|
`onTurnComplete` is where persistence happens. Action turns fire `onAction` only, and a `chat.history.set()` inside `run()` is overwritten by the accumulator at turn end. See [Persistence and replay](/ai-chat/patterns/persistence-and-replay#action-turns-no-snapshot-write).
|
|
127
132
|
</Note>
|
|
128
133
|
|
|
134
|
+
<Warning>
|
|
135
|
+
Thinking is on by default on Claude 5.5 models, and each thinking block is bound to the conversation that came before it. Removing tool parts from earlier turns in your own code changes that history, so Anthropic can reject the next request with a 400 (`Invalid signature in thinking block`). Server-side context editing, as configured above, doesn't count as an edit. That's why `pruneOldestToolParts` also removes the reasoning parts from the turns it changes and every turn after them.
|
|
136
|
+
</Warning>
|
|
137
|
+
|
|
129
138
|
## Persist OpenAI stored responses
|
|
130
139
|
|
|
131
140
|
OpenAI's `store: true` keeps the thread server-side and returns a `responseId`. Pass that back as `previousResponseId` on the next turn and send only the messages since the last assistant reply; everything before it lives on OpenAI's side.
|
|
@@ -156,7 +165,7 @@ export const openaiStore = chat.agent({
|
|
|
156
165
|
const outbound = native ? messagesSinceLastAssistant(messages) : messages;
|
|
157
166
|
|
|
158
167
|
const result = streamText({
|
|
159
|
-
model: openai("gpt-
|
|
168
|
+
model: openai("gpt-6-luna"),
|
|
160
169
|
messages: outbound,
|
|
161
170
|
abortSignal: signal,
|
|
162
171
|
stopWhen: stepCountIs(5),
|
|
@@ -197,10 +206,17 @@ const FALLBACK_ORDER: Provider[] = ["anthropic", "openai"];
|
|
|
197
206
|
type NativeState = { provider: "openai"; previousResponseId: string };
|
|
198
207
|
const nativeStore = new Map<string, NativeState>();
|
|
199
208
|
|
|
209
|
+
// Retained messages follow a different history after compaction, so their thinking
|
|
210
|
+
// blocks no longer verify on Claude 5.5 models. Drop reasoning parts before replaying them.
|
|
211
|
+
function stripReasoning(message: ModelMessage): ModelMessage {
|
|
212
|
+
if (message.role !== "assistant" || typeof message.content === "string") return message;
|
|
213
|
+
return { ...message, content: message.content.filter((part) => part.type !== "reasoning") };
|
|
214
|
+
}
|
|
215
|
+
|
|
200
216
|
// Provider-agnostic summary: a plain string, portable across any provider.
|
|
201
217
|
async function summarizeConversation(messages: ModelMessage[]): Promise<string> {
|
|
202
218
|
const { text } = await generateText({
|
|
203
|
-
model: openai("gpt-
|
|
219
|
+
model: openai("gpt-6-luna"),
|
|
204
220
|
messages: [
|
|
205
221
|
...messages,
|
|
206
222
|
{
|
|
@@ -223,7 +239,7 @@ export const resilientChat = chat.agent({
|
|
|
223
239
|
summarize: ({ messages }) => summarizeConversation(messages),
|
|
224
240
|
compactModelMessages: ({ modelMessages, summary }) => [
|
|
225
241
|
{ role: "user", content: `Summary of the conversation so far:\n\n${summary}` },
|
|
226
|
-
...modelMessages.slice(-2),
|
|
242
|
+
...modelMessages.slice(-2).map(stripReasoning),
|
|
227
243
|
],
|
|
228
244
|
compactUIMessages: ({ uiMessages, summary }) => [
|
|
229
245
|
{
|
|
@@ -251,7 +267,7 @@ export const resilientChat = chat.agent({
|
|
|
251
267
|
// compacted baseline (summary + recent), so raw history is not re-sent.
|
|
252
268
|
const useHandle = native?.provider === "openai";
|
|
253
269
|
const result = streamText({
|
|
254
|
-
model: openai("gpt-
|
|
270
|
+
model: openai("gpt-6-luna"),
|
|
255
271
|
messages,
|
|
256
272
|
abortSignal: signal,
|
|
257
273
|
stopWhen: stepCountIs(5),
|
|
@@ -269,7 +285,7 @@ export const resilientChat = chat.agent({
|
|
|
269
285
|
}
|
|
270
286
|
|
|
271
287
|
return streamText({
|
|
272
|
-
model: anthropic("claude-sonnet-
|
|
288
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
273
289
|
messages,
|
|
274
290
|
abortSignal: signal,
|
|
275
291
|
stopWhen: stepCountIs(5),
|
|
@@ -292,6 +308,10 @@ export const resilientChat = chat.agent({
|
|
|
292
308
|
|
|
293
309
|
When Anthropic is down, the loop falls through to OpenAI. Because `compaction` has already reduced `messages` to a summary plus the last couple of exchanges, the switch sends the portable baseline, not megabytes of raw transcript.
|
|
294
310
|
|
|
311
|
+
<Note>
|
|
312
|
+
The messages that `compactModelMessages` keeps after the summary now follow a different history from the one their thinking blocks were produced in. Claude 5.5 models reject those blocks with a 400 (`Invalid signature in thinking block`), which is why the example runs the retained messages through `stripReasoning`.
|
|
313
|
+
</Note>
|
|
314
|
+
|
|
295
315
|
<Warning>
|
|
296
316
|
Fallback here retries a turn that hasn't started streaming yet. Once a response is streaming to the client, a mid-stream provider failure can't be swapped transparently. Surface the error and let the frontend regenerate the turn. See [Error handling](/ai-chat/error-handling).
|
|
297
317
|
</Warning>
|
|
@@ -163,7 +163,7 @@ export const myChat = chat.agent({
|
|
|
163
163
|
await db.chat.update({ where: { id: chatId }, data: { messages: uiMessages } });
|
|
164
164
|
},
|
|
165
165
|
run: async ({ messages, signal }) => {
|
|
166
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
166
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
167
167
|
},
|
|
168
168
|
});
|
|
169
169
|
```
|
|
@@ -28,7 +28,7 @@ export const supportAgent = chat.agent({
|
|
|
28
28
|
id: "support-agent",
|
|
29
29
|
telemetry: { recordUserMessage: false, recordClientData: false },
|
|
30
30
|
run: async ({ messages, signal, streamText }) =>
|
|
31
|
-
streamText({ model: anthropic("claude-sonnet-
|
|
31
|
+
streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal }),
|
|
32
32
|
});
|
|
33
33
|
```
|
|
34
34
|
|
|
@@ -47,7 +47,7 @@ export const supportAgent = chat.agent({
|
|
|
47
47
|
telemetry: { recordUserMessage: false, recordClientData: false },
|
|
48
48
|
run: async ({ messages, signal, streamText }) =>
|
|
49
49
|
streamText({
|
|
50
|
-
model: anthropic("claude-sonnet-
|
|
50
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
51
51
|
messages,
|
|
52
52
|
abortSignal: signal,
|
|
53
53
|
// Replaces the default telemetry config (and chat.prompt.set()'s), so keep isEnabled on
|
|
@@ -94,7 +94,7 @@ export const agent = chat.agent({
|
|
|
94
94
|
},
|
|
95
95
|
run: async ({ messages, signal, streamText }) => {
|
|
96
96
|
return streamText({
|
|
97
|
-
model: anthropic("claude-sonnet-
|
|
97
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
98
98
|
messages,
|
|
99
99
|
abortSignal: signal,
|
|
100
100
|
stopWhen: stepCountIs(15),
|
|
@@ -165,7 +165,7 @@ If you also define your own AI SDK tools, pass them through `chat.toStreamTextOp
|
|
|
165
165
|
|
|
166
166
|
```ts
|
|
167
167
|
return streamText({
|
|
168
|
-
model: anthropic("claude-sonnet-
|
|
168
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
169
169
|
messages,
|
|
170
170
|
abortSignal: signal,
|
|
171
171
|
tools: {
|
|
@@ -301,7 +301,7 @@ export const myAgent = chat.agent({
|
|
|
301
301
|
tools, // declare here so toModelOutput survives across turns
|
|
302
302
|
run: async ({ messages, tools, stopSignal, streamText }) => {
|
|
303
303
|
return streamText({
|
|
304
|
-
model: anthropic("claude-sonnet-
|
|
304
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
305
305
|
messages,
|
|
306
306
|
tools,
|
|
307
307
|
abortSignal: stopSignal,
|
|
@@ -37,7 +37,7 @@ export const myChat = chat.agent({
|
|
|
37
37
|
return await db.getMessages(chatId);
|
|
38
38
|
},
|
|
39
39
|
run: async ({ messages, signal, streamText }) => {
|
|
40
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
40
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
41
41
|
},
|
|
42
42
|
});
|
|
43
43
|
```
|
|
@@ -247,7 +247,7 @@ export const myAgent = chat
|
|
|
247
247
|
// Score-based routing. The values arrive from the edge proxy.
|
|
248
248
|
if (clientData.__cf.botScore < 30) {
|
|
249
249
|
return streamText({
|
|
250
|
-
model: anthropic("claude-haiku-
|
|
250
|
+
model: anthropic("claude-haiku-5-5"),
|
|
251
251
|
messages: [{ role: "system", content: "Reject politely; do not engage." }],
|
|
252
252
|
abortSignal: signal,
|
|
253
253
|
stopWhen: stepCountIs(15),
|
|
@@ -255,7 +255,7 @@ export const myAgent = chat
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
return streamText({
|
|
258
|
-
model: anthropic("claude-sonnet-
|
|
258
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
259
259
|
messages,
|
|
260
260
|
abortSignal: signal,
|
|
261
261
|
// ...
|
|
@@ -122,7 +122,7 @@ export const myChat = chat
|
|
|
122
122
|
}
|
|
123
123
|
},
|
|
124
124
|
run: async ({ messages, signal, streamText }) => {
|
|
125
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
125
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
126
126
|
},
|
|
127
127
|
});
|
|
128
128
|
```
|
|
@@ -184,7 +184,7 @@ export const myChat = chat
|
|
|
184
184
|
}
|
|
185
185
|
},
|
|
186
186
|
run: async ({ messages, signal, streamText }) => {
|
|
187
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
187
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
188
188
|
},
|
|
189
189
|
});
|
|
190
190
|
```
|
|
@@ -45,7 +45,7 @@ export const myChat = chat.agent({
|
|
|
45
45
|
},
|
|
46
46
|
run: async ({ messages, signal, streamText }) => {
|
|
47
47
|
return streamText({
|
|
48
|
-
model: anthropic("claude-sonnet-
|
|
48
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
49
49
|
messages,
|
|
50
50
|
tools: {
|
|
51
51
|
inspectDocument: tool({
|
|
@@ -151,7 +151,7 @@ const session = chat.createSession(payload, {
|
|
|
151
151
|
|
|
152
152
|
for await (const turn of session) {
|
|
153
153
|
const result = streamText({
|
|
154
|
-
model: anthropic("claude-sonnet-
|
|
154
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
155
155
|
messages: turn.messages,
|
|
156
156
|
abortSignal: turn.signal,
|
|
157
157
|
prepareStep: turn.prepareStep(), // Handles injection + compaction
|
|
@@ -193,7 +193,7 @@ for (let turn = 0; turn < 100; turn++) {
|
|
|
193
193
|
});
|
|
194
194
|
|
|
195
195
|
const result = streamText({
|
|
196
|
-
model: anthropic("claude-sonnet-
|
|
196
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
197
197
|
messages,
|
|
198
198
|
prepareStep: conversation.prepareStep(), // Handles injection + compaction
|
|
199
199
|
stopWhen: stepCountIs(15),
|
|
@@ -248,7 +248,7 @@ function Chat({ chatId }: { chatId: string }) {
|
|
|
248
248
|
messages,
|
|
249
249
|
setMessages,
|
|
250
250
|
sendMessage,
|
|
251
|
-
metadata: { model: "gpt-
|
|
251
|
+
metadata: { model: "gpt-6-luna" },
|
|
252
252
|
});
|
|
253
253
|
|
|
254
254
|
return (
|
|
@@ -345,7 +345,7 @@ const sent = await transport.sendPendingMessage(chatId, {
|
|
|
345
345
|
id: crypto.randomUUID(),
|
|
346
346
|
role: "user",
|
|
347
347
|
parts: [{ type: "text", text: "and compare to vercel" }],
|
|
348
|
-
}, { model: "gpt-
|
|
348
|
+
}, { model: "gpt-6-luna" });
|
|
349
349
|
```
|
|
350
350
|
|
|
351
351
|
Unlike `sendMessage()` from useChat, this does NOT:
|
|
@@ -4,7 +4,7 @@ sidebarTitle: "Prompt caching"
|
|
|
4
4
|
description: "Cache the stable prefix of your agent's prompt with Anthropic prompt caching to cut token cost and latency on every turn."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
**Prompt caching lets a provider reuse the unchanged prefix of your prompt across requests, billing it at a fraction of the input price and skipping re-processing.** With Anthropic, cache reads cost ~
|
|
7
|
+
**Prompt caching lets a provider reuse the unchanged prefix of your prompt across requests, billing it at a fraction of the input price and skipping re-processing.** With Anthropic, cache reads cost ~5% of base input tokens on Claude Sonnet 5.5 and Opus 5.5, so a long, stable system prompt or a growing conversation history pays full price once and reads cheaply on every turn after.
|
|
8
8
|
|
|
9
9
|
Caching is a **byte-exact prefix match**: any change in the prefix invalidates everything after it. A multi-turn agent is the ideal case — the system prompt, tools, and earlier turns are identical turn over turn, so the cacheable prefix only grows. `chat.agent` is built to keep that prefix stable across turns, suspends, and resumes; this page shows how to place the cache breakpoints and verify they're hitting.
|
|
10
10
|
|
|
@@ -46,7 +46,7 @@ export const myChat = chat.agent({
|
|
|
46
46
|
},
|
|
47
47
|
run: async ({ messages, signal, streamText }) => {
|
|
48
48
|
return streamText({
|
|
49
|
-
model: anthropic("claude-sonnet-
|
|
49
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
50
50
|
// Caches the system block with a 5-minute breakpoint.
|
|
51
51
|
messages,
|
|
52
52
|
abortSignal: signal,
|
|
@@ -63,7 +63,7 @@ export const myChat = chat.agent({
|
|
|
63
63
|
systemProviderOptions: { anthropic: { cacheControl: { type: "ephemeral" } } },
|
|
64
64
|
run: async ({ messages, signal, streamText }) =>
|
|
65
65
|
streamText({
|
|
66
|
-
model: anthropic("claude-sonnet-
|
|
66
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
67
67
|
messages,
|
|
68
68
|
abortSignal: signal,
|
|
69
69
|
}),
|
|
@@ -80,7 +80,7 @@ onChatStart: async () => {
|
|
|
80
80
|
},
|
|
81
81
|
run: async ({ messages, signal, streamText }) => {
|
|
82
82
|
return streamText({
|
|
83
|
-
model: anthropic("claude-sonnet-
|
|
83
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
84
84
|
messages,
|
|
85
85
|
abortSignal: signal,
|
|
86
86
|
});
|
|
@@ -117,7 +117,7 @@ export const myChat = chat.agent({
|
|
|
117
117
|
},
|
|
118
118
|
run: async ({ messages, signal, streamText }) => {
|
|
119
119
|
return streamText({
|
|
120
|
-
model: anthropic("claude-sonnet-
|
|
120
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
121
121
|
messages,
|
|
122
122
|
abortSignal: signal,
|
|
123
123
|
});
|
|
@@ -128,7 +128,7 @@ export const myChat = chat.agent({
|
|
|
128
128
|
The system breakpoint and the conversation breakpoint compose: the system block is cached once for the life of the chat, and each turn extends the cached message prefix.
|
|
129
129
|
|
|
130
130
|
<Note>
|
|
131
|
-
Anthropic allows **at most 4** cache breakpoints per request, and a prefix must
|
|
131
|
+
Anthropic allows **at most 4** cache breakpoints per request, and a prefix must reach a model-dependent minimum to cache at all (512 tokens on Claude Sonnet 5.5 and Opus 5.5) — shorter prefixes silently don't cache. One system breakpoint plus one rolling message breakpoint is the typical setup and leaves headroom.
|
|
132
132
|
</Note>
|
|
133
133
|
|
|
134
134
|
<Note>
|
|
@@ -171,7 +171,7 @@ run: async ({ messages, signal, previousTurnUsage, streamText }) => {
|
|
|
171
171
|
console.log("cache write", previousTurnUsage?.inputTokenDetails?.cacheWriteTokens);
|
|
172
172
|
|
|
173
173
|
return streamText({
|
|
174
|
-
model: anthropic("claude-sonnet-
|
|
174
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
175
175
|
messages,
|
|
176
176
|
abortSignal: signal,
|
|
177
177
|
});
|
|
@@ -23,7 +23,7 @@ The chat surface works with Vercel AI SDK **v5, v6, or v7**; install whichever m
|
|
|
23
23
|
id: "my-chat",
|
|
24
24
|
run: async ({ messages, signal, streamText }) => {
|
|
25
25
|
return streamText({
|
|
26
|
-
model: anthropic("claude-sonnet-
|
|
26
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
27
27
|
messages,
|
|
28
28
|
abortSignal: signal,
|
|
29
29
|
stopWhen: stepCountIs(15),
|
|
@@ -76,7 +76,7 @@ The chat surface works with Vercel AI SDK **v5, v6, or v7**; install whichever m
|
|
|
76
76
|
|
|
77
77
|
`requireChatOwner` is your application helper: authenticate the request, load the chat by ID and owner, and throw if it doesn't belong to that user. Create the chat record on your server before rendering the frontend, and pass its ID into `Chat`. Check ownership in both actions, including token refresh.
|
|
78
78
|
|
|
79
|
-
Set `TRIGGER_SECRET_KEY` and your model provider key in the
|
|
79
|
+
Set `TRIGGER_SECRET_KEY` on your server and your model provider key in the worker environment. Keep both keys out of the browser.
|
|
80
80
|
|
|
81
81
|
</Step>
|
|
82
82
|
|