agentlog-llm
Trace AI agent execution — LLM calls, tool calls, costs and latency. Zero dependencies.
pip install agentlog-llm
The Problem
Agentic AI systems make multiple LLM calls, use tools, make decisions — all invisibly. When something goes wrong (or costs too much), you have no idea what happened inside.
agentlog-llm gives you a complete execution trace — every LLM call, every tool use, every decision — with costs, latency, and token counts.
Quick Start
from agentlog import AgentTracer
tracer = AgentTracer("my-agent", task="Summarize documents")
# Log an LLM call
with tracer.llm_call("openai", "gpt-4o", prompt="Summarize this...") as call:
response = openai_client.chat(...)
call.response = response.text
call.tokens_in = response.usage.prompt_tokens
call.tokens_out = response.usage.completion_tokens
# Log a tool call
with tracer.tool_call("web_search", inputs={"query": "AI news"}) as tool:
result = search("AI news")
tool.output = result
# Log a decision
tracer.log("Decided to summarize top 3 results only")
# Finish and get trace
trace = tracer.finish(success=True)
print(trace.summary())
Output:
{
"trace_id": "a1b2c3d4",
"agent": "my-agent",
"task": "Summarize documents",
"steps": 3,
"llm_calls": 1,
"tool_calls": 1,
"total_tokens": 1250,
"total_cost_usd": 0.00425,
"total_latency_ms": 2340.5,
"success": True
}
Decorator Support
@tracer.trace_tool("calculator")
def calculate(expression: str) -> float:
return eval(expression)
# Tool call is automatically logged
result = calculate("2 + 2")
Export
# As dict
data = tracer.to_dict()
# As JSON string
json_str = tracer.to_json()
# Save to file
tracer.save("trace.json")
AgentTrace Properties
trace.total_llm_calls # Number of LLM calls
trace.total_tool_calls # Number of tool calls
trace.total_tokens # Total tokens used
trace.total_cost_usd # Total cost in USD
trace.total_latency_ms # Total latency in ms
trace.llm_calls # List of LLMCall objects
trace.tool_calls # List of ToolCall objects
trace.summary() # Dict summary
License
MIT
Metadata
Release files for agentlog-llm 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agentlog_llm-0.1.0.tar.gz | 7.5 kB | Without provenance | Details for agentlog_llm-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agentlog_llm-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for agentlog_llm-0.1.0-py3-none-any.whl |
Total release size: 14.1 kB
Release files / agentlog_llm-0.1.0.tar.gz
| Download URL | agentlog_llm-0.1.0.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8508769258e0edf5094631b125a45fe3ee2b65e5f43d582ebb69f544ed157a93
|
|
BLAKE2b-256 checksum How to use checksums |
e7a13a8591228225fc2bda32b6ad31ab66d6758ee28b06c358896b26c712a520
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / agentlog_llm-0.1.0-py3-none-any.whl
| Download URL | agentlog_llm-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
414756128df51af6fac7680900ba5660d806f93eb33be70bbb92e0d5760e3d93
|
|
BLAKE2b-256 checksum How to use checksums |
a6e72129fe6ab38b4135a8bd14c3afad3a3de1e94844caed1ffe832086286fc7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for agentlog-llm 0.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.