Skip to main content

Trajectory-level evaluation for LLM agents

Project description

AgentLens

Trajectory-level evaluation for LLM agents. Zero dependencies, five metrics, one score.

📦 Live on TestPyPI: test.pypi.org/project/agentlens — install with pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ agentlens

Current tools (LangSmith, Langfuse, etc.) give you logging. AgentLens gives you scores.

When an LLM agent runs, it produces a trajectory — a sequence of thoughts, tool calls, observations, and a final answer. Knowing whether that trajectory was actually correct is hard: Did it call the right tools? With the right arguments? Did it wander in loops? Did it finish the task at all? AgentLens answers all of that with a single evaluate() call.

trajectory (list of steps)
        │
        ▼
   AgentLens.evaluate()
        │
        ▼
EvaluationReport
  ├─ tool_accuracy_score      — did it call the right tools?
  ├─ argument_fidelity_score  — did it call them with the right arguments?
  ├─ trajectory_length_score  — did it solve the task efficiently?
  ├─ completion_score         — did it actually finish the task?
  └─ failure_taxonomy         — what went wrong, categorised

Install

Currently published on TestPyPI (real PyPI release pending):

pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ agentlens

Zero required dependencies. Optional extras for framework integrations:

pip install agentlens[langchain]   # LangChain agent parsing
pip install agentlens[openai]      # OpenAI function-calling parsing

Quickstart

from agentlens import Trajectory, Step, evaluate

trajectory = Trajectory(
    task="Find the latest JAX release and summarize the changelog",
    steps=[
        Step(step_type="thought", content="I need to search for JAX releases"),
        Step(step_type="tool_call", content="", tool_name="search",
             tool_args={"query": "JAX latest release"}),
        Step(step_type="observation", content="JAX 0.4.30 released on July 2026..."),
        Step(step_type="final_answer",
             content="The latest JAX release is 0.4.30, released July 2026."),
    ],
    final_answer="The latest JAX release is 0.4.30, released July 2026.",
)

report = evaluate(
    trajectory=trajectory,
    expected_tools=["search"],
    expected_calls=[{"tool_name": "search", "expected_args": {"query": "JAX latest release"}}],
    optimal_steps=4,
    completion_keywords=["JAX", "release"],
)

print(report)
print(report.overall_score)   # 0.9-ish
print(report.failures)        # []
AgentLens Evaluation Report
========================================
  Overall Score         : 0.93
  Tool Accuracy         : 1.00
  Argument Fidelity     : 0.70
  Trajectory Efficiency : 1.00
  Completion            : 1.00

  No failures detected.
========================================

Export to JSON for dashboards, CI gates, or logging pipelines:

report.to_json()

Run it yourself: python examples/basic_evaluation.py


The five metrics

Metric Question it answers Signal
Tool Accuracy Did the agent call the tools it was supposed to? expected_tools matched against tools actually called
Argument Fidelity Were those tools called with the right arguments? exact + fuzzy match against expected_calls
Trajectory Length Did it solve the task efficiently? optimal_steps / actual_steps, capped at 1.0
Completion Did it actually finish? binary, or keyword coverage of the final answer
Failure Taxonomy When it broke, why? WRONG_TOOL, MISSING_TOOL, BAD_ARGS, LOOP, NO_COMPLETION, HALLUCINATED_TOOL

overall_score is a weighted average: 0.3 × tool_accuracy + 0.3 × argument_fidelity + 0.2 × trajectory_length + 0.2 × completion.


Framework integrations

Already using LangChain or OpenAI function calling? Don't hand-build trajectories — parse them straight out of the agent's own output.

LangChain

from agentlens.integrations.langchain import from_langchain

result = agent_executor.invoke({"input": task})
trajectory = from_langchain(result, task=task)
report = evaluate(trajectory, expected_tools=["search"])

OpenAI function calling

from agentlens.integrations.openai import from_openai_messages

trajectory = from_openai_messages(messages, task=task)
report = evaluate(trajectory, expected_tools=["search"])

Design principles

  • Zero required dependencies. A library that requires nothing to install is a library people actually install. LangChain/OpenAI support is opt-in via extras.
  • Framework-agnostic core. Trajectory and Step are plain dataclasses — build them from any agent framework, or by hand.
  • Scores, not logs. AgentLens doesn't replace your tracing tool; it turns a trajectory you already captured into a number you can gate CI on.

Development

pip install -e ".[dev]"
pytest

License

MIT

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

agentrubric-0.1.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

agentrubric-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agentrubric-0.1.0.tar.gz
Algorithm Hash digest
SHA256 49d591dad1b60d42b28b6f93754703e87929f8b8deb67896c8561e6911521f3e
MD5 22517426fcc2ebdb95abc161a1cec025
BLAKE2b-256 00a6e28c0eb97d14f8935ac3edfd644fde354a721ff17b51fafe8d61d56f7a5f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: agentrubric-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for agentrubric-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 542eac65ebc29a96102c2e7a7f4d6f6a4006d74245c3f51b75d34a76df73e348
MD5 dab2da0dbb9722314daaec949fe0209a
BLAKE2b-256 9650b6501e4b97a486fb04356c93263aa0b27d1a87073c857bb6291b0061632d

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