Catalog PyPI
Back to packageRELEASE DETAILS

0.2.0

PyPI

agentmetrics-anthropic

AgentMetrics observability integration for Claude Managed Agents

agentmetricsai-agentsanthropicclaudemanaged-agentsobservability
Published20 Jun 2026
Direct dependencies3
Transitive dependenciesNot calculated

README

Version 0.2.0 documentation

agentmetrics-anthropic

PyPI License: MIT

AgentMetrics integration for Claude Managed Agents (Python). Wrap your session event stream with one tracker and every session reports back to your dashboard when it terminates showing latency, cost, token counts with cache, tool calls, and errors.


Install

pip install agentmetrics-anthropic

Quickstart

import anthropic
from agentmetrics_anthropic import AgentMetricsSessionTracker

client  = anthropic.Anthropic()
tracker = AgentMetricsSessionTracker(
    agent_id="my-claude-agent",
    base_url="http://localhost:8099",
)

# Sync stream
with tracker.stream(client, session_id="sess_...") as stream:
    for event in stream:
        pass  # handle events as normal

tracker.flush()

Async

async with tracker.astream(client, session_id="sess_...") as stream:
    async for event in stream:
        pass

await tracker.flush()

API

AgentMetricsSessionTracker(agent_id, base_url)

ParameterDefaultDescription
agent_id"anthropic-agent"Label shown in the dashboard
base_url"http://localhost:8099"AgentMetrics server address

.stream(client, session_id, **kwargs)

Returns a sync context manager. Yields the same events as client.beta.sessions.events.stream(). Emits a run summary on session.status_terminated.

.astream(client, session_id, **kwargs)

Async version of .stream().

.flush(timeout=10.0)

Blocks until all in-flight HTTP requests complete. Call before process exit.


What gets tracked

Each session emits one event to /v1/events when it terminates:

FieldDescription
statussuccess or failed
duration_msWall-clock session duration
input_tokens / output_tokensAggregated across all LLM calls
cache_read_tokens / cache_write_tokensCache token counts
llm_callsNumber of LLM requests in the session
tool_calls / tool_errorsTool usage counts
tool_namesSet of tools invoked
modelModel name from the first LLM call
estimated_cost_usdComputed from token counts and model pricing
errorFirst 500 chars of the error message on failure

License

MIT

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 3

Native requirements
3 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
agentmetrics-shared
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
agentmetrics-shared>=0.2.0runtime
agentmetrics
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
agentmetrics>=0.2.0runtime
anthropic
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
anthropic>=0.49.0runtime

Distribution files

2 collected
agentmetrics_anthropic-0.2.0-py3-none-any.whl

bdist_wheel · 4.76 KB · Python py3

Source file
agentmetrics_anthropic-0.2.0.tar.gz

sdist · 4.27 KB · Python source

Source file

Repository

PENDING
andalabx/agentmetrics

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:43 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:d2e5affdb74e2e8576c82d22f1cde0fa38a7f746ececc9d511b28d2791b38dfa

Other collected versions

View all collected versions →