Summary
Under zero config (sentryCloudflareVitePlugin()), a wrapped class reports its name as __SENTRY_ORIGINAL_<Name>__ at runtime. Anything that reads Class.name shows that placeholder: a @cloudflare/think agent span reads invoke_agent __SENTRY_ORIGINAL_ThinkAgent__ with gen_ai.function_id to match, and agents puts it in gen_ai.agent.name. Applies to every class the plugin wraps (Durable Objects, Agents, Workflows, WorkerEntrypoints). Manual instrument*WithSentry is unaffected.
Root cause
packages/cloudflare/src/vite/transform.ts frees the export binding for the wrapper by renaming the user's class declaration:
class __SENTRY_ORIGINAL_ThinkAgent__ extends Think {}
export const ThinkAgent = instrumentAgentWithSentry(opts, __SENTRY_ORIGINAL_ThinkAgent__);
Renaming a declaration changes Function.prototype.name. Think passes this.constructor.name to the AI SDK as functionId, which the vercel-ai subscriber uses as the span name.
Fix: leave the declaration alone and alias the export instead, the shape the plugin already emits for cross-module re-exports and the docs show for manual wrapping:
class ThinkAgent extends Think {}
const __SENTRY_WRAPPED_ThinkAgent__ = instrumentAgentWithSentry(opts, ThinkAgent);
export { __SENTRY_WRAPPED_ThinkAgent__ as ThinkAgent };
Environment
@sentry/cloudflare 10.67.0, @cloudflare/vite-plugin 1.57.2
@cloudflare/think 0.19.0, ai 7, agents 0.24
- Reproduced on a local worker with the
cloudflare-think e2e app
Summary
Under zero config (
sentryCloudflareVitePlugin()), a wrapped class reports its name as__SENTRY_ORIGINAL_<Name>__at runtime. Anything that readsClass.nameshows that placeholder: a@cloudflare/thinkagent span readsinvoke_agent __SENTRY_ORIGINAL_ThinkAgent__withgen_ai.function_idto match, andagentsputs it ingen_ai.agent.name. Applies to every class the plugin wraps (Durable Objects, Agents, Workflows, WorkerEntrypoints). Manualinstrument*WithSentryis unaffected.Root cause
packages/cloudflare/src/vite/transform.tsfrees the export binding for the wrapper by renaming the user's class declaration:Renaming a declaration changes
Function.prototype.name. Think passesthis.constructor.nameto the AI SDK asfunctionId, which the vercel-ai subscriber uses as the span name.Fix: leave the declaration alone and alias the export instead, the shape the plugin already emits for cross-module re-exports and the docs show for manual wrapping:
Environment
@sentry/cloudflare10.67.0,@cloudflare/vite-plugin1.57.2@cloudflare/think0.19.0,ai7,agents0.24cloudflare-thinke2e app