Catch silent cost surges and broken agent loops before they ship.

Your agent returned the right answer, but took 5 extra steps and burned 3× the tokens. AgentDiff catches silent tool loops, cost surges, and execution drift in CI before your PR lands in production.

Try in 5 Minutes
$ pip install agent-trajectory-diff
FAIL
$ agentdiff traces/baseline.json runs/candidate_pr.json --fail-on-regression

Automated PR checks · Blocks broken runs before code merges

The Testing Dilemma

Your unit tests are green.Your agent is silently burning money.

Traditional assertions only check if the final output string matched. They are blind to execution drift — missing recursive tool loops, unverified prompt detours, and 3× cost surges before code merges.

Standard Assertion (test_agent.py)Passed in 0.42s
# Pytest assertion checks final string output
response = customer_agent.run("account 402")
assert "Total Balance: $4,200" in response.text
The final sentence contained the expected balance, so your CI pipeline turned green and approved the merge.
Assertion Result:1 passed, 0 warnings
AgentDiff Trajectory GateExit Code 1 · Blocked
# Graph alignment detected 3 redundant retry cycles
01 authenticate · 42ms
02 fetch_customer_data · 180ms
↻ loop detected: fetch_customer_data ×3 (+148% tokens)
03 generate_summary · 520ms
AgentDiff caught the hidden 3× loop in 5ms, halting the PR before the cost spike reached production.
Gate Verdict:Blocked (TDI 0.428 · Limit 0.250)
01 · The Problem

Final output looks fine

The agent still delivered the expected summary, so standard assertion tests pass easily in CI.

02 · The Hidden Bug

3× redundant API calls

Behind the scenes, a prompt tweak caused the agent to loop 3 times over the customer database.

03 · The AgentDiff Gate

Instant merge block

AgentDiff detects the step surge in milliseconds and fails the PR before it ever costs you real money.

How It Works

From git commit to merge gate.

No complex dashboards or cloud databases. AgentDiff operates as a pure, deterministic regression engine directly in your terminal and CI/CD pipeline.

01Local CLI

Record Golden Baseline

One command snapshots the graph.

Run your agent on a verified test dataset. AgentDiff records its execution graph, tool call sequences, and token budget into a committed JSON file in your repository.

$ agentdiff record tests/golden.json
02CI Pipeline

Align & Diff on Every PR

Sub-10ms graph comparison.

When an engineer refactors a prompt or upgrades a model, AgentDiff aligns the candidate execution against the baseline in GitHub Actions without calling any paid LLM judges.

$ agentdiff golden.json pr.json
03Merge Gate

Block Regressions with Exit Code 1

Zero broken agents in production.

If the PR agent enters an infinite retry loop, drifts off its path, or surges token cost, the build halts immediately and an automated root-cause comment is posted to the PR.

Exit Code 1 · 3× loop on execute_sql
Native adapters for LangGraph, OpenAI Agents, CrewAI, and OpenTelemetry.Get started in 5 minutes
Core Capabilities

Built for engineering teams shipping agentic AI to production.

Deterministic gates designed to protect four things: your monthly token budget, user latency, graph consistency, and engineering confidence.

01BUDGET PROTECTION

Token & Cost Surge Gating

Never let a prompt refactor double your LLM bill.

Enforce strict safety budgets (e.g. max +10% token overhead). If a new prompt variant or model version burns more tokens than your baseline, AgentDiff fails the PR immediately.

Average blocked cost spike+148%
02STAGNATION PREVENTION

Infinite Tool Loop Interception

Kill repetitive polling cycles before they reach production.

Isolates cyclical execution loops where an agent calls the same endpoint with identical parameters without state progress — stopping runaway recursive loops before merge.

Zero-tolerance CI threshold0 Loops
03RELIABILITY ASSURANCE

Silent Model Fork Detection

Know the exact step where a new model diverged.

When you upgrade from GPT-4o to o3 or Gemini, AgentDiff mathematically aligns both execution graphs to verify whether the agent followed your golden path or hallucinated an unverified detour.

Deterministic graph alignment100%
04ENGINEERING VELOCITY

Sub-10ms Automated CI Runs

Evaluations without third-party judge latency or API fees.

Unlike LLM-as-a-judge evaluators that cost $0.05 per test and take 15 seconds, AgentDiff runs air-gapped on raw AST graphs in single-digit milliseconds.

Fast enough for pre-commit hooks< 5ms
Want the full mathematical formulas and graph alignment proofs?Explore Engine Specifications & Math
Automated CI/CD Feedback

Instant root-cause diagnosis right in GitHub PRs.

Engineers never have to hunt through raw terminal logs or third-party web apps. AgentDiff posts an actionable diagnostic comment directly to the Pull Request review timeline.

acme-corp/customer-support-agentPublic
Code Issues Pull requests4

