@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
package/docs/ai/prompts.mdx
CHANGED
|
@@ -25,8 +25,8 @@ import { z } from "zod";
|
|
|
25
25
|
export const supportPrompt = prompts.define({
|
|
26
26
|
id: "customer-support",
|
|
27
27
|
description: "System prompt for customer support interactions",
|
|
28
|
-
model: "gpt-
|
|
29
|
-
config: {
|
|
28
|
+
model: "gpt-6-luna",
|
|
29
|
+
config: { maxOutputTokens: 1024 },
|
|
30
30
|
variables: z.object({
|
|
31
31
|
customerName: z.string(),
|
|
32
32
|
plan: z.string(),
|
|
@@ -50,8 +50,8 @@ Respond to the customer's issue. Be concise and helpful.`,
|
|
|
50
50
|
|--------|------|----------|-------------|
|
|
51
51
|
| `id` | `string` | Yes | Unique identifier (becomes the prompt slug) |
|
|
52
52
|
| `description` | `string` | No | Shown in the dashboard |
|
|
53
|
-
| `model` | `string` | No | Default model (e.g. `"gpt-
|
|
54
|
-
| `config` | `object` | No | Default
|
|
53
|
+
| `model` | `string` | No | Default model (e.g. `"gpt-6-luna"`, `"claude-sonnet-5-5"`) |
|
|
54
|
+
| `config` | `object` | No | Default AI SDK call settings (e.g. `maxOutputTokens`) |
|
|
55
55
|
| `variables` | Zod/ArkType schema | No | Schema for template variables (enables validation and dashboard UI) |
|
|
56
56
|
| `content` | `string` | Yes | The prompt template with `{{variable}}` placeholders |
|
|
57
57
|
|
|
@@ -65,7 +65,7 @@ Templates use Mustache-style placeholders:
|
|
|
65
65
|
```ts
|
|
66
66
|
export const prompt = prompts.define({
|
|
67
67
|
id: "summarizer",
|
|
68
|
-
model: "gpt-
|
|
68
|
+
model: "gpt-6-luna",
|
|
69
69
|
variables: z.object({
|
|
70
70
|
text: z.string(),
|
|
71
71
|
maxSentences: z.string().optional(),
|
|
@@ -91,7 +91,7 @@ const resolved = await supportPrompt.resolve({
|
|
|
91
91
|
|
|
92
92
|
console.log(resolved.text); // The compiled prompt with variables filled in
|
|
93
93
|
console.log(resolved.version); // e.g. 3
|
|
94
|
-
console.log(resolved.model); // "gpt-
|
|
94
|
+
console.log(resolved.model); // "gpt-6-luna"
|
|
95
95
|
console.log(resolved.labels); // ["current"] or ["override"]
|
|
96
96
|
```
|
|
97
97
|
|
|
@@ -135,12 +135,16 @@ By default, `resolve()` returns the **override** version if one is active, other
|
|
|
135
135
|
|
|
136
136
|
The resolved prompt integrates with the [Vercel AI SDK](https://ai-sdk.dev) via `toAISDKTelemetry()`. This links AI generation spans to the prompt in the dashboard.
|
|
137
137
|
|
|
138
|
+
<Note>
|
|
139
|
+
Prompt linking currently works on AI SDK 5 and 6. On AI SDK 7, the metadata from `toAISDKTelemetry()` doesn't reach the span yet, so generations are traced but not linked to the prompt.
|
|
140
|
+
</Note>
|
|
141
|
+
|
|
138
142
|
### generateText
|
|
139
143
|
|
|
140
144
|
```ts
|
|
141
145
|
import { task } from "@trigger.dev/sdk";
|
|
142
146
|
import { generateText, stepCountIs } from "ai";
|
|
143
|
-
import {
|
|
147
|
+
import { openai } from "@ai-sdk/openai";
|
|
144
148
|
|
|
145
149
|
export const supportTask = task({
|
|
146
150
|
id: "handle-support",
|
|
@@ -152,9 +156,10 @@ export const supportTask = task({
|
|
|
152
156
|
});
|
|
153
157
|
|
|
154
158
|
const result = await generateText({
|
|
155
|
-
model: openai(resolved.model ?? "gpt-
|
|
159
|
+
model: openai(resolved.model ?? "gpt-6-luna"),
|
|
156
160
|
system: resolved.text,
|
|
157
161
|
prompt: payload.issue,
|
|
162
|
+
...resolved.config,
|
|
158
163
|
...resolved.toAISDKTelemetry(),
|
|
159
164
|
});
|
|
160
165
|
|
|
@@ -178,9 +183,10 @@ export const streamTask = task({
|
|
|
178
183
|
});
|
|
179
184
|
|
|
180
185
|
const result = streamText({
|
|
181
|
-
model: openai(resolved.model ?? "gpt-
|
|
186
|
+
model: openai(resolved.model ?? "gpt-6-luna"),
|
|
182
187
|
system: resolved.text,
|
|
183
188
|
prompt: payload.issue,
|
|
189
|
+
...resolved.config,
|
|
184
190
|
...resolved.toAISDKTelemetry(),
|
|
185
191
|
stopWhen: stepCountIs(15),
|
|
186
192
|
});
|
|
@@ -201,7 +207,7 @@ Pass additional metadata to `toAISDKTelemetry()` that will appear on the generat
|
|
|
201
207
|
|
|
202
208
|
```ts
|
|
203
209
|
const result = await generateText({
|
|
204
|
-
model: anthropic("claude-sonnet-
|
|
210
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
205
211
|
prompt: resolved.text,
|
|
206
212
|
...resolved.toAISDKTelemetry({
|
|
207
213
|
"task.type": "summarization",
|
|
@@ -227,8 +233,8 @@ const registry = createProviderRegistry({ anthropic });
|
|
|
227
233
|
|
|
228
234
|
const systemPrompt = prompts.define({
|
|
229
235
|
id: "my-chat-system",
|
|
230
|
-
model: "anthropic:claude-sonnet-
|
|
231
|
-
config: {
|
|
236
|
+
model: "anthropic:claude-sonnet-5-5",
|
|
237
|
+
config: { maxOutputTokens: 1024 },
|
|
232
238
|
variables: z.object({ name: z.string() }),
|
|
233
239
|
content: `You are a helpful assistant for {{name}}.`,
|
|
234
240
|
});
|
|
@@ -259,21 +265,21 @@ Inside a `chat.agent` you don't need this: the `streamText` passed to `run()` ap
|
|
|
259
265
|
|
|
260
266
|
- `system` — the compiled prompt text
|
|
261
267
|
- `model` — resolved via the `registry` when provided
|
|
262
|
-
- `
|
|
268
|
+
- `maxOutputTokens` and other call settings — from the prompt's `config`
|
|
263
269
|
- `experimental_telemetry` — links generations to the prompt in the dashboard
|
|
264
270
|
|
|
265
271
|
```ts
|
|
266
272
|
// With registry — model is resolved automatically
|
|
267
273
|
const options = chat.toStreamTextOptions({ registry });
|
|
268
|
-
// { system: "...", model: LanguageModel,
|
|
274
|
+
// { system: "...", model: LanguageModel, maxOutputTokens: 1024, experimental_telemetry: { ... } }
|
|
269
275
|
|
|
270
276
|
// Without registry — model is not included
|
|
271
277
|
const options = chat.toStreamTextOptions();
|
|
272
|
-
// { system: "...",
|
|
278
|
+
// { system: "...", maxOutputTokens: 1024, experimental_telemetry: { ... } }
|
|
273
279
|
```
|
|
274
280
|
|
|
275
281
|
<Tip>
|
|
276
|
-
When the user provides a `registry` and the prompt has a `model` string (e.g. `"anthropic:claude-sonnet-
|
|
282
|
+
When the user provides a `registry` and the prompt has a `model` string (e.g. `"anthropic:claude-sonnet-5-5"`), the model is resolved via `registry.languageModel()` and included in the returned options. This means `streamText` uses the prompt's model by default — no manual model selection needed.
|
|
277
283
|
</Tip>
|
|
278
284
|
|
|
279
285
|
### Reading the prompt
|
|
@@ -284,7 +290,7 @@ Access the stored prompt from anywhere in the run:
|
|
|
284
290
|
run: async ({ messages, signal, streamText }) => {
|
|
285
291
|
const prompt = chat.prompt(); // Throws if not set
|
|
286
292
|
console.log(prompt.text); // The compiled prompt
|
|
287
|
-
console.log(prompt.model); // "anthropic:claude-sonnet-
|
|
293
|
+
console.log(prompt.model); // "anthropic:claude-sonnet-5-5"
|
|
288
294
|
console.log(prompt.version); // 3
|
|
289
295
|
|
|
290
296
|
return streamText({
|
|
@@ -324,7 +330,7 @@ Create a new override that takes priority over the deployed version:
|
|
|
324
330
|
```ts
|
|
325
331
|
const result = await prompts.createOverride("customer-support", {
|
|
326
332
|
textContent: "New prompt template: Hello {{customerName}}!",
|
|
327
|
-
model: "gpt-
|
|
333
|
+
model: "gpt-6-luna",
|
|
328
334
|
commitMessage: "Shorter prompt",
|
|
329
335
|
});
|
|
330
336
|
```
|
|
@@ -334,7 +340,7 @@ const result = await prompts.createOverride("customer-support", {
|
|
|
334
340
|
```ts
|
|
335
341
|
await prompts.updateOverride("customer-support", {
|
|
336
342
|
textContent: "Updated template: Hi {{customerName}}!",
|
|
337
|
-
model: "gpt-
|
|
343
|
+
model: "gpt-6-luna",
|
|
338
344
|
});
|
|
339
345
|
```
|
|
340
346
|
|
package/docs/ai-chat/actions.mdx
CHANGED
|
@@ -45,7 +45,7 @@ export const myChat = chat.agent({
|
|
|
45
45
|
},
|
|
46
46
|
|
|
47
47
|
run: async ({ messages, signal, streamText }) => {
|
|
48
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
48
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
49
49
|
},
|
|
50
50
|
});
|
|
51
51
|
```
|
package/docs/ai-chat/anatomy.mdx
CHANGED
|
@@ -65,7 +65,7 @@ export const myAgent = chat.agent({
|
|
|
65
65
|
run: async ({ messages, tools, signal, streamText }) =>
|
|
66
66
|
streamText({
|
|
67
67
|
tools,
|
|
68
|
-
model: anthropic("claude-sonnet-
|
|
68
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
69
69
|
messages,
|
|
70
70
|
abortSignal: signal,
|
|
71
71
|
stopWhen: stepCountIs(15),
|
package/docs/ai-chat/backend.mdx
CHANGED
|
@@ -37,7 +37,7 @@ export const simpleChat = chat.agent({
|
|
|
37
37
|
id: "simple-chat",
|
|
38
38
|
run: async ({ messages, signal, streamText }) => {
|
|
39
39
|
return streamText({
|
|
40
|
-
model: anthropic("claude-sonnet-
|
|
40
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
41
41
|
system: "You are a helpful assistant.",
|
|
42
42
|
messages,
|
|
43
43
|
abortSignal: signal,
|
|
@@ -63,7 +63,7 @@ export const simpleChat = chat.agent({
|
|
|
63
63
|
id: "simple-chat",
|
|
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
|
stopWhen: stepCountIs(15),
|
|
@@ -108,7 +108,7 @@ async function runAgentLoop(messages: ModelMessage[], streamText: ChatStreamText
|
|
|
108
108
|
// ... agent logic, tool calls, etc.
|
|
109
109
|
|
|
110
110
|
const result = streamText({
|
|
111
|
-
model: anthropic("claude-sonnet-
|
|
111
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
112
112
|
messages,
|
|
113
113
|
stopWhen: stepCountIs(15),
|
|
114
114
|
});
|
|
@@ -129,7 +129,7 @@ export const myChat = chat.agent({
|
|
|
129
129
|
// This data part will be in responseMessage.parts in onTurnComplete
|
|
130
130
|
writer.write({
|
|
131
131
|
type: "data-metadata",
|
|
132
|
-
data: { turn, model: "gpt-
|
|
132
|
+
data: { turn, model: "gpt-6-luna", timestamp: Date.now() },
|
|
133
133
|
});
|
|
134
134
|
},
|
|
135
135
|
onTurnComplete: async ({ responseMessage }) => {
|
|
@@ -143,7 +143,7 @@ export const myChat = chat.agent({
|
|
|
143
143
|
data: { searchResults: results },
|
|
144
144
|
});
|
|
145
145
|
|
|
146
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
146
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
147
147
|
},
|
|
148
148
|
});
|
|
149
149
|
```
|
|
@@ -214,7 +214,7 @@ export const myChat = chat.agent({
|
|
|
214
214
|
run: async ({ messages, tools, signal, streamText }) =>
|
|
215
215
|
streamText({
|
|
216
216
|
tools,
|
|
217
|
-
model: anthropic("claude-sonnet-
|
|
217
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
218
218
|
messages,
|
|
219
219
|
abortSignal: signal,
|
|
220
220
|
stopWhen: stepCountIs(15),
|
|
@@ -239,7 +239,7 @@ Use [AI Prompts](/ai/prompts) to manage your system prompt as versioned, overrid
|
|
|
239
239
|
```ts
|
|
240
240
|
import { chat } from "@trigger.dev/sdk/ai";
|
|
241
241
|
import { prompts } from "@trigger.dev/sdk";
|
|
242
|
-
import { createProviderRegistry } from "ai";
|
|
242
|
+
import { createProviderRegistry, stepCountIs } from "ai";
|
|
243
243
|
import { anthropic } from "@ai-sdk/anthropic";
|
|
244
244
|
import { z } from "zod";
|
|
245
245
|
|
|
@@ -247,8 +247,8 @@ const registry = createProviderRegistry({ anthropic });
|
|
|
247
247
|
|
|
248
248
|
const systemPrompt = prompts.define({
|
|
249
249
|
id: "my-chat-system",
|
|
250
|
-
model: "anthropic:claude-sonnet-
|
|
251
|
-
config: {
|
|
250
|
+
model: "anthropic:claude-sonnet-5-5",
|
|
251
|
+
config: { maxOutputTokens: 1024 },
|
|
252
252
|
variables: z.object({ name: z.string() }),
|
|
253
253
|
content: `You are a helpful assistant for {{name}}.`,
|
|
254
254
|
});
|
|
@@ -302,7 +302,7 @@ export const myChat = chat.agent({
|
|
|
302
302
|
id: "my-chat",
|
|
303
303
|
run: async ({ messages, signal, stopSignal, cancelSignal, streamText }) => {
|
|
304
304
|
return streamText({
|
|
305
|
-
model: anthropic("claude-sonnet-
|
|
305
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
306
306
|
messages,
|
|
307
307
|
abortSignal: signal, // Handles both stop and cancel
|
|
308
308
|
stopWhen: stepCountIs(15),
|
|
@@ -330,7 +330,7 @@ export const myChat = chat.agent({
|
|
|
330
330
|
});
|
|
331
331
|
},
|
|
332
332
|
run: async ({ messages, signal, streamText }) => {
|
|
333
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
333
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
334
334
|
},
|
|
335
335
|
});
|
|
336
336
|
```
|
|
@@ -344,7 +344,7 @@ export const myChat = chat.agent({
|
|
|
344
344
|
id: "my-chat",
|
|
345
345
|
run: async ({ messages, signal, streamText }) => {
|
|
346
346
|
return streamText({
|
|
347
|
-
model: anthropic("claude-sonnet-
|
|
347
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
348
348
|
messages,
|
|
349
349
|
abortSignal: signal,
|
|
350
350
|
onFinish: ({ isAborted }) => {
|
|
@@ -397,7 +397,7 @@ export const myChat = chat.agent({
|
|
|
397
397
|
id: "my-chat",
|
|
398
398
|
run: async ({ messages, signal, streamText }) => {
|
|
399
399
|
return streamText({
|
|
400
|
-
model: anthropic("claude-sonnet-
|
|
400
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
401
401
|
messages,
|
|
402
402
|
tools: { sendEmail },
|
|
403
403
|
abortSignal: signal,
|
|
@@ -636,7 +636,7 @@ export const myChat = chat.agent({
|
|
|
636
636
|
];
|
|
637
637
|
},
|
|
638
638
|
run: async ({ messages, signal, streamText }) => {
|
|
639
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
639
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
640
640
|
},
|
|
641
641
|
});
|
|
642
642
|
```
|
|
@@ -663,7 +663,7 @@ chat.agent({
|
|
|
663
663
|
run: async ({ messages, signal, streamText }) => {
|
|
664
664
|
// Single-response agent — exit after this turn.
|
|
665
665
|
chat.endRun();
|
|
666
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
666
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
667
667
|
},
|
|
668
668
|
});
|
|
669
669
|
```
|
|
@@ -684,7 +684,7 @@ Use this when the agent knows its work is done (budget exhausted, goal achieved,
|
|
|
684
684
|
chat.agent({
|
|
685
685
|
id: "budgeted-agent",
|
|
686
686
|
run: async ({ messages, signal }) =>
|
|
687
|
-
streamText({ model: anthropic("claude-sonnet-
|
|
687
|
+
streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal }),
|
|
688
688
|
// onBeforeTurnComplete carries the same fields as onTurnComplete, including
|
|
689
689
|
// `usage`, and still runs while the response stream is open.
|
|
690
690
|
onBeforeTurnComplete: async ({ chatId }) => {
|
|
@@ -736,7 +736,7 @@ Override how long the run stays suspended waiting for the next message. Call fro
|
|
|
736
736
|
```ts
|
|
737
737
|
run: async ({ messages, signal, streamText }) => {
|
|
738
738
|
chat.setTurnTimeout("2h"); // Wait longer for this conversation
|
|
739
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
739
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
740
740
|
},
|
|
741
741
|
```
|
|
742
742
|
|
|
@@ -747,7 +747,7 @@ Override how long the run stays idle (active, using compute) after each turn:
|
|
|
747
747
|
```ts
|
|
748
748
|
run: async ({ messages, signal, streamText }) => {
|
|
749
749
|
chat.setIdleTimeoutInSeconds(60); // Stay idle for 1 minute
|
|
750
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
750
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
751
751
|
},
|
|
752
752
|
```
|
|
753
753
|
|
|
@@ -781,7 +781,7 @@ export const myChat = chat.agent({
|
|
|
781
781
|
},
|
|
782
782
|
},
|
|
783
783
|
run: async ({ messages, signal, streamText }) => {
|
|
784
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
784
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
785
785
|
},
|
|
786
786
|
});
|
|
787
787
|
```
|
|
@@ -812,7 +812,7 @@ export const myChat = chat.agent({
|
|
|
812
812
|
sendSources: true, // Forward source citations (default: false)
|
|
813
813
|
},
|
|
814
814
|
run: async ({ messages, signal, streamText }) => {
|
|
815
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
815
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
816
816
|
},
|
|
817
817
|
});
|
|
818
818
|
```
|
|
@@ -830,7 +830,7 @@ export const myChat = chat.agent({
|
|
|
830
830
|
generateMessageId: () => uuidv7(),
|
|
831
831
|
},
|
|
832
832
|
run: async ({ messages, signal, streamText }) => {
|
|
833
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
833
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
834
834
|
},
|
|
835
835
|
});
|
|
836
836
|
```
|
|
@@ -850,7 +850,7 @@ export const myChat = chat
|
|
|
850
850
|
.agent({
|
|
851
851
|
id: "my-chat",
|
|
852
852
|
run: async ({ messages, signal, streamText }) => {
|
|
853
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
853
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
854
854
|
},
|
|
855
855
|
});
|
|
856
856
|
```
|
|
@@ -872,7 +872,7 @@ run: async ({ messages, clientData, signal, streamText }) => {
|
|
|
872
872
|
if (clientData.model?.includes("claude")) {
|
|
873
873
|
chat.setUIMessageStreamOptions({ sendReasoning: true });
|
|
874
874
|
}
|
|
875
|
-
return streamText({ model: openai(clientData.model ?? "gpt-
|
|
875
|
+
return streamText({ model: openai(clientData.model ?? "gpt-6-luna"), messages, abortSignal: signal });
|
|
876
876
|
},
|
|
877
877
|
```
|
|
878
878
|
|
|
@@ -901,7 +901,7 @@ export const manualChat = task({
|
|
|
901
901
|
queue: { concurrencyLimit: 10 },
|
|
902
902
|
run: async (payload: ChatTaskPayload) => {
|
|
903
903
|
const result = streamText({
|
|
904
|
-
model: anthropic("claude-sonnet-
|
|
904
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
905
905
|
messages: payload.messages,
|
|
906
906
|
stopWhen: stepCountIs(15),
|
|
907
907
|
});
|
|
@@ -87,7 +87,7 @@ const registry = createProviderRegistry({ anthropic });
|
|
|
87
87
|
|
|
88
88
|
const selfReviewPrompt = prompts.define({
|
|
89
89
|
id: "self-review",
|
|
90
|
-
model: "anthropic:claude-haiku-
|
|
90
|
+
model: "anthropic:claude-haiku-5-5",
|
|
91
91
|
content: `You are a conversation quality reviewer. Analyze the assistant's most recent response.
|
|
92
92
|
|
|
93
93
|
Focus on:
|
|
@@ -107,7 +107,7 @@ export const myChat = chat.agent({
|
|
|
107
107
|
const resolved = await selfReviewPrompt.resolve({});
|
|
108
108
|
|
|
109
109
|
const review = await generateObject({
|
|
110
|
-
model: registry.languageModel(resolved.model ?? "anthropic:claude-haiku-
|
|
110
|
+
model: registry.languageModel(resolved.model ?? "anthropic:claude-haiku-5-5"),
|
|
111
111
|
...resolved.toAISDKTelemetry(),
|
|
112
112
|
system: resolved.text,
|
|
113
113
|
prompt: messages
|
|
@@ -152,7 +152,7 @@ export const myChat = chat.agent({
|
|
|
152
152
|
});
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
The self-review runs on `claude-haiku-
|
|
155
|
+
The self-review runs on `claude-haiku-5-5` (fast, cheap) in the background. If the user sends another message before it completes, the coaching is still injected, because `chat.inject()` persists across the idle wait.
|
|
156
156
|
|
|
157
157
|
## Other use cases
|
|
158
158
|
|
|
@@ -173,7 +173,7 @@ export const myChat = chat.agent({
|
|
|
173
173
|
chat.defer(analytics.track("turn_started", { chatId, runId }));
|
|
174
174
|
},
|
|
175
175
|
run: async ({ messages, signal, streamText }) => {
|
|
176
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
176
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
177
177
|
},
|
|
178
178
|
});
|
|
179
179
|
```
|
|
@@ -200,7 +200,7 @@ export const myChat = chat.agent({
|
|
|
200
200
|
);
|
|
201
201
|
},
|
|
202
202
|
run: async ({ messages, signal, streamText }) => {
|
|
203
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
203
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
204
204
|
},
|
|
205
205
|
});
|
|
206
206
|
```
|
|
@@ -48,7 +48,7 @@ export const myChat = chat.agent({
|
|
|
48
48
|
userContext.messageCount++;
|
|
49
49
|
|
|
50
50
|
return streamText({
|
|
51
|
-
model: anthropic("claude-sonnet-
|
|
51
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
52
52
|
system: `Helping ${userContext.name} (${userContext.plan} plan).`,
|
|
53
53
|
messages,
|
|
54
54
|
abortSignal: signal,
|
|
@@ -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
|
tools: { analyzeData },
|
|
123
123
|
abortSignal: signal,
|
|
@@ -29,7 +29,7 @@ export const myChat = chat.agent({
|
|
|
29
29
|
shouldCompact: ({ totalTokens }) => (totalTokens ?? 0) > 80_000,
|
|
30
30
|
summarize: async ({ messages }) => {
|
|
31
31
|
const result = await generateText({
|
|
32
|
-
model: anthropic("claude-haiku-
|
|
32
|
+
model: anthropic("claude-haiku-5-5"),
|
|
33
33
|
messages: [...messages, { role: "user", content: "Summarize this conversation concisely." }],
|
|
34
34
|
});
|
|
35
35
|
return result.text;
|
|
@@ -84,7 +84,7 @@ export const myChat = chat.agent({
|
|
|
84
84
|
shouldCompact: ({ totalTokens }) => (totalTokens ?? 0) > 80_000,
|
|
85
85
|
summarize: async ({ messages }) => {
|
|
86
86
|
return generateText({
|
|
87
|
-
model: anthropic("claude-haiku-
|
|
87
|
+
model: anthropic("claude-haiku-5-5"),
|
|
88
88
|
messages: [...messages, { role: "user", content: "Summarize." }],
|
|
89
89
|
}).then((r) => r.text);
|
|
90
90
|
},
|
|
@@ -98,7 +98,7 @@ export const myChat = chat.agent({
|
|
|
98
98
|
],
|
|
99
99
|
},
|
|
100
100
|
run: async ({ messages, signal, streamText }) => {
|
|
101
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
101
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
102
102
|
},
|
|
103
103
|
});
|
|
104
104
|
```
|
|
@@ -123,12 +123,20 @@ By default, model messages are replaced with a single summary message. Use `comp
|
|
|
123
123
|
|
|
124
124
|
### Summary + recent context
|
|
125
125
|
|
|
126
|
-
Keep the last few model messages so the LLM has recent detail alongside the summary:
|
|
126
|
+
Keep the last few model messages so the LLM has recent detail alongside the summary. The kept messages now follow a different history, so strip their reasoning: Claude 5.5 models reject thinking blocks whose earlier conversation changed with a 400 (`Invalid signature in thinking block`).
|
|
127
127
|
|
|
128
128
|
```ts
|
|
129
|
+
import type { ModelMessage } from "ai";
|
|
130
|
+
|
|
131
|
+
function stripReasoning(message: ModelMessage): ModelMessage {
|
|
132
|
+
if (message.role !== "assistant" || typeof message.content === "string") return message;
|
|
133
|
+
return { ...message, content: message.content.filter((part) => part.type !== "reasoning") };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ...
|
|
129
137
|
compactModelMessages: ({ modelMessages, summary }) => [
|
|
130
138
|
{ role: "user", content: summary },
|
|
131
|
-
...modelMessages.slice(-2), // Keep last exchange for detail
|
|
139
|
+
...modelMessages.slice(-2).map(stripReasoning), // Keep last exchange for detail
|
|
132
140
|
],
|
|
133
141
|
```
|
|
134
142
|
|
|
@@ -192,7 +200,7 @@ export const myChat = chat.agent({
|
|
|
192
200
|
});
|
|
193
201
|
},
|
|
194
202
|
run: async ({ messages, signal, streamText }) => {
|
|
195
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
203
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
196
204
|
},
|
|
197
205
|
});
|
|
198
206
|
```
|
|
@@ -214,7 +222,7 @@ import { z } from "zod";
|
|
|
214
222
|
// Reusable summarize fn — also used by the automatic compaction config.
|
|
215
223
|
async function summarize(messages: ModelMessage[]) {
|
|
216
224
|
const result = await generateText({
|
|
217
|
-
model: anthropic("claude-haiku-
|
|
225
|
+
model: anthropic("claude-haiku-5-5"),
|
|
218
226
|
messages: [...messages, { role: "user", content: "Summarize this conversation concisely." }],
|
|
219
227
|
});
|
|
220
228
|
return result.text;
|
|
@@ -250,7 +258,7 @@ export const myChat = chat.agent({
|
|
|
250
258
|
},
|
|
251
259
|
|
|
252
260
|
run: async ({ messages, signal, streamText }) => {
|
|
253
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
261
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
254
262
|
},
|
|
255
263
|
});
|
|
256
264
|
```
|
|
@@ -317,7 +325,10 @@ const session = chat.createSession(payload, {
|
|
|
317
325
|
compaction: {
|
|
318
326
|
shouldCompact: ({ totalTokens }) => (totalTokens ?? 0) > 80_000,
|
|
319
327
|
summarize: async ({ messages }) =>
|
|
320
|
-
generateText({
|
|
328
|
+
generateText({
|
|
329
|
+
model: anthropic("claude-haiku-5-5"),
|
|
330
|
+
messages: [...messages, { role: "user", content: "Summarize this conversation concisely." }],
|
|
331
|
+
}).then((r) => r.text),
|
|
321
332
|
compactUIMessages: ({ uiMessages, summary }) => [
|
|
322
333
|
{ id: generateId(), role: "assistant",
|
|
323
334
|
parts: [{ type: "text", text: `[Summary]\n\n${summary}` }] },
|
|
@@ -328,7 +339,7 @@ const session = chat.createSession(payload, {
|
|
|
328
339
|
|
|
329
340
|
for await (const turn of session) {
|
|
330
341
|
const result = streamText({
|
|
331
|
-
model: anthropic("claude-sonnet-
|
|
342
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
332
343
|
messages: turn.messages,
|
|
333
344
|
abortSignal: turn.signal,
|
|
334
345
|
stopWhen: stepCountIs(15),
|
|
@@ -353,7 +364,10 @@ const conversation = new chat.MessageAccumulator({
|
|
|
353
364
|
compaction: {
|
|
354
365
|
shouldCompact: ({ totalTokens }) => (totalTokens ?? 0) > 80_000,
|
|
355
366
|
summarize: async ({ messages }) =>
|
|
356
|
-
generateText({
|
|
367
|
+
generateText({
|
|
368
|
+
model: anthropic("claude-haiku-5-5"),
|
|
369
|
+
messages: [...messages, { role: "user", content: "Summarize this conversation concisely." }],
|
|
370
|
+
}).then((r) => r.text),
|
|
357
371
|
compactUIMessages: ({ summary }) => [
|
|
358
372
|
{ id: generateId(), role: "assistant",
|
|
359
373
|
parts: [{ type: "text", text: `[Summary]\n\n${summary}` }] },
|
|
@@ -365,7 +379,7 @@ for (let turn = 0; turn < 100; turn++) {
|
|
|
365
379
|
const messages = await conversation.addIncoming(payload.messages, payload.trigger, turn);
|
|
366
380
|
|
|
367
381
|
const result = streamText({
|
|
368
|
-
model: anthropic("claude-sonnet-
|
|
382
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
369
383
|
messages,
|
|
370
384
|
prepareStep: conversation.prepareStep(), // Inner-loop compaction
|
|
371
385
|
stopWhen: stepCountIs(15),
|
|
@@ -388,11 +402,17 @@ for (let turn = 0; turn < 100; turn++) {
|
|
|
388
402
|
For maximum control, use `chat.compact()` directly inside a custom `prepareStep`:
|
|
389
403
|
|
|
390
404
|
```ts
|
|
391
|
-
prepareStep: async ({ messages: stepMessages, steps }) => {
|
|
405
|
+
prepareStep: async ({ messages: stepMessages, steps, responseMessages }) => {
|
|
392
406
|
const result = await chat.compact(stepMessages, steps, {
|
|
407
|
+
// On AI SDK 7, pass these so the steps after a compaction are rebuilt
|
|
408
|
+
// with every new tool result. Earlier AI SDK versions don't need them.
|
|
409
|
+
responseMessages,
|
|
393
410
|
threshold: 80_000,
|
|
394
411
|
summarize: async (msgs) =>
|
|
395
|
-
generateText({
|
|
412
|
+
generateText({
|
|
413
|
+
model: anthropic("claude-haiku-5-5"),
|
|
414
|
+
messages: [...msgs, { role: "user", content: "Summarize this conversation concisely." }],
|
|
415
|
+
}).then((r) => r.text),
|
|
396
416
|
});
|
|
397
417
|
return result.type === "skipped" ? undefined : result;
|
|
398
418
|
},
|
|
@@ -404,7 +424,10 @@ Or use the `chat.compactionStep()` factory:
|
|
|
404
424
|
prepareStep: chat.compactionStep({
|
|
405
425
|
threshold: 80_000,
|
|
406
426
|
summarize: async (msgs) =>
|
|
407
|
-
generateText({
|
|
427
|
+
generateText({
|
|
428
|
+
model: anthropic("claude-haiku-5-5"),
|
|
429
|
+
messages: [...msgs, { role: "user", content: "Summarize this conversation concisely." }],
|
|
430
|
+
}).then((r) => r.text),
|
|
408
431
|
}),
|
|
409
432
|
```
|
|
410
433
|
|
|
@@ -109,7 +109,7 @@ export const myChat = chat
|
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
const result = streamText({
|
|
112
|
-
model: anthropic("claude-sonnet-
|
|
112
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
113
113
|
messages: turn.messages,
|
|
114
114
|
abortSignal: turn.signal,
|
|
115
115
|
stopWhen: stepCountIs(15),
|
|
@@ -230,7 +230,7 @@ For more control, you can do each step manually:
|
|
|
230
230
|
```ts
|
|
231
231
|
for await (const turn of session) {
|
|
232
232
|
const result = streamText({
|
|
233
|
-
model: anthropic("claude-sonnet-
|
|
233
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
234
234
|
messages: turn.messages,
|
|
235
235
|
abortSignal: turn.signal,
|
|
236
236
|
stopWhen: stepCountIs(15),
|
|
@@ -267,7 +267,7 @@ and aborts that turn as normal.
|
|
|
267
267
|
```ts trigger/my-chat.ts
|
|
268
268
|
for await (const turn of session) {
|
|
269
269
|
const result = streamText({
|
|
270
|
-
model: anthropic("claude-sonnet-
|
|
270
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
271
271
|
messages: turn.messages,
|
|
272
272
|
abortSignal: turn.signal, // fires on a user stop OR a run cancel
|
|
273
273
|
stopWhen: stepCountIs(15),
|
|
@@ -442,7 +442,7 @@ export const myChat = chat.customAgent({
|
|
|
442
442
|
const combinedSignal = AbortSignal.any([runSignal, stop.signal]);
|
|
443
443
|
|
|
444
444
|
const result = streamText({
|
|
445
|
-
model: anthropic("claude-sonnet-
|
|
445
|
+
model: anthropic("claude-sonnet-5-5"),
|
|
446
446
|
messages,
|
|
447
447
|
abortSignal: combinedSignal,
|
|
448
448
|
stopWhen: stepCountIs(15),
|
|
@@ -38,7 +38,7 @@ export const myChat = chat.agent({
|
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
run: async ({ messages, signal, streamText }) => {
|
|
41
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
41
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
42
42
|
},
|
|
43
43
|
});
|
|
44
44
|
```
|
|
@@ -74,7 +74,7 @@ export const myChat = chat.agent({
|
|
|
74
74
|
await db.chat.update({ where: { id: chatId }, data: { messages: uiMessages } });
|
|
75
75
|
},
|
|
76
76
|
run: async ({ messages, signal, streamText }) => {
|
|
77
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
77
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
78
78
|
},
|
|
79
79
|
});
|
|
80
80
|
```
|
|
@@ -142,7 +142,7 @@ chat.agent({
|
|
|
142
142
|
});
|
|
143
143
|
},
|
|
144
144
|
run: async ({ messages, signal, streamText }) => {
|
|
145
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
145
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
146
146
|
},
|
|
147
147
|
});
|
|
148
148
|
```
|
|
@@ -174,7 +174,7 @@ chat.agent({
|
|
|
174
174
|
}
|
|
175
175
|
},
|
|
176
176
|
run: async ({ messages, signal, streamText }) => {
|
|
177
|
-
return streamText({ model: anthropic("claude-sonnet-
|
|
177
|
+
return streamText({ model: anthropic("claude-sonnet-5-5"), messages, abortSignal: signal });
|
|
178
178
|
},
|
|
179
179
|
});
|
|
180
180
|
```
|