Integration Overview
Use this integration when your application runs Claude Agent SDK queries through@anthropic-ai/claude-agent-sdk. Asymptote Observe can wrap the query function to create a Beacon-compatible root span for each agent turn.
Overview
Claude Agent SDK integration is currently a query wrapper, not a custom hook adapter. UseObserve.wrapClaudeAgentQuery() when module loading prevents provider-level instrumentation or when you want a stable root span around an agent query.
For direct Anthropic API calls through @anthropic-ai/sdk, use Anthropic.
What Asymptote Captures
- A
claude_agent_sdk.queryspan for wrapped query calls. beacon.harness.name=claude_agent_sdk.beacon.event.action=prompt.submittedandbeacon.event.category=prompt.- Prompt text from the first string argument or common object fields such as
prompt,input, andquery. - Errors recorded on failed spans.
Prerequisites
- Node.js 20 or newer.
@asymptote/sdkinstalled.@anthropic-ai/claude-agent-sdkinstalled.ASYMPTOTE_API_KEYset for Asymptote Managed hosted Observe, orOTEL_EXPORTER_OTLP_ENDPOINTset for customer-managed OTLP export. To get an Asymptote Managed API key, reach out for a demo.
Install the SDK and Claude Agent SDK
Set the Asymptote Managed API key
Getting Started
Wrap the query function before using it.Wrap a Claude Agent SDK query
Prompt Detection
wrapClaudeAgentQuery() records the first string argument as beacon.prompt.text. If the first argument is an object, it checks common prompt fields such as prompt, input, and query.
Prompt detection examples
Patch Module Exports
If you prefer patching the module object, pass it throughinstrumentModules during initialization.
Patch the Claude Agent SDK module
Observe.wrapClaudeAgentQuery().
Group Agent Work
UseObserve.observe() around your entrypoint when one request combines Claude Agent SDK queries with other application work.
Group Claude agent work under a parent span
Troubleshooting
- Confirm
ASYMPTOTE_API_KEYorOTEL_EXPORTER_OTLP_ENDPOINTis set in the same process that runs the SDK. - Make sure application code calls the wrapped
queryfunction, not the original import. - If module patching does not work in an ESM namespace, use
Observe.wrapClaudeAgentQuery()explicitly. - Call
Observe.flush()before short-lived scripts or jobs exit.
What’s Next
Anthropic
Instrument direct Anthropic provider calls.
Observe
Wrap additional agent steps and tool calls.

