AgentAssay: Token-Efficient Regression Testing for Non-Deterministic AI Agent Workflows
Organizations: Independent Researcher
Abstract
Autonomous AI agents are deployed at unprecedented scale, yet no principled methodology exists for verifying that an agent has not regressed after changes to its prompts, tools, models, or orchestration logic. We present AgentAssay, the first token-efficient framework for regression testing non-deterministic AI agent workflows, achieving 78-100% cost reduction while maintaining rigorous statistical guarantees. Our contributions include: (1) stochastic three-valued verdicts (PASS/FAIL/INCONCLUSIVE) grounded in hypothesis testing; (2) five-dimensional agent coverage metrics; (3) agent-specific mutation testing operators; (4) metamorphic relations for agent workflows; (5) CI/CD deployment gates as statistical decision procedures; (6) behavioral fingerprinting that maps execution traces to compact vectors, enabling multivariate regression detection; (7) adaptive budget optimization calibrating trial counts to behavioral variance; and (8) trace-first offline analysis enabling zero-cost testing on production traces. Experiments across 5 models (GPT-5.2, Claude Sonnet 4.6, Mistral-Large-3, Llama-4-Maverick, Phi-4), 3 scenarios, and 7,605 trials demonstrate that behavioral fingerprinting achieves 86% detection power where binary testing has 0%, SPRT reduces trials by 78%, and the full pipeline achieves 100% cost savings through trace-first analysis. Implementation: 20,000+ lines of Python, 751 tests, 10 framework adapters.
Figures & tables
| Feature | AgentAssay | agentrial | deepeval | promptfoo | METAL | ProbTest |
|---|---|---|---|---|---|---|
| Multi-step agent workflows | ✓ | ✓ | — | — | — | — |
| Stochastic verdicts | ✓ | — | — | — | ||
| Formal test semantics | ✓ | — | — | — | — | |
| Confidence intervals | ✓ | ✓ | — | — | — | — |
| Regression detection | ✓ | ✓ | — | — | — | — |
| SPRT adaptive stopping | ✓ | — | — | — | — | — |
| Test Type | Offline? | Soundness | Live Cost |
|---|---|---|---|
| Coverage analysis | Yes | Lower bound | $0 |
| Contract checking | Yes | Sound | $0 |
| Metamorphic relations | Yes | Sound (unbiased) | $0 |
| Mutation testing | Partial | Evaluator only | $0 |
| SPRT regression | No | Sound | Reduced by Pillars 1–2 |
| Deployment gate | Hybrid | Sound | Reduced |
| Component | Lines of Code |
|---|---|
| Core Engine (statistics, verdicts) | 3,092 |
| Coverage Analyzer | 844 |
| Mutation & Metamorphic Engine | 3,710 |
| Token-Efficient Engine | 2,324 |
| Framework Adapters (10 frameworks) | 4,469 |
| Infrastructure (CLI, dashboard, persistence) | 5,644 |
| Model | Trials | Tokens/Trial | Cost/Trial | Latency (ms) |
|---|---|---|---|---|
| GPT-5.2 | 1,050 | $0.0009 | ||
| Sonnet 4.6 | 1,050 | $0.0018 | ||
| Mistral-Large-3 | 1,050 | $0.0033 | ||
| Llama-4-Maverick | 1,050 | $0.0000 | ||
| Phi-4 | 1,050 | $0.0000 |
| Approach | Mean Trials | Mean Cost | Savings | Power |
|---|---|---|---|---|
| Fixed- (baseline) | \0.287\pm 0.184$ | — | 0.00 | |
| SPRT | \0.064\pm 0.042$ | 77.6% | 0.00 | |
| SPRT + Fingerprint | \0.059\pm 0.038$ | 79.5% | 0.86 | |
| SPRT + FP + Budget | \0.058\pm 0.038$ | 79.7% | 0.86 | |
| Full system | \0.000\pm 0.000$ | 100.0% | 0.94 |
| Model | Fixed- | SPRT (savings) | Full (savings) |
|---|---|---|---|
| GPT-5.2 | $0.127 | $0.028 (78%) | $0.000 (100%) |
| Sonnet 4.6 | $0.196 | $0.043 (78%) | $0.000 (100%) |
| Mistral-L3 | $0.338 | $0.076 (77%) | $0.000 (100%) |
| Llama-4-Maverick | $0.000 | $0.000 (N/A) | $0.000 (N/A) |
| Scenario | Fixed- Cost | SPRT Savings | Full Savings |
|---|---|---|---|
| E-commerce | $0.170 | 77.7% | 100% |
| Customer Support | $0.372 | 77.5% | 100% |
| Code Generation | $0.174 | 78.2% | 100% |