Skip to main content

AnoSys SDK for Claude Agents

Automatically trace Claude Agent SDK runs and send them to AnoSys: agents, tools, subagents, tokens and cost.

Installation

Requires Python 3.10 or later.

pip install anosys-sdk-claude-agents

Quick Start

import asyncio
from anosys_sdk_claude_agents import AnosysClaudeAgentsLogger

# Initialize once, before importing query (instruments query() and ClaudeSDKClient)
AnosysClaudeAgentsLogger()

from claude_agent_sdk import ClaudeAgentOptions, query

async def main():
    options = ClaudeAgentOptions(allowed_tools=["Bash", "Read"])
    async for message in query(prompt="List the Python files here", options=options):
        print(message)

asyncio.run(main())

ClaudeSDKClient is traced too: each receive_response() produces one agent run.

If query was imported before the logger was created, wrap it explicitly:

from anosys_sdk_claude_agents import wrap_query
query = wrap_query(query)

For other message streams, use trace_messages(stream, prompt=..., options=...).

Options

AnosysClaudeAgentsLogger(
    get_user_context=lambda: {"session_id": "abc", "token": "user-token"},
    agent_name="support_agent",   # gen_ai.agent.name (default "claude_agent")
    capture_content=True,          # prompts, results, tool input/output (default)
    emit_llm_spans=False,          # one chat span per assistant response
    use_batch_processor=False,
)

What Data is Captured?

The Agent SDK runs the model inside a Claude Code subprocess, so the integration builds spans from the messages the run yields:

Span Name Carries
Agent (root) invoke_agent <agent_name> session id (gen_ai.conversation.id), model, prompt, system prompt, final result, total tokens (including cache), cost (cvn7), turns
Tool execute_tool <tool> tool name and call id, input, output, errors
Subagent execute_tool Task subagent type as gen_ai.agent.name; the subagent's tool calls are nested under it
LLM (opt-in) chat <model> per-response model, stop reason, usage

Token and cost totals live on the agent span. When emit_llm_spans is on, chat spans also carry per-call usage, so sum one or the other, not both.

The run span is the active span while the SDK works, so the Claude Code subprocess inherits the trace context (TRACEPARENT).

Records are tagged cvs200 = "ClaudeAgentsTelemetry" and use the same columns as anosys-sdk-anthropic. See MAPPINGS.md.

Environment Variables

Variable Required Description
ANOSYS_API_KEY Yes Your AnoSys API key
ANTHROPIC_API_KEY Yes Your Anthropic API key (used by Claude Code)

License

Apache 2.0

Content controls

See the content-controls reference for encryption coverage, default columns, size limits, and limitations. Encryption is opt-in and applies to selected string fields; it does not encrypt the complete record.

Collection follows one level for every AnoSys SDK: ANOSYS_COLLECTION_LEVEL=full (default), metadata (no prompts, completions or tool data) or off, a project .anosys file can only lower it, and ANOSYS_DISABLE=1 stops all sending. Without an API key nothing is sent. Telemetry is sent in the background and never delays your calls. See the data-collection policy.

Metadata

Release files for anosys-sdk-claude-agents 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anosys-sdk-claude-agents 1.1.0
File Size Uploaded Provenance Actions
anosys_sdk_claude_agents-1.1.0.tar.gz 24.6 kB Without provenance Details for anosys_sdk_claude_agents-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for anosys-sdk-claude-agents 1.1.0
File Interpreter ABI Platform Actions
anosys_sdk_claude_agents-1.1.0-py3-none-any.whl Python 3 none any Details for anosys_sdk_claude_agents-1.1.0-py3-none-any.whl

Total release size: 46.1 kB

Release files / anosys_sdk_claude_agents-1.1.0.tar.gz

Download URL anosys_sdk_claude_agents-1.1.0.tar.gz
Size 24.6 kB
Tags Source
SHA-256 checksum
How to use checksums
932bf6bf6fdd4ff57026e9f3fbd1512e5da0c43dc545dfc042705c5d660df999
BLAKE2b-256 checksum
How to use checksums
aaea3e716fef70337b3bd7800f003f6c367cbe47dc5b092a8d1a8965be5b6565
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / anosys_sdk_claude_agents-1.1.0-py3-none-any.whl

Download URL anosys_sdk_claude_agents-1.1.0-py3-none-any.whl
Size 21.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cea7eb603f1bbf962c337b71f35d3ac54ef98d721dbdbb59db8757efd1970da2
BLAKE2b-256 checksum
How to use checksums
ea19a8a3ec35c9dab7093e24986b50914a31afdfe299577b6f1138bd9f0ba316
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for anosys-sdk-claude-agents 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page