Local-first observability + eval for AI agents: trace runs, detect loops, render an HTML report. No backend.
Project description
🔎 agentlens
Local-first observability + eval for AI agents.
Capture every step your agent takes — thoughts, tool calls, tokens, latency, errors — automatically detect when it gets stuck in a loop, and render the whole run to a self-contained HTML report. No backend, no account, no cloud. The core is stdlib-only.
Working name. Easy to rename.
Site: a static landing page + docs live in site/ — open
site/index.html in a browser (no build step).
Why
Most agent tools either (a) only score the final answer, missing mistakes that
happen mid-run, or (b) require a hosted dashboard (Postgres + ClickHouse, an
account, a cloud). agentlens is the opposite: one trace object, many
lenses, running entirely on your laptop.
Install (dev)
pip install -e .
Quick start
from agentlens_eval import Tracer, detect_loops
from agentlens_eval.report import generate_html
tracer = Tracer("my-agent")
with tracer.step("user wants the weather") as step:
step.tool_call("get_weather", {"city": "NYC"},
result="72F", tokens=120, latency_ms=800)
warnings = detect_loops(tracer.trace)
generate_html(tracer.trace, "report.html", warnings=warnings, open_browser=True)
Or just run the demo:
python example.py # writes report.html
What's in the box (v0.3)
- Tracing —
Tracer/Step/Trace; latency timed automatically. - Loop detection — consecutive and frequent repeated tool calls.
- HTML trace report — timeline, per-step tool calls, totals, loop warnings.
- Eval layer — cheap, deterministic metrics (
Contains,Regex,Equals,ToolWasCalled,MaxSteps,MaxTokens,NoErrors,NoLoops) plus anEval/Caserunner that produces apass_rateyou can gate CI on, and an HTML eval report with per-case pass/fail. - LLM-as-judge — opt-in
LLMJudge("criteria")for grading open-ended outputs with Claude. It's the only metric that costs tokens, so the rest of your suite stays cheap and deterministic.
from agentlens_eval import Eval, Case, metrics
report = Eval("my-agent", my_agent).run([
Case("weather in NYC", [metrics.Contains("72"), metrics.ToolWasCalled("get_weather")]),
])
report.summary()
assert report.pass_rate == 1.0 # CI gate
See example_eval.py for a full dataset.
pytest integration
Run your evals as normal tests — one pass/fail row per case:
from agentlens_eval import Case, metrics
from agentlens_eval.testing import parametrize, check
DATASET = [Case("weather in NYC", [metrics.Contains("72")], name="weather")]
@parametrize(DATASET)
def test_agent(case):
check(my_agent, case).assert_passed()
pytest -v # tests/test_agent_eval.py::test_agent[weather] PASSED
Or gate a whole run: Eval(...).run(dataset).assert_passed(min_pass_rate=0.9).
Roadmap
The whole design is layers over the same Trace:
- More agent checks — premature termination, plan drift, expected-trajectory match.
- Dev UX — JSON export + run-to-run regression diff, framework adapters (raw
callable, Anthropic, OpenAI, LangChain),
agentlens.wrap(client)one-line auto-capture. - Packaging — publish to PyPI as
pip install agentlens-eval(the bareagentlensname is taken, so the distribution isagentlens-evalwhile the import staysagentlens_eval).
License
MIT
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 agentlens_eval-0.3.0.tar.gz.
File metadata
- Download URL: agentlens_eval-0.3.0.tar.gz
- Upload date:
- Size: 37.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0abb3a8ba380a7d19b931815a4419f10f73da6639ade8e61fddb8e515c505b85
|
|
| MD5 |
c2cc85fcb625e134fb0c6817c293d40b
|
|
| BLAKE2b-256 |
a48ada3e19ddd2d903dc4e39de82b9097dc1ccfefe61488594c020542cc551a2
|
File details
Details for the file agentlens_eval-0.3.0-py3-none-any.whl.
File metadata
- Download URL: agentlens_eval-0.3.0-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbc7678fee447a84e0484191a8de0ff9622ed893319c4967d50dd8253e756988
|
|
| MD5 |
4b7e2498b03598b7d86d6a512ef70a34
|
|
| BLAKE2b-256 |
15ece3a5ca306a1161022537957d208b764ad2b7660eb8feeadddb1c1a279217
|