feat(cloudflare): Enable AI v7 support for Cloudflare in the /nodejs_compat entrypoint#21917
feat(cloudflare): Enable AI v7 support for Cloudflare in the /nodejs_compat entrypoint#21917JPeer264 wants to merge 2 commits into
Conversation
d6415d8 to
32490ef
Compare
| warnings: [], | ||
| }), | ||
| }), | ||
| prompt: 'How much is the fish?', |
| @@ -0,0 +1,57 @@ | |||
| /** | |||
| * This is a copy of the Vercel AI integration from the Cloudflare SDK. | |||
There was a problem hiding this comment.
This reads a bit confusing, we are in the cloudflare sdk.
There was a problem hiding this comment.
Ya, I rephrased that 10 times - was never happy. Maybe I specify the entrypoint
There was a problem hiding this comment.
Yeah, I'd specify the tracing path, doesn't have to be the exact path of the integration.
| enableTruncation?: boolean; | ||
| } | ||
|
|
||
| const _vercelAIIntegration = ((options: VercelAiOptions = {}) => { | ||
| const inner = serverUtilsVercelAiIntegration(options); | ||
| const instrumentation = cloudflareVercelAIIntegration(options); | ||
|
|
||
| return { | ||
| ...inner, | ||
| ...instrumentation, | ||
| }; |
There was a problem hiding this comment.
Bug: The VercelAiOptions interface is missing recordInputs and recordOutputs, preventing users from configuring these settings and causing TypeScript compilation errors.
Severity: MEDIUM
Suggested Fix
Update the VercelAiOptions interface in packages/cloudflare/src/nodejs_compat/integrations/tracing/vercelai.ts to include the optional recordInputs?: boolean and recordOutputs?: boolean properties. This will align it with the underlying server-utils integration and allow users to configure these settings directly.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: packages/cloudflare/src/nodejs_compat/integrations/tracing/vercelai.ts#L13-L28
Potential issue: The `VercelAiOptions` interface in the new `nodejs_compat` Vercel AI
integration is incomplete. It only exposes the `enableTruncation` option, while omitting
`recordInputs` and `recordOutputs`. This creates a discrepancy with the underlying
`serverUtilsVercelAiIntegration`, which does support these options. As a result, users
attempting to configure input or output recording at the integration level (e.g.,
`vercelAIIntegration({ recordInputs: false })`) will encounter a TypeScript compilation
error. This prevents users from controlling data recording for Vercel AI v7 through the
public API, limiting the integration's configurability.
Did we get this right? 👍 / 👎 to inform future reviews.
size-limit report 📦
|

re-implementing #21793 with tests, but in the
/nodejs_compatentrypoint. The docs will be updated to clarify that AI v7 would only work in this entrypoint. I didn't want to name the integration differently, as then, the "drop-in replacement" would not work properly.The majority of the PR is tests, and the actual code implementation is just a copy from the base entrypoint including #21793.
Test info
Unfortunately AI v7 cannot be installed as cloudflare-integration-test dependency, as it requires Node v22. It forced me to add 2 e2e-tests instead.
The test matrix is as follows:
nodejs_als(cloudflare-integration-test)nodejs_compat(cloudflare-integration-test)nodejs_als(e2e-test, confirming that it doesn't work)nodejs_compat(e2e-test)If v7 support would be added by accident to the base entrypoint, then the Vercel AI v6 with
nodejs_alswill fail. That should have prevented #21793 to exist actually.