refactor(prompt): parse customer records with new schema #42

Openalex-chen wants to merge 1 commit into main from feat/parse-schema
AD
agentdiff-botbotcommented 2 minutes ago

⛔ AgentDiff · Trajectory Regression Check (Exit Code 1)

Candidate execution trajectory breached regression tolerances against golden baseline.

GateMeasuredThresholdVerdict
TDI (Trajectory Divergence)0.4285≤ 0.2500❌ FAIL
Stagnant Tool Retries3 loops0 loops❌ FAIL
Token Budget Delta+148.2%≤ 10.0%❌ FAIL
Root Cause Culprit

execute_sql node repeated 3 consecutive times with identical parameters without state progress.

Divergence Tree
1 · authenticate
2 · execute_sql
3 + execute_sql (↻ loop repetition 1)
4 + execute_sql (↻ loop repetition 2)
5 + execute_sql (↻ loop repetition 3)
6 · generate_summary
All checks have failed
1 failing and 2 successful checksagentdiff-gate failed
agentdiff / evaluate-trajectory (push)
Failed in 4.2ms
AgentDiff GitHub Action v0.1.0 installed across 12 repos
View workflow runsDocumentation
Universal Ecosystem Ingestion

Works with your existing agent stack. Zero code rewrite.

You shouldn’t have to re-architect your codebase to protect your agents. AgentDiff connects directly to your existing telemetry formats and framework runtimes.

LangGraph

LangGraph

State Checkpoint DAGs
StateGraph & Cyclical Subgraphs

Ingest native JSON trace dumps from LangGraph directly into AgentDiff's deterministic regression engine. Sub-5ms parsing speed, zero telemetry lock-in, and full DAG verification.

Zero custom SDK or decorator changes
Deterministic sub-5ms graph alignment
Runs locally and in GitHub Actions
Instant CLI Diff Command
agentdiff golden.json pr_run.json --adapter langgraph
test_langgraph_regression.pyPure Python SDK
# Ingest native LangGraph Checkpoints with zero instrumentation
from agentdiff import load_trace, compare

baseline  = load_trace("runs/langgraph_golden.json")
candidate = load_trace("runs/langgraph_pr.json")

# Compare execution paths across cycles & tool nodes
report = compare(baseline, candidate)
assert report.stagnant_loops == 0
Auto-detects format from JSON payloadView all adapters
Stack Architecture

Where AgentDiff fits in your stack.

AgentDiff doesn’t replace observability platforms or LLM judges. It completes your modern AI stack by filling the critical missing layer: instant, deterministic regression gates in CI.

Pre-Merge Gate (CI/CD)100% Deterministic

AgentDiff

The missing unit test for execution trajectories.

Evaluates PR candidate runs against committed golden baselines in under 5ms. Blocks infinite loops, prompt drift, and token surges before code reaches production.

Execution Speed< 5ms
EnforcementExit Code 0 / 1 (Hard Block)
Offline EvaluationSemantic Scoring

LLM-as-a-Judge

Subjective quality and tone grading.

Evaluates nuances like politeness, formatting, and hallucination on offline test suites. High latency, non-deterministic scores, and API costs make it unsuited as a hard CI gate.

Execution Speed15s - 60s
EnforcementProbabilistic Score (0.0 - 1.0)
Post-Deploy MonitoringLive Telemetry

Observability (OTel / Langfuse)

Production user traffic and debugging.

Captures live production spans, distributed traces, and latency charts. Vital for debugging what happened after an outage, but cannot prevent broken PRs from deploying.

Execution SpeedPost-Hoc
EnforcementAlerts & Dashboards
Leading engineering teams run AgentDiff in CI, LLM Judges offline, and OTel in production.Explore Architecture Guide
Frequently Asked Questions

Everything you need to know.

Deterministic agent regression testing demystified. If you have any other questions, our engineering docs and GitHub discussions are always open.

LLM judges score semantic nuance (e.g. 'Is this response polite?') via expensive, non-deterministic model calls that take 15–60 seconds. AgentDiff evaluates the structural execution DAG (tool sequence order, retry loops, wasted token deltas) in sub-5ms using pure graph algorithms. It gives you an instant, deterministic Exit Code 0 or 1 for your CI/CD pipeline.
Have a unique custom framework or telemetry format?Ask in GitHub Discussions
Ready to Deploy

Stop agent regressions before they merge.

Install in seconds. Compare candidate executions against golden baselines, block infinite tool loops, and protect your token budget on every PR.

MIT LicensedZero Cloud DependenciesSub-5ms Graph Alignment
bash
PyPI Release
$pip install agent-trajectory-diff
.github/workflows/ci.ymlCI Gate
- name: Run AgentDiff Gate
  uses: agentdiff/action@v1
  with:
    baseline: tests/golden_baseline.json
    max-divergence: 0.25