Evaluation Harness for LLM Agents

Ships production agent evaluation.

Stop guessing whether your agents are getting worse. Capture trajectories, score them with three parallel metrics, detect regressions with statistical rigor, and visualize the full decision DAG—all offline, all local, all in one harness.

Agent Decision DAG Prompt Tool A Tool B Tool C Parallel Scoring Tool Accuracy 1.0 Semantic Similarity 0.94 Faithful -ness 0.89 ✓ PASS (all thresholds met)

The Problem with Agent Evals

Tool-using agents fail in ways end-to-end answer checks miss. An agent can produce plausible final text while calling the wrong tool, skipping required lookups, or hallucinating facts. You ship the agent confident it works. A week later, a prompt change degrades performance without warning. You have no idea why, and no way to catch it fast.

AgentBench replaces guessing with data. It intercepts every tool call your agent makes, scores the entire trajectory—not just the final answer—and flags regressions before they reach production.

What You Get

Production Results

100%
Pass Rate (Good Run)
75%
Degraded Run (Detected)
9 Runs
Full History Tracked

Real demo results: Good agent runs achieve 100% pass rate (all metrics 1.0). Degraded prompt drops to 75% with z-score regressions flagged automatically. Broken agent (wrong tools) fails as expected. You see all three scenarios instantly in the dashboard timeline.

Demo Results

This is what shipped. Nine runs, 36 scored results, four scenarios. Good agent, degraded variant, broken variant. Full history in SQLite. Dashboard renders all three at once.

Scenario Runs Passed Tool Acc. Semantic Faithfulness
weather_austin 9 8 (89%) 0.89 0.88 0.89
company_lookup 9 8 (89%) 0.89 0.87 0.89
company_tax 9 6 (67%) 0.89 0.86 0.33
order_status 9 8 (89%) 0.89 0.87 0.89

How It Works

Clean, modular pipeline. Load scenarios from YAML. Intercept tool calls. Score in parallel. Persist to SQLite. Detect regressions with statistics. Visualize in Streamlit. No magic, no dependencies beyond what you already have.

The Pipeline

AgentBench follows a linear but flexible path from test case definition to visual regression detection:

1. Scenario Loading

Parse YAML test cases into Pydantic models. Define the prompt, expected tool call sequence, gold output text, grounding context, and custom pass thresholds for each metric. One scenario file per test case.

2. Trajectory Interception

Non-invasive LangChain tool wrapping. When your agent calls a tool, the interceptor records it as a DAG node: tool name, input arguments, returned output, latency in milliseconds, reasoning traces, token counts, timestamps. Each node links to its parents, building the full decision tree.

3. Parallel Scoring

Three metrics computed concurrently via ThreadPoolExecutor. Tool-call accuracy (Levenshtein edit distance on expected vs actual sequences), semantic similarity (sentence-transformers embeddings + cosine), faithfulness (claim grounding against context). All three must pass their scenario thresholds for the run to pass.

4. Regression Detection

Z-score analysis against rolling 30-run history. For each metric, compute mean and standard deviation. Current value flagged if z ≤ -1.5σ (configurable). Keeps track of degradation even when total pass rate stays high.

5. SQLite Persistence

Four tables: runs (metadata, model name, prompt version, timestamps), trajectories (full DAG JSON), results (per-scenario scores and pass/fail), regressions (flagged anomalies with z-scores). Query any of it offline. No external database needed.

6. Streamlit Dashboard

Interactive UI with KPI strip, per-scenario pass-rate bars, box plots for metric distributions, regression scatter with -1.5σ reference line, score timeline, and expandable raw results table. Filter by model name, prompt version, or scenario. One command to launch: agentbench dashboard.

The Three Metrics Explained

1. Tool-Call Accuracy

Compares the sequence of tools your agent called against the sequence it was supposed to call. Each tool invocation is normalized to (tool_name, arguments). Levenshtein distance measures how many edits (insertions, deletions, substitutions) are needed to transform actual into expected. Score = 1 - (distance / max_length), clipped to [0, 1]. Catches wrong tool calls, skipped steps, extra steps. A score of 1.0 means perfect tool usage.

2. Semantic Similarity

Embeds the agent's final answer and the gold output separately using all-MiniLM-L6-v2 (sentence-transformers). Computes cosine similarity. Catches answers that say the right thing in different words, and answers that say the wrong thing in confident language. Ranges 0 to 1. A score of 1.0 is bit-for-bit identical meaning.

3. Faithfulness (Claim Grounding)

Splits the answer into claim-like sentences. For each claim, checks if it's supported by either the context provided in the scenario or the outputs from the tools the agent called. Support measured by token overlap ≥ 0.4 or fuzzy trigram containment. Score = supported_claims / total_claims. Catches hallucinations, made-up facts, statements without grounding. A score of 1.0 means every claim is verifiable in the context.

Decision DAG Model

Each tool call becomes a node in a directed acyclic graph. Every node stores:

The full trajectory aggregates all nodes plus final_output, total_tokens, model/prompt labels, and metadata. You can reconstruct the agent's exact thought process from the DAG: which tools it called, in what order, with what results.

Evaluation Methodology

Here's the exact sequence for each scenario:

  1. Load — Parse YAML into a Pydantic Scenario object with prompt, expected_calls, expected_output, context, and pass_thresholds.
  2. Instrument — Create TrajectoryInterceptor; agent wraps its LangChain tools through it.
  3. Execute — Agent runs; every tool call becomes a ToolCallNode linked via parent_ids (chain DAG).
  4. Finalize — Capture final natural-language answer; stamp finished_at.
  5. Score (parallel) — ThreadPoolExecutor computes three metrics concurrently.
  6. Gate — Scenario passes if ALL three metrics meet their thresholds (AND logic).
  7. Persist — Save trajectory + result to SQLite; compare metrics to rolling history; write regression flags if z ≤ -1.5.
  8. Summarize — CLI prints pass rate and per-scenario breakdown; optional JSON export to data/last_run.json.

Regression Detection in Depth

The regression detector is statistical and tolerant. For each metric in each scenario:

Why z-score instead of just watching pass rate? A prompt change might drop semantic similarity from 0.98 to 0.94 while keeping pass rate at 100% (if threshold is 0.85). You'd miss it with binary pass/fail tracking. AgentBench catches that decline before it becomes a cascade.

Get It Running

Five minutes to your first eval. Bundled demo agent, four YAML scenarios, seeded SQLite history, full Streamlit dashboard.

python -m venv .venv source .venv/bin/activate pip install -e ".[dev]" agentbench seed agentbench run --model demo-agent --prompt-version v1 agentbench run --agent-mode degraded --model demo-agent --prompt-version v2 agentbench dashboard pytest -q

Note: See data/last_run.json for CI-friendly JSON summary of latest run.

Plug In Your Agent

The protocol is clean. No modifications to AgentBench source needed. Wrap your LangChain tools with the interceptor, run your agent, record reasoning, return the final answer. Results write to SQLite immediately. Dashboard picks them up on refresh.

from agentbench.harness import EvaluationHarness, HarnessConfig from agentbench.interceptor import TrajectoryInterceptor def my_agent(scenario, interceptor): tools = interceptor.wrap_tools(my_tools) # ... run your agent ... interceptor.record_reasoning(thoughts, token_count=n) return final_answer harness = EvaluationHarness( my_agent, HarnessConfig(model_name="gpt-4.1", prompt_version="v3") ) summary = harness.run()

What Comes Next

v0.1.0 ships the core. Here's what's coming to make it even stronger:

Real LLM runners

First-class OpenAI/Anthropic adapters via [openai] extra; record true chain-of-thought and token usage from production models.

CI quality gates

GitHub Action integration to run agentbench run and fail PRs on pass-rate regressions or new flags.

Richer faithfulness

Optional NLI / LLM-judge entailment scoring instead of token overlap; smarter claim decomposition.

Branching DAGs

Capture parallel tool fan-out instead of linear parent chaining for more complex agentic patterns.

More scenarios

Multi-hop retrieval, refusal/safety testing, ambiguous tool choice, latency/cost budgets.

Compare mode

A/B dashboard for model_name × prompt_version side-by-side metric inspection.

Export & observability

HTML/PDF report generation from runs; OpenTelemetry trace integration for production environments.

Ship agents with confidence.

AgentBench v0.1.0 is ready now. Install locally, wire in your LangChain agent, run the demo, and build your regression history. No external services. No dependencies beyond Python. Catch degradation before production.

Get Started on GitHub