Skip to main content

AnoSys SDK for Claude Agents

License: Apache 2.0 Python

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

Installation

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

Metadata

Release files for anosys-sdk-claude-agents 1.0.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.0.0
File Size Uploaded Provenance Actions
anosys_sdk_claude_agents-1.0.0.tar.gz 23.6 kB Without provenance Details for anosys_sdk_claude_agents-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 44.7 kB

Release files / anosys_sdk_claude_agents-1.0.0.tar.gz

Download URL anosys_sdk_claude_agents-1.0.0.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
957d6a9834444a896a51916c2b35ee774fc6054302fcf0f368739c276f0bb713
BLAKE2b-256 checksum
How to use checksums
6b38335a437b6dd6de172db5f1b57c2a2f35ea11c984fb6a046fcbcefeb83087
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.0.0-py3-none-any.whl

Download URL anosys_sdk_claude_agents-1.0.0-py3-none-any.whl
Size 21.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2adc832053feff421bf105638d18dc83cfdf83928242c628125b9a6842d8f95a
BLAKE2b-256 checksum
How to use checksums
a8c614122ad0f40067fbc53984448cb5d089261664e572c9247f4943add06ca9
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.0.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.0.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