-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
docs(vercelai): Align types based on implementation #18752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,7 @@ _Import name: `Sentry.vercelAIIntegration`_ | |
|
|
||
| The `vercelAIIntegration` adds instrumentation for the [`ai`](https://www.npmjs.com/package/ai) SDK by Vercel to capture spans using the [`AI SDK's built-in Telemetry`](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry). | ||
|
|
||
| <PlatformSection notSupported={["javascript.cloudflare", "javascript.nextjs"]}> | ||
| <PlatformSection notSupported={["javascript.cloudflare", "javascript.deno", "javascript.nextjs"]}> | ||
| It is enabled by default and will automatically capture spans for all `ai` | ||
| function calls. You can opt-in to capture inputs and outputs by setting `recordInputs` and `recordOutputs` in the integration config: | ||
|
|
||
|
|
@@ -63,7 +63,7 @@ Sentry.init({ | |
|
|
||
| </PlatformSection> | ||
|
|
||
| <PlatformSection supported={['javascript.cloudflare']}> | ||
| <PlatformSection supported={['javascript.cloudflare', 'javascript.deno']}> | ||
| This integration is not enabled by default. You need to manually enable it by passing `Sentry.vercelAIIntegration()` to `Sentry.init`: | ||
|
|
||
| ```javascript | ||
|
|
@@ -89,7 +89,7 @@ Sentry.init({ | |
|
|
||
| </PlatformSection> | ||
|
|
||
| <PlatformSection supported={['javascript.cloudflare', 'javascript.nextjs']}> | ||
| <PlatformSection supported={['javascript.cloudflare', 'javascript.deno', 'javascript.nextjs']}> | ||
| To correctly capture spans, pass the `experimental_telemetry` object with `isEnabled: true` to every `generateText`, `generateObject`, `streamText`, and `ToolLoopAgent` call. For more details, see the [AI SDK Telemetry Metadata docs](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry#telemetry-metadata). | ||
|
|
||
| ```javascript | ||
|
|
@@ -105,9 +105,23 @@ const result = await generateText({ | |
|
|
||
| </PlatformSection> | ||
|
|
||
| <PlatformSection notSupported={['javascript.cloudflare']}> | ||
| ## Options | ||
|
|
||
| ### `enableTruncation` | ||
|
|
||
| _Type: `boolean`_ | ||
|
|
||
| Enables or disables truncation of recorded input messages. Truncation keeps large payloads within span size limits. | ||
|
|
||
| Defaults to `true`. | ||
|
|
||
| ```javascript | ||
| Sentry.init({ | ||
| integrations: [Sentry.vercelAIIntegration({ enableTruncation: false })], | ||
| }); | ||
| ``` | ||
|
|
||
| <PlatformSection notSupported={['javascript.cloudflare', 'javascript.deno']}> | ||
| ### `force` | ||
|
|
||
| Requires SDK version `9.29.0` or higher. | ||
|
|
@@ -129,7 +143,9 @@ Sentry.init({ | |
| forced when it is enabled. | ||
| </PlatformSection> | ||
|
|
||
| <PlatformSection notSupported={['javascript.nextjs']}> | ||
| </PlatformSection> | ||
|
|
||
| <PlatformSection notSupported={['javascript.cloudflare', 'javascript.nextjs']}> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Documentation for the Vercel AI integration incorrectly shows Deno users the Suggested FixAdd Prompt for AI Agent |
||
| ### `recordInputs` | ||
|
|
||
| Requires SDK version `9.27.0` or higher. | ||
|
|
@@ -164,19 +180,35 @@ Sentry.init({ | |
|
|
||
| </PlatformSection> | ||
|
|
||
| <PlatformSection supported={['javascript.cloudflare']}> | ||
| ### `recordInputs` and `recordOutputs` | ||
|
|
||
| Setting `recordInputs` and `recordOutputs` on the integration is only supported with AI SDK v7 or higher through the <PlatformLink to="/features/nodejs-compat">`@sentry/cloudflare/nodejs_compat`</PlatformLink> entrypoint. On the default entrypoint, Sentry only post-processes spans the AI SDK already emitted and can't decide whether inputs and outputs are recorded. | ||
|
|
||
| To control input and output recording on the default entrypoint, set `experimental_telemetry.recordInputs` and `experimental_telemetry.recordOutputs` directly on each `ai` function call (for example, `generateText`), not on the Sentry integration (see [Configuration](#configuration)). | ||
|
|
||
| ```javascript | ||
| // Only in the `@sentry/cloudflare/nodejs_compat` entrypoint (AI SDK v7+) | ||
| Sentry.init({ | ||
| integrations: [ | ||
| Sentry.vercelAIIntegration({ recordInputs: true, recordOutputs: true }), | ||
| ], | ||
| }); | ||
| ``` | ||
|
|
||
| </PlatformSection> | ||
|
|
||
| ## ToolLoopAgent | ||
|
|
||
| The integration also captures spans for the [`ToolLoopAgent`](https://ai-sdk.dev/docs/agents/overview#toolloopagent-class) class. Each call to `generate()` or `stream()` creates an agent span with individual LLM requests and tool executions as child spans. | ||
|
|
||
| <PlatformSection notSupported={["javascript.cloudflare", "javascript.nextjs"]}> | ||
| <PlatformSection notSupported={["javascript.cloudflare", "javascript.deno", "javascript.nextjs"]}> | ||
|
|
||
| No additional configuration is needed — `ToolLoopAgent` spans are captured automatically. | ||
|
|
||
| </PlatformSection> | ||
|
|
||
| <PlatformSection supported={['javascript.cloudflare', 'javascript.nextjs']}> | ||
| <PlatformSection supported={['javascript.cloudflare', 'javascript.deno', 'javascript.nextjs']}> | ||
|
|
||
| Pass `experimental_telemetry` with `isEnabled: true` to the `ToolLoopAgent` constructor to correctly capture spans: | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The documentation for
recordInputsincorrectly implies support for Deno, breaking the pattern where Deno and Cloudflare have parallel feature support.Severity: LOW
Suggested Fix
To ensure consistency, add
'javascript.deno'to thenotSupportedarray for therecordInputssection invercelai.mdx. This will align its documented support with that of Cloudflare, as is done for other options in the file.Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.