test(cloudflare): Add e2e test app for @cloudflare/think - #24660
Draft
RulaKhaled wants to merge 1 commit into
Draft
RulaKhaled wants to merge 1 commit into
RulaKhaled wants to merge 1 commit into
Conversation
Records what a Think agent produces with the current SDK, before any Think-specific code exists. The worker imports no Sentry API at all: `sentryCloudflareVitePlugin()` detects `class ThinkAgent extends Think` and wraps the export at build time, and `ai` publishes the telemetry `vercelAIIntegration` already consumes. Covers the same five things the other AI apps do: the gen_ai hierarchy, a tool throw becoming an issue with an errored span, a manual span nesting under the tool span, the provider request staying inside the turn, and `dataloader` proving the orchestrion transform reaches a bundled worker. Runs on `ai` v7 by default with a v6 lane as an optional variant, because Think's peer range spans both and the two produce different trace shapes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
size-limit report 📦
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
cloudflare-thinke2e app that records what a Think agent produces with the SDK as it stands today, before any Think-specific code exists. Same shape asnode-eveandcloudflare-mastra.The setup is the whole point: the worker imports no Sentry API at all.
sentryCloudflareVitePlugin()detectsextends Thinkand wraps the export at build time, andaipublishes the telemetryvercelAIIntegrationalready consumes. Options come fromsrc/instrument.server.tsby convention.What works today
One turn produces
gen_ai.invoke_agent, agen_ai.generate_contentper step andgen_ai.execute_tool, correctly nested, all with originauto.vercelai.channel. Token usage is right per step and rolls up onto the agent span, and prompts, tool arguments and results, tool definitions and finish reasons are all present.A tool throw becomes an issue with mechanism
auto.vercelai.channeland marks only its own span errored, leaving the model callsok. A manualSentry.startSpaninside a tool nests under that tool's span.dataloaderspans land in the same trace, which is worth noting: the orchestrion module transform reaches a bundled Think worker with no--importbootstrap, unlike the Node apps.What does not
The provider HTTP call nests under
gen_ai.generate_contentonaiv7 but is a sibling of it on v4 to v6. That difference is ours: only v7's native channel binds the model-call span into async context. Asserted per lane so the gap is recorded rather than hidden.The agent span is named from
this.constructor.name, which the Vite plugin's class rename currently mangles intoinvoke_agent __SENTRY_ORIGINAL_ThinkAgent__. Not asserted here. A follow-up fixes it and adds the assertion.There is no
gen_ai.agent.name, and none of thecloudflare.agents.turn.*context Think supplies (agent id, Durable Object conversation id, turn trigger, continuation) reaches a span. Think sends all of it, asruntimeContexton v7 andexperimental_telemetry.metadataon v6, and neither subscriber reads either field.Notes
sentryTest.optional: truekeeps this in the optional matrix likenode-eve, since it makes real OpenRouter calls. The v6 lane rides along as anoptionalVariantsentry rather than a second app.E2E_OPENROUTER_API_KEYis already wired inbuild.ymlfrom the eve PR, so CI needs no change.ref JS-3568
🤖 Generated with Claude Code