docs(cloudflare): Update Cloudflare docs, also suggest new entrypoint#298
Conversation
c5edfa8 to
2cb1201
Compare
| content: m.parts | ||
| .filter((p) => p.type === "text") | ||
| .map((p) => p.text) | ||
| .join(""), | ||
| })), | ||
| }); | ||
|
|
There was a problem hiding this comment.
Bug: The onChatMessage example incorrectly uses env.AI.run() and returns a static JSON response, but the agent requires a streaming response, which will break chat functionality.
Severity: CRITICAL
Suggested Fix
Update the example to use the canonical pattern for streaming responses. This involves replacing env.AI.run() with a streaming API like streamText() from the Vercel AI SDK and returning its streaming output, potentially using helpers like convertToModelMessages().
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: src/references/sdks/cloudflare/tracing.md#L170-L176
Potential issue: The documentation example for `AIChatAgent.onChatMessage` demonstrates
an incorrect implementation. It uses `env.AI.run()` and returns a static JSON response
via `new Response(JSON.stringify(result))`. However, the `onChatMessage` handler is
designed to work with streaming responses, and the `AIChatAgent` expects a streaming
response to function correctly. Following the current example will result in a
non-functional chat agent because the client-side infrastructure expects a data stream,
not a single JSON payload. The canonical pattern involves using a streaming API like
`streamText()` from the Vercel AI SDK.
| ); | ||
| ``` | ||
|
|
||
| > **Deprecated:** the explicit `Sentry.instrumentD1WithSentry(env.DB)` wrapper still works but is **deprecated and will be removed in v11**. Access `env.DB` directly instead — it's instrumented automatically. |
There was a problem hiding this comment.
idk if this needs to be part of the reference, hopefully the agent catches the deprecated flag running typecheck or it's lsp
There was a problem hiding this comment.
This is the reference: https://github.com/getsentry/sentry-for-ai/pull/298/changes#diff-970a25bab0eb084745c1721a1579059748f1dc23f2aa169a3d6ed441809af469R318
The reference you added is solely for removals if users have Sentry.instrumentD1WithSentry set. It is just not necessary anymore.
This is now in sync with the docs.
This also adds the
enableRpcTracePropagationflag (and is also the recommended approach).