Skip to main content
Adrian instruments the Anthropic SDK directly, for agents that call messages.create rather than going through a framework. Every call on both anthropic.Anthropic and anthropic.AsyncAnthropic is captured as a PairedEvent and streamed to the Adrian backend. Your call sites stay unchanged. This ships inside the Python SDK rather than as a separate package, so configuration, callbacks, and the PairedEvent schema are shared with the LangChain integration and documented there.

Install

Requires Python 3.12+. The extra pins a supported anthropic version. Plain pip install adrian-sdk also works, since the instrumentation patches whichever anthropic your project already depends on. If the package is absent, Adrian skips Anthropic patching and everything else continues as normal.

Initialise

init and shutdown bracket your normal Anthropic code.
For synchronous code use adrian.anthropic_invocation_sync(). An invocation is Adrian’s unit of work. A single Anthropic call is not one, so wrap related calls to group them under a shared invocation_id.
Calls made outside an invocation are still captured, but carry invocation_id="no_invocation" and cannot be correlated with each other.

Streaming

Text deltas stream through untouched. The event is emitted when the final message is requested.

Enforcement modes

The agent profile’s execution mode is set in the dashboard and pushed to the SDK in the LoginAck frame. See Severity codes for what each MAD code means. Under Block and Human Review, a halted tool call never reaches your execution loop. Halted blocks are rewritten to a text block reading [BLOCKED by security policy], and stop_reason is downgraded from tool_use to end_turn so agentic loops terminate cleanly.
The gate fails closed. If no LoginAck arrives within 5s all tool calls are blocked, and in Block mode a verdict timeout blocks the tool call.

Manual instrumentation

init() patches the Anthropic SDK automatically. To control when that happens:
Patching is idempotent and safe to call more than once.

What’s captured

Each call produces one PairedEvent with pair_type="llm". LlmPairData carries the model, the flattened message list including the system prompt, the output text, requested tool_calls, and token usage. Content blocks are normalised to strings, so a tool_use block appears as [tool_use: name args={...}] in the message text. Agent identity is derived from the system prompt, since the Anthropic SDK exposes no framework-level agent boundary. Two agents sharing a system prompt share an agent_id.