Skip to main content

Agent execution tracing and economic event emission.

Project description

agentmeter

CI PyPI version License: MIT OpenInference compatible

agentmeter instruments multi-agent AI systems to track execution cost, latency, and outcome at the span level - giving you the economic signal your traces are missing.

Multi-agent systems fail silently and spend invisibly. LangSmith and Phoenix show you what happened. agentmeter tells you what it cost, what failed, and how it compares.

Quickstart

from agentmeter import Tracer, SpanKind, configure
def retrieve(q: str) -> list[str]:
    return ["doc-a"]
configure(log_path="./agentmeter_logs/run.jsonl")
tracer = Tracer("my-planner", SpanKind.AGENT)
with tracer.span("my-retriever", SpanKind.RETRIEVER) as s:
    docs = retrieve("change-order status")
    s.set_cost(0.0002)
    s.set_outcome("success")
print(f"Total cost: ${tracer.finish().total_cost_usd:.4f}")

SpanKind Reference

Name OpenInference-compatible Cost driver Example
LLM Yes (llm) prompt + completion tokens draft a summary
CHAIN Yes (chain) orchestration overhead + downstream calls run a multi-step chain
RETRIEVER Yes (retriever) vector/DB lookup count and latency fetch top-k documents
TOOL Yes (tool) external API/runtime call cost OCR a PDF
AGENT Yes (agent) planning + delegated subcalls route task to workers
EMBEDDING Yes (embedding) embedding model tokens embed a document chunk
RERANKER Yes (reranker) reranker model inference rerank candidate passages
GUARDRAIL Yes (guardrail) policy/model checks schema and safety gate
EVALUATOR Yes (evaluator) evaluation model/runtime calls score answer quality

Configuration

from agentmeter import configure

configure()  # silent stdout default
configure(silent=False)  # print JSON events to stdout
configure(log_path="./agentmeter_logs/run.jsonl")  # JSONL file output

Data Model

ExecutionTrace is the immutable top-level record for one execution and includes execution_id, root_agent_id, started_at, ended_at, outcome, and spans, plus computed total_cost_usd and total_latency_ms. Each Span captures span_id, parent_span_id, caller_agent_id, callee_agent_id, capability, timestamps, token counts, cost_usd, outcome, and optional error_message/metadata. AgentIdentity stores persistent identity fields (agent_id, capability, version, tags, created timestamp) for cross-run attribution.

OpenInference Compatibility

agentmeter SpanKinds align with the OpenInference specification used by Arize Phoenix and LangSmith. Traces can be compared against industry benchmarks using the same vocabulary.

Contributing

Contributions are welcome, especially around tracer integrations, emitter backends, and model validation hardening. Changes to SpanKind require discussion before merge because it is part of the public API and affects downstream compatibility.

License

MIT

agentmeter

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentmeter_caleb12-0.1.0.tar.gz (43.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentmeter_caleb12-0.1.0-py3-none-any.whl (40.3 kB view details)

Uploaded Python 3

File details

Details for the file agentmeter_caleb12-0.1.0.tar.gz.

File metadata

  • Download URL: agentmeter_caleb12-0.1.0.tar.gz
  • Upload date:
  • Size: 43.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for agentmeter_caleb12-0.1.0.tar.gz
Algorithm Hash digest
SHA256 369ed97bc3ba6c5205f851d643855364ebb27fc213535445448645541dc1bc90
MD5 6d5a4a60ee44868965a28cc38b9db202
BLAKE2b-256 80eff9cc46e072f82d596ea2fe27cafb39891921ca6745eda1429aaf39b2ece4

See more details on using hashes here.

File details

Details for the file agentmeter_caleb12-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agentmeter_caleb12-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94da19168bd43c671b459f92e892c33eda5d799c8e5d719cd2252f1d462615a5
MD5 afa988020f3bd877bdc54ad517bedd69
BLAKE2b-256 ff25c99e2f40a155a3f5a7ff4b42eeebe9d3c422045000b8ca60ee26194175a7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page