Agent execution tracing and economic event emission.
Project description
agentmeter
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
369ed97bc3ba6c5205f851d643855364ebb27fc213535445448645541dc1bc90
|
|
| MD5 |
6d5a4a60ee44868965a28cc38b9db202
|
|
| BLAKE2b-256 |
80eff9cc46e072f82d596ea2fe27cafb39891921ca6745eda1429aaf39b2ece4
|
File details
Details for the file agentmeter_caleb12-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agentmeter_caleb12-0.1.0-py3-none-any.whl
- Upload date:
- Size: 40.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94da19168bd43c671b459f92e892c33eda5d799c8e5d719cd2252f1d462615a5
|
|
| MD5 |
afa988020f3bd877bdc54ad517bedd69
|
|
| BLAKE2b-256 |
ff25c99e2f40a155a3f5a7ff4b42eeebe9d3c422045000b8ca60ee26194175a7
|