Empirical Lyapunov Stability: Growth-Ratio Energy Functions as Leading Indicators of Agent Task Failure
Abstract
In our prior theoretical work [1], we proposed a physics-inspired framework for governing the semantic boundary layer of multi-agent AI systems, drawing on Lyapunov stability theory, Renormalization Group compression, and Vector Symbolic Architectures. That framework was mathematically grounded but untested.
Here we test it with a 5-condition ablation (3,175 runs in total) that isolates each mechanism’s contribution, repeated SWE-bench trials (333 runs) to measure run-to-run variance, and runs on 5 model families, 4 of them open-weight local models.
We implement the proposed framework as state-harness, a hybrid Rust/Python runtime safety library, and evaluate it across four complementary benchmarks: τ³-bench [2] (customer-service agents, 750 runs), SWE-bench Verified [14] (software engineering agents, 481 runs), MINT [15] (multi-turn reasoning and coding, 1,136 runs), and a custom local-model battery (808 runs across 4 open-weight model families via Ollama on consumer hardware). Our central finding is that the naive Lyapunov energy function has a 46% false positive rate, because holds on almost every turn of a multi-turn conversation as the context window grows. We fix this with growth-ratio normalization: the monitor tracks the ratio against a warmup baseline instead of raw token counts. With this change the signal becomes a leading indicator of task failure.
The 5-condition ablation (Baseline → Lyapunov-only → Lyapunov+RG → Full-stack → Naive Cap) gives four main results: (1) on short and medium-loop benchmarks (MINT and τ³), the monitor records zero stability violations in 1,886 runs, with <2% computational overhead; (2) on the long-loop benchmark (SWE-bench), full-stack monitoring cuts compute by 38.6% and wall time by 30%, and no task hits the budget ceiling; (3) across 333 multi-trial SWE-bench runs, full-stack monitoring resolves 4.5pp fewer tasks than the baseline, which is not significant (p = 0.28), and 6.3pp fewer than the naive cap, a gap whose bootstrap interval excludes zero (Welch p = 0.11); (4) on 4 open-weight local models (Llama 3.2:3B, Phi-4-Mini, Qwen3:4B, Gemma4:E4B), the monitor has zero false positives in 80 harness runs, and we observe a small-model self-sabotage pattern in which a naive turn limit beats the unconstrained baseline by +17.5pp on average.
The implementation is released as open-source: github.com/vishal-dehurdle/state-harness. Install via PyPI: pip install state-harness.
1. From Theory to Measurement: The Experimental Program
Our prior theoretical work [1] argued that the failure modes of production multi-agent systems (Token Tsunamis, semantic drift and context dilution) can be modeled with the tools of dynamical systems theory. It proposed three mechanisms for a physics-inspired governance layer:
- A Lyapunov energy function whose derivative indicates trajectory stability.
- Renormalization Group decimation to compress high-entropy agent communications into scale-invariant macrostates.
- Holographic Invariant Storage via Vector Symbolic Architectures to detect policy drift outside the LLM context window.
This paper tests all three in a 5-condition ablation that isolates each layer’s contribution, organized around four questions:
| Question | Method | Section |
|---|---|---|
| Q1: Does the raw Lyapunov energy derivative predict task failure, and why does it fail? | Empirical analysis of false positive rates | §2 |
| Q2: Can growth-ratio normalization reduce false positives while preserving detection sensitivity? | 5-condition ablation across four benchmarks | §5 |
| Q3: Does the value of monitoring scale with agent loop length? | Cross-benchmark comparison (MINT, τ³-bench, SWE-bench) | §5.4 |
| Q4: How much does each mechanism (Lyapunov, RG, VSA) contribute independently? | Ablation: B vs C vs D conditions | §5.2, §5.4 |
2. The Instability of Naive Energy Functions
The Lyapunov stability criterion states that a discrete-time system is asymptotically stable if there exists a positive-definite scalar function such that for all [4, 16]. Conversely, sustained indicates instability: the system is diverging from equilibrium.
Our theoretical framework [1] defined the composite energy function:
where is the token consumption at discrete time step , is the error indicator, and is the error coupling constant, drawing on composite and neural Lyapunov formulations for dynamical systems [11]. The circuit breaker trips when for consecutive steps.
In practice this fails. In a multi-turn LLM conversation the context window accumulates: each turn adds the previous response to the prompt, so the input token count increases monotonically with by construction. then holds on almost every turn of any multi-turn task, and the resulting false positive rate makes the raw energy function useless as a diagnostic.
graph LR
subgraph naive["Naive Energy Function — V(k) = S(k)"]
direction TB
A["Turn 1: 1000 tokens"] --> B["Turn 2: 1800 tokens"]
B --> C["Turn 3: 2600 tokens"]
C --> D["Turn 4: 3400 tokens"]
D --> E["Trips: ΔV ≥ 0 for 3 steps"]
end
naive ~~~ problem
subgraph problem["The Problem"]
direction TB
F["This is NORMAL context growth."]
G["The task was healthy."]
H["FALSE POSITIVE."]
end
Our v1 implementation confirmed this empirically: the raw Lyapunov monitor tripped on 46% of all tasks, but only 54% of those trips were genuine failures. Nearly half the killed tasks would have completed successfully. A false positive rate this close to the failure rate of unguarded agents defeats the purpose of a monitor.
3. Growth-Ratio Normalization: The Central Innovation
The resolution draws from the practice of normalization in experimental physics [5] and statistical process control (SPC) in quality engineering [3]. When measuring a signal contaminated by a systematic trend, the standard approach is to divide by the trend to isolate the fluctuation of interest [3, 5]. A cosmic ray detector does not measure raw photon counts (which increase with observation time); it measures counts per unit time (the rate), normalized against the expected background [5].
We apply the same principle to agent energy monitoring. During a warmup period of turns, we establish a baseline token consumption :
The median is chosen over the mean for robustness to outliers (e.g., an unusually large first-turn system prompt). For subsequent turns , we define the growth ratio:
The circuit breaker trips when (the ratio threshold) for consecutive steps, AND cumulative tokens exceed a minimum budget gate .
The ratio has a direct interpretation. means the agent is consuming tokens at its baseline rate, and means it is consuming twice its baseline, a sign that the execution dynamics have changed. The threshold defines the boundary of the stability envelope.
graph TD
subgraph warmup["Warmup Phase (k ≤ W₀)"]
W1["Turn 1: 1000 tokens"]
W2["Turn 2: 1100 tokens"]
W3["Turn 3: 1050 tokens"]
W1 --> W2 --> W3
W3 --> BASELINE["Baseline S̄ = median = 1050"]
end
subgraph monitor["Monitoring Phase (k > W₀)"]
M1["Turn 4: 1200 tokens → V̂ = 1.14×"]
M2["Turn 5: 1500 tokens → V̂ = 1.43×"]
M3["Turn 6: 2800 tokens → V̂ = 2.67× [Warning]"]
M4["Turn 7: 3500 tokens → V̂ = 3.33× [Warning]"]
M5["Turn 8: 4500 tokens → V̂ = 4.29× [Warning]"]
M1 --> M2 --> M3 --> M4 --> M5
M5 --> TRIP["TRIPPED: V̂ > τ for W=3 steps"]
end
BASELINE --> M1
A healthy multi-turn task may grow from 1,000 to 1,500 tokens per turn over 10 turns; if it started at 1,000, this is a steady – growth. A spiraling task grows from 1,000 to 3,000 to 8,000 to 20,000, with values of , and . In this example, the growth ratio separates the two.
3.1 Dual-Confirmation Gating
Growth-ratio escalation alone can produce false positives when an agent legitimately requires elevated token consumption (e.g., a complex multi-tool resolution generating verbose responses). To address this, we introduce dual-confirmation gating: the circuit breaker requires corroboration from two independent signals.
The first signal is the growth ratio for consecutive steps.
The second signal is policy drift, measured via Vector Symbolic Architecture (VSA) and Holographic Reduced Representations (HRR) [6, 13]. We encode the domain policy as a high-dimensional bipolar vector and compute the cosine drift at each step:
where is the VSA encoding of the agent’s response at step . If the mean drift over the last steps exceeds a threshold , the drift gate confirms the trip.
The circuit breaker trips if and only if:
With both gates, an agent that uses many tokens while staying on-policy (doing useful, complex work) is not killed: the growth ratio flags the energy anomaly, and the drift score must confirm a semantic one.
3.2 Renormalization Group History Compression
Before each LLM invocation, the conversation history undergoes RG-inspired decimation [7, 1]. Messages are scored by structural importance (TF-IDF relevance, tool-call status, positional significance), and those below a threshold are pruned.
Compression has two effects. It reduces per-turn token consumption by removing redundant context, and it flattens the natural growth curve, so real spirals stand out more against the compressed baseline.
Without compression, a 15-turn conversation naturally grows to 5× the baseline due to context accumulation alone. With RG decimation, the same conversation grows to 2×, which puts natural growth below the detection threshold , so the monitor responds mainly to pathological growth.
4. Experimental Setup
4.1 Benchmark: τ³-bench
We evaluate across four benchmarks spanning different agent modalities:
Primary benchmark: τ³-bench (Sierra Research, 2026) [2] is a standard benchmark for multi-turn tool-calling agents. τ³-bench simulates realistic customer service interactions where an LLM agent must complete tasks using domain-specific tools (flight lookups, order modifications, account changes) while conversing with a simulated user. Each task is scored on a [0, 1] reward scale based on correctness of database mutations and communication quality. A task with reward > 0 is considered a pass. We evaluate on the Airline domain (50 tasks).
Cross-benchmark validation:
| Benchmark | Domain | Tasks | Turn Structure | Spiral Risk |
|---|---|---|---|---|
| τ³-bench Airline | Customer-service dialog | 50 | Medium (3–10 turns) | Low |
| SWE-bench Verified | Software engineering | 37 (of 50; 13 Docker images unavailable) | Long (10–50+ turns) | High |
| MINT | Reasoning + Coding | 284 (GSM8K 48, MATH 100, HumanEval 45, MBPP 91) [24, 25] | Short (1–5 turns) | Medium |
| Custom (Local) | Multi-domain code generation | 20 (5 easy, 10 medium, 5 hard) | Short–Medium (1–6 turns) | Medium |
SWE-bench [14] evaluates agents on real GitHub issues from open-source projects (code navigation, patch writing, test execution), where scaffolds range from search trees to lightweight prompts (e.g. Agentless [10]). MINT [15] evaluates multi-turn interaction with tools across reasoning (GSM8K, MATH [24]) and code generation (HumanEval, MBPP [25]) tasks using iterative interaction paradigms such as ReAct [19].
4.1.1 Benchmark Validity Note
SWE-bench has faced scrutiny regarding data contamination and leaderboard saturation for model-to-model comparisons. Our design is largely insulated from these concerns, because we compare the same model-agent pair with and without state-harness monitoring. We expect token spiral behavior to depend on the agent scaffold more than on model capability, and so to persist whether or not the model saw the task during training.
4.2 Agent Configurations and Ablation Conditions
We evaluate cloud benchmarks using the same model (Gemini 2.5 Flash via Vertex AI) across a 5-condition ablation study that isolates each mechanism’s contribution across multi-agent patterns common to frameworks like LangGraph and AutoGen [22]. For local model validation, we use four open-weight models via Ollama on Apple M4 hardware (16 GB RAM): Llama 3.2:3B, Phi-4-Mini, Qwen3:4B, Gemma4:E4B.
| Condition | Lyapunov | RG Decimation | VSA Dual-Gate | Description |
|---|---|---|---|---|
| A. Baseline | — | — | — | Unmonitored agent |
| B. Lyapunov-only | — | — | Energy monitoring and termination, no compression or drift gating | |
| C. Lyapunov+RG | — | + history compression on violation | ||
| D. Full-stack | + VSA policy drift gating | |||
| E. Naive Cap | — | — | — | Hard budget cap ($0.30 / 100K tokens), representing industry practice [8] |
Conditions B, C, and D use the same harness_agent with feature toggles controlled via environment variables (HARNESS_RG=off, HARNESS_VSA=off), ensuring identical agent scaffolding across conditions. Not all conditions apply to all benchmarks: Condition C is omitted for SWE-bench (see §5.2), and Condition E (naive cap) is omitted for MINT (see §5.3).
For all benchmarks, we use live execution: the harness actively monitors and intervenes during agent execution, not retroactive simulation. This ensures that any behavioral changes induced by early termination are captured in the results.
4.3 Metrics
| Metric | Definition |
|---|---|
| Pass Rate | Fraction of tasks with reward > 0 (τ³-bench) or success (SWE-bench, MINT) |
| Token Savings | per task or aggregate |
| Trip Rate | Fraction of tasks where the monitor triggers early termination |
| Precision | P(task would have failed | monitor tripped) |
| False Positive Rate | P(task would have succeeded | monitor tripped) |
Precision is computed by comparing tripped tasks against the baseline: if a task was tripped by the monitor but completed successfully in the unguarded baseline, it is a false positive.
4.4 Infrastructure Note: Vertex AI Parallel Tool Call Bug
During initial retail-domain evaluation (a preliminary domain later excluded for scope reasons; the final evaluation uses the airline domain), we observed 35–42% of runs across all three agent configurations failing with zero duration and zero messages. Root cause analysis identified a protocol error in the Vertex AI Gemini API: when the model issues parallel function calls in a single turn (e.g., simultaneous get_order_details calls for multiple items), the API requires exactly corresponding function_response parts. The τ³-bench message serialization layer was sending {"content": null, "tool_calls": [...]} for tool-call-only turns; the null content field caused Vertex AI’s protocol translation to miscount parts, rejecting the request with HTTP 400.
Fix applied: We patched the message serialization to omit content from the API payload when it is null and tool calls are present, matching the Vertex AI protocol specification. The fix is a 6-line change in to_litellm_messages(). We record it here for reproducibility.
5. Results
5.1 Primary Result: τ³-bench Airline Domain
Setup: 50 tasks × 3 trials × 5 conditions = 750 total runs. Agent handles airline reservations (flight search, booking modification, cancellation) via tool calls with a simulated user. All conditions run sequentially with concurrency=1.
| Condition | Trial Pass | Rate | Task Pass (majority) | Rate | Cost | Cost Δ |
|---|---|---|---|---|---|---|
| A. Baseline | 99/150 | 66.0% | 35/50 | 70.0% | $2.47 | — |
| B. Lyapunov-only | 83/150 | 55.3% | 28/50 | 56.0% | $2.42 | −2.0% |
| C. Lyapunov+RG | 79/150 | 52.7% | 26/50 | 52.0% | $1.69 | −31.8% |
| D. Full-stack | 86/150 | 57.3% | 30/50 | 60.0% | $2.28 | −8.1% |
| E. Naive Cap | 81/150 | 54.0% | 26/50 | 52.0% | $2.33 | −5.7% |
Finding 1: Zero stability trips across all 750 runs. The growth-ratio monitor classified every airline task as stable and never intervened. On medium-loop customer-service agents, the monitor is non-invasive.
Finding 2: Pass-rate variance is LLM nondeterminism, not harness impact. The apparent ~10–18pp spread between conditions is attributable to intrinsic model variance: (a) 24–34% of tasks (28% on average) produce mixed pass/fail outcomes within the same condition across 3 trials; (b) the naive cap condition (E), which has zero monitoring, shows a −18pp drop from baseline, worse than full-stack monitoring (D, −10pp); (c) the union of conditions A–D passes 37/50 tasks while their intersection passes only 22/50, a 15-task (30%) variance band (adding E leaves the union at 37 and lowers the intersection to 19).
Finding 3: 8.1% lower cost under full-stack monitoring, although the monitor never intervened; we attribute this to the harness’s passive overhead reduction in the agent loop. The fail/pass cost ratio is lower (1.3×) than on MINT (1.6× on MATH, 3.4× on GSM8K), which suggests these medium-loop tasks gain less from monitoring.
5.2 Central Result: SWE-bench Verified (4-Condition Ablation)
Setup: 50 instances selected from SWE-bench Verified (Django project). 37 instances successfully ran (13 lacked pre-built Docker evaluation images). Agent uses moatless-tools SearchTree [23] with up to 50 node expansions per task. Each condition was run as a separate, complete execution (live monitoring, not retroactive simulation).
Note on Condition C: Condition C (Lyapunov+RG, no VSA) is omitted for SWE-bench because the VSA dual-gate requires access to prompt content, which the moatless Docker-isolated architecture does not expose. Condition D results thus reflect Lyapunov + RG without VSA, which makes C and D functionally identical in this integration.
5.2.1 Ablation Results
| Condition | Resolved | Rate | Total Nodes | Avg Nodes (Resolved) | Avg Nodes (Failed) | Hit 50-Max | Wall Time |
|---|---|---|---|---|---|---|---|
| A. Baseline | 15 / 37 | 40.5% | 945 | 27.5 | 24.2 | 7 | 80 min |
| B. Lyapunov-only | 16 / 37 | 43.2% | 620 | 16.8 | 16.8 | 0 | 69 min |
| D. Full-stack | 14 / 37 | 37.8% | 580 | 14.8 | 16.2 | 0 | 56 min |
| E. Naive Cap | 21 / 37 | 56.8% | 876 | 22.0 | 25.9 | 4 | 77 min |
All four conditions completed with zero infrastructure errors across 148 total runs (37 instances × 4 conditions).
5.2.2 Primary Finding: Compute Efficiency
The central result is compute efficiency, not pass-rate improvement. Full-stack monitoring (D) achieves:
- 38.6% compute reduction: 945 → 580 total nodes across 37 instances
- 30% wall-time reduction: 80 → 56 minutes
- 34% better cost-per-resolution: 63.0 → 41.4 nodes per resolved task
- Eliminates all max-budget burnout: Baseline had 7 tasks hitting the 50-node ceiling (all 7 failed after using their full budget). Full-stack: zero tasks hit ceiling.
Resolved tasks finish 46% faster under monitoring (27.5 → 14.8 avg nodes), suggesting that early termination of failing branches allows the search tree to converge faster on productive paths.
5.2.3 Ablation: Mechanism Contribution
| Layer Added | Compute (nodes) | Δ vs Baseline | Cumulative Reduction |
|---|---|---|---|
| A. No monitoring | 945 | — | — |
| B. + Lyapunov | 620 | −325 | 34.4% |
| D. + RG (no VSA) | 580 | −40 | 38.6% |
Lyapunov monitoring alone delivers ~90% of the total benefit (325 of 365 nodes saved). The energy function is the core mechanism. RG decimation adds ~4pp more compute reduction by compressing context on intervention, but most of the signal comes from the growth-ratio monitor.
5.2.4 Naive Cap Control Analysis
The naive cap (E) resolved 21/37 tasks (56.8%), apparently outperforming all other conditions. However, this result is attributable to LLM nondeterminism, not mechanism quality:
-
The cap never triggered. The $0.30 budget (~100K tokens) exceeds the natural consumption of most SWE-bench tasks. The naive cap is functionally identical to baseline for tasks that finish within budget.
-
Instance-level overlap analysis reveals the variance band:
- Union of all 4 conditions: 24/37 (64.9%) resolved at least once
- Intersection of all 4 conditions: only 10/37 (27.0%) resolved by every condition
- 14-instance variance band where each run solves a different random subset
-
The harness stopped some instances the baseline resolved. D stopped 25 of the 37 instances (24 growth-ratio kills, 1 budget stop). The baseline had resolved 10 of those 25, and D still resolved 7 of the 10. Of the 8 instances E resolved but D did not, the harness killed 5, after 16–19 nodes at growth ratios of 2.1–3.2× for 3 consecutive turns; the other 3 ended without a kill (7–19 nodes in all).
-
Statistical significance. With 37 instances and single trials, the standard error on pass rate is approximately ±8pp. The observed range (37.8%–56.8%) spans approximately 2.4 standard errors, within the expected range of sampling noise for single-trial evaluation.
The naive cap serves as a control: a hard budget cap set above the task’s natural consumption never triggers and so saves nothing by itself, while growth-ratio monitoring cuts nodes by 38.6% by detecting and terminating dynamically anomalous execution.
Multi-trial confirmation (§7.3.1): Over three trials E’s single-trial lead (56.8%) shrinks: E = 47.7% ± 3.1%, A = 45.9% ± 4.7%, D = 41.4% ± 4.1%. E and A are within noise of each other (p = 0.61). E’s lead over D (6.3pp) is the one gap whose bootstrap interval excludes zero, though the Welch test does not reach significance (p = 0.11).
5.2.5 Threshold Sensitivity Analysis (Retroactive)
To characterize the Pareto frontier between cost savings and pass-rate preservation, we perform a threshold sweep via retroactive simulation on the Condition A baseline trajectories. This complements the live ablation results above (§5.2.1–5.2.4) by exploring the full parameter space without requiring a separate live run for each (, ) combination.
We sweep with :
| Trips | Token Savings | Resolved Preserved | False Positives | Precision | ||
|---|---|---|---|---|---|---|
| 1.5 | 3 | 32 | 83.1% | 3 / 15 | 12 | 62.5% |
| 2.0 | 3 | 29 | 74.0% | 4 / 15 | 11 | 62.1% |
| 2.0 | 5 | 27 | 69.1% | 6 / 15 | 9 | 66.7% |
| 3.0 | 5 | 16 | 49.5% | 10 / 15 | 5 | 68.8% |
| 3.5 | 3 | 16 | 46.8% | 10 / 15 | 5 | 68.8% |
| 5.0 | 3 | 9 | 24.0% | 12 / 15 | 3 | 66.7% |
The sweep shows four operating regimes:
- Aggressive (): Maximum savings (70–83%) but a high false positive rate: only 3–6 of 15 resolved tasks survive. Suitable only for cost-sensitive, non-critical workloads.
- Balanced (, ): 49.5% savings with 10/15 resolved preserved. The recommended default for SWE-bench-class tasks.
- Conservative (): 24% savings with 12/15 resolved preserved. Minimal intervention; useful when resolve rate is the priority.
- Ultra-conservative (): 5.4% savings with 15/15 resolved preserved (zero false positives). Even here the guard catches the largest spirals (those exceeding 7× baseline), which suggests the worst failure modes separate from healthy execution across the thresholds we tested.
Early detection timing. The guard trips at a median of node 23 (range: 17–32), corresponding to approximately 46% of the 50-node maximum budget. This means the monitor detects spirals roughly halfway through the available computation: early enough for substantial savings, but late enough for the warmup baseline to calibrate accurately.
Robustness to window parameter. The Pareto knee occurs at regardless of window size ( or ), indicating that the threshold is the primary sensitivity parameter while the window provides secondary smoothing. This simplifies operator tuning: set for your risk tolerance, leave at the default.
The threshold stays in a narrow range (–) across very different task complexities, which is consistent with the self-calibrating property of growth-ratio normalization: because each task establishes its own baseline, the threshold operates on relative deviation rather than absolute scale.
5.3 Cross-Benchmark Validation: MINT (4-Condition Ablation)
Setup: 284 tasks × 4 conditions = 1,136 total runs across GSM8K (48), MATH (100), HumanEval (45), MBPP (91). Agent uses up to 5 turns per task.
| Condition | GSM8K (48) | MATH (100) | HumanEval (45) | MBPP (91) | Total (284) | Tokens |
|---|---|---|---|---|---|---|
| A. Baseline | 91.7% | 39.0% | 0.0% | 0.0% | 29.2% | 1,909,582 |
| B. Lyapunov | 91.7% | 41.0% | 0.0% | 0.0% | 29.9% | 1,904,421 |
| C. Lyapunov+RG | 89.6% | 37.0% | 0.0% | 0.0% | 28.2% | 1,910,926 |
| D. Full-stack | 87.5% | 39.0% | 0.0% | 0.0% | 28.5% | 1,949,708 |
Finding 1: Zero stability violations across all 1,136 runs. The monitor never intervenes on these short-loop tasks (1–5 turns): they never reach the sustained growth-ratio escalation ( consecutive turns above threshold) needed to trigger the guard. This is consistent with the non-invasiveness hypothesis.
Finding 2: Token usage is flat. Total tokens (prompt + completion) range from 1,904,421 to 1,949,708 across conditions (<2% variation). The monitoring computation adds negligible overhead. Token counts are computed as prompt_tokens + completion_tokens from the MINT token_counter per-task accumulator.
Finding 3: Failed tasks cost disproportionately more.
| Task | Success Avg Tokens | Failure Avg Tokens | Ratio |
|---|---|---|---|
| GSM8K | 2,613 | 8,857 | 3.4× |
| MATH | 5,154 | 8,188 | 1.6× |
Failing agents consume 1.6–3.4× more compute than successful ones. This asymmetry is the main economic argument for runtime monitoring, even on benchmarks where the monitor does not intervene.
Finding 4: Pass rates do not differ significantly. The range 28.2%–29.9% across 4 conditions represents ±0.85pp variation. With 284 tasks, the standard error is ~2.7pp.
The coding category (HumanEval, MBPP) shows 0% across all conditions due to a MINT framework limitation in code execution evaluation. Because all 4 conditions score 0%, these categories cannot show a harness effect in either direction.
5.4 Synthesis: The Loop-Length Hypothesis and Ablation Summary
Two patterns hold across the four benchmarks.
Pattern 1: Savings scale with loop length.
| Benchmark | Avg Turns | Compute Savings (D vs A) | Stability Trips | Pass-Rate Δ |
|---|---|---|---|---|
| MINT | 1–5 | ~0% | 0 / 1,136 | −0.7pp |
| Custom (Local) | 1–6 | 15.2% | 3 / 80 | 0pp |
| τ³-bench | 3–10 | 8.1% (cost) | 0 / 750 | −10pp (+2pp in an earlier run) |
| SWE-bench | 10–50 | 38.6% (nodes) | 87 / 148 (59%) | −4.5pp (not significant, p = 0.28) |
This matches the prediction in [1]: token spirals are a property of iterative agent scaffolds operating in open-ended action spaces. Short, bounded loops (MINT) converge or fail quickly. Long, exploratory loops (SWE-bench) create the conditions for context accumulation, retry storms, and policy drift, the instabilities that Lyapunov monitoring detects.
Pattern 2: Lyapunov monitoring delivers the majority of the benefit.
| Mechanism Layer | MINT Accuracy | SWE Compute (nodes) | Contribution |
|---|---|---|---|
| A. No monitoring | 29.2% | 945 | — |
| B. + Lyapunov | 29.9% | 620 | 34.4% compute reduction |
| D. + RG (+ VSA on MINT only) | 28.5% | 580 | +4.2pp additional |
Lyapunov monitoring alone (Condition B) delivers ~90% of the total compute savings on SWE-bench, with no measurable change in MINT accuracy. Teams that want the simplest integration can deploy the GrowthRatioGuard alone, without RG compression or VSA drift detection, and keep most of the benefit.
In practice, state-harness is most useful for agents with long or unbounded loops, such as coding agents, and adds little overhead to short-loop deployments.
5.5 Local Open-Weight Model Validation
Setup: 20 custom tasks (5 easy, 10 medium, 5 hard) × 4 models × 3 conditions = 240 runs. Models: Llama 3.2:3B (2.0 GB), Phi-4-Mini (2.5 GB), Qwen3:4B (2.5 GB), Gemma4:E4B (9.6 GB). Hardware: Apple M4 MacBook Pro, 16 GB RAM, Ollama local inference.
| Model | Baseline | Harness | Naive Cap | Token Savings | False Positives |
|---|---|---|---|---|---|
| Llama 3.2:3B | 45% | 45% | 60% | 1.2% | 0 |
| Phi-4-Mini | 30% | 30% | 40% | 20.7% | 0 |
| Qwen3:4B | 30% | 30% | 40% | 0.9% | 0 |
| Gemma4:E4B | 35% | 35% | 70% | 37.9% | 0 |
| Mean | 35% | 35% | 52.5% | 15.2% | 0 |
Finding 1: Zero false positives across all 80 harness runs. Across 4 model families spanning 3 difficulty tiers, the growth-ratio monitor never kills a task that baseline would have passed. It tripped 3 times, all on Llama 3.2:3B and all on tasks the baseline also failed; on the other three models it never tripped. This matches τ³-bench and MINT with Gemini 2.5 Flash, where the monitor also never tripped.
Finding 2: Small-model self-sabotage. Naive cap (2-turn limit) outperforms unconstrained baseline by +17.5pp on average across all four models (median +12.5pp). The effect is strongest on Gemma4:E4B (+35pp: 35%→70%). Examination of task trajectories reveals that small models often solve a problem correctly in an early turn and then break the correct solution with unneeded revisions in later turns.
Finding 3: Model-family behavioral signatures. Growth-ratio trajectories reveal distinct behavioral patterns:
- Llama 3.2:3B. Spirals with exponential ratio growth ( values of 2.3×, 5.9×, 7.6×). Three true-positive trips.
- Phi-4-Mini. Spike-and-recover patterns. 20.7% token savings via passive governance.
- Qwen3:4B. Uniform high-volume output (~4K tokens/turn from “thinking mode”) but flat growth ratios ( ≤ 1.06). Correctly classified as stable despite 3× the absolute token volume.
- Gemma4:E4B. Decreasing ratios under monitoring ( values of 1.0, 0.56, 0.07). 37.9% passive token savings with zero formal trips.
Qwen3:4B shows the difference most clearly. It consumed 255K tokens in total (3× the runner-up), yet its growth ratio never exceeded 1.06×, so the metric did not mistake high volume for instability.
5.5.1 MINT on Local Model (Qwen3:4B)
To validate the loop-length hypothesis on local hardware, we ran the full MINT benchmark on Qwen3:4B under two conditions: harness monitoring (max_steps=5) and naive cap (max_steps=2), totalling 568 additional runs.
| Task | Harness (max=5) | Naive Cap (max=2) | Δ | n |
|---|---|---|---|---|
| GSM8K | 37.5% | 27.1% | +10.4pp | 48 |
| MATH | 0.0% | 0.0% | — | 100 |
| HumanEval | 11.1% | 11.1% | — | 45 |
| MBPP | 14.3% | 14.3% | — | 91 |
| Total | 12.7% | 10.9% | +1.8pp | 284 |
The harness monitored all 284 tasks with zero interventions (all terminated_by_harness: false). On MINT’s short-loop tasks (max 5 turns), the harness monitoring window (W=3) cannot trigger within the available post-warmup turns, so zero trips on MINT are guaranteed by construction.
The GSM8K result (+10.4pp with more steps) suggests that on reasoning tasks, extra turns help. The self-sabotage effect observed in the custom benchmark does not appear on MINT, consistent with MINT’s short-form Q&A format leaving less opportunity for destructive self-revision.
6. Zero-Cost Failure Diagnostics
A circuit breaker that kills tasks is useful in operation but opaque for diagnosis. An engineer needs to know why a task was killed and what to change to prevent it.
We introduce zero-cost failure diagnostics: a pattern classification system that operates entirely on the energy trajectory and drift trajectory , requiring no additional LLM calls.
6.1 Failure Pattern Taxonomy
From empirical analysis of tripped tasks, we identify six distinct failure patterns, each with a characteristic energy signature:
| Pattern | Energy Signature | Root Cause |
|---|---|---|
| Context Accumulation Spiral | Monotonically accelerating ; last 5 values > 1.5× | Agent replaying full conversation as context each turn |
| Retry Storm | Near-constant with CV < 0.3 across 8+ turns | Tool failure triggering identical retry attempts |
| Policy Drift | Moderate with high, increasing | Agent losing focus on original task objective |
| Early Explosion | in first 3 turns | Malformed prompt or oversized tool response |
| Budget Exhaustion | Stable reaching cumulative ceiling | Genuinely complex task requiring extended execution |
| Gradual Degradation | Mild growth without exponential acceleration | Borderline task; may complete with higher threshold |
graph TD
TRIP["Task Tripped / Completed"]
TRIP --> CHECK1{"V̂(k) > 3.0 in first 3 turns?"}
CHECK1 -->|Yes| EARLY["Early Explosion"]
CHECK1 -->|No| CHECK2{"Frozen (budget exceeded)?"}
CHECK2 -->|Yes| BUDGET["Budget Exhaustion"]
CHECK2 -->|No| CHECK3{"CV(energy) < 0.3 and turns ≥ 8?"}
CHECK3 -->|Yes| RETRY["Retry Storm"]
CHECK3 -->|No| CHECK4{"Last 5 V̂ > 1.5 with 3+ accelerating?"}
CHECK4 -->|Yes| SPIRAL["Context Spiral"]
CHECK4 -->|No| CHECK5{"Mean recent drift > 0.7?"}
CHECK5 -->|Yes| DRIFT["Policy Drift"]
CHECK5 -->|No| GRADUAL["Gradual Degradation"]
6.2 The Actionable Output
Each classified pattern produces a prioritized list of recommendations, derived from the energy and drift signatures observed in that task:
| Pattern | Priority 1 Action | Rationale |
|---|---|---|
| Context Spiral | Enable RG history compression | Context window growing unchecked; compression reduces prompt tokens 40–60% |
| Retry Storm | Add exponential backoff with max-retry cap | Identical calls burning tokens with zero progress |
| Policy Drift | Re-inject domain policy every N turns | Model forgetting original instructions over long conversations |
| Early Explosion | Audit system prompt and initial tool response sizes | First-turn token spike indicates oversized static content |
The diagnostics can be exported as distributed traces via OpenTelemetry [21], and they are the main practical difference between state-harness and a plain budget cap. Tool-retry storms and other execution failures [20] get their own label when the monitor trips. A hard cap tells the engineer “your task was killed at 50,000 tokens.” State-harness tells the engineer “your task was killed because of a context accumulation spiral starting at turn 7, caused by the agent replaying full conversation history. Enable RG compression to fix it.”
7. Discussion
7.1 The Complementarity Thesis
Growth-ratio Lyapunov monitoring complements offline agent optimization such as NeoSigma [9] and differs from probabilistic runtime assertion frameworks such as ProbGuard [12]. The difference is one of timing:
| Dimension | Offline Optimization (NeoSigma [9]) | Runtime Monitoring (State-Harness) |
|---|---|---|
| When | After failures are collected (batch, iterative) | During execution (real-time, per-turn) |
| What it improves | Agent capability (pass rate) | Agent efficiency (cost of failure) |
| Mechanism | Failure mining → harness edits → regression testing | Energy trajectory analysis → circuit breaking |
| Cost | High (96+ iterative experiments, GPT-5.4) | Near-zero (~1μs per step, no LLM calls) |
| Target user | Enterprise teams with dedicated ML ops | Solo developers, lean startups |
NeoSigma reports a 39.3% improvement in pass rate on τ³-bench (0.56 → 0.78) using GPT-5.4 [9]. The 22% of tasks that still fail under NeoSigma can still spiral without runtime monitoring. State-harness leaves pass rate unchanged and reduces the cost of the failures that remain after capability optimization.
The complete agent reliability stack combines both:
7.2 The Physics of the Growth Ratio
The growth-ratio normalization is more than trend removal. It maps onto the thermodynamic distinction between intensive and extensive quantities: absolute token count is an extensive quantity (it grows with system size, i.e., conversation length), while the growth ratio is intensive (bounded for stable systems regardless of conversation length).
This explains why the naive energy function fails: monitoring on raw token counts is analogous to measuring the total energy of a growing system, which increases monotonically by construction. The growth ratio removes the system-size effect and separates real dynamical anomalies from the natural accumulation trend, in the spirit of Input-to-State Stability (ISS) [17] and control barrier certificates [18].
7.3 Future Evaluation Roadmap
Several newer benchmarks would extend the current four:
| Benchmark | Why It’s Relevant | Status |
|---|---|---|
| Multi-trial SWE-bench | 3 trials × 3 conditions × 37 instances (333 runs) to quantify LLM nondeterminism | Complete (§7.3.1) |
| Local model validation | 4 open-weight models (Llama, Phi, Qwen, Gemma) × 3 conditions × 20 tasks + MINT on Qwen3:4B | Complete (§5.5) |
| Cross-model validation | Full runs on Gemini 2.5 Flash + 4 local models; an 8-run smoke test on GPT-4o-mini and Claude Haiku 4.5 | Partial (smoke test: 0 false positives, 0 of 2 spirals caught) |
| Terminal-Bench | Terminal-based agent tasks; tests command-line tool loops where spirals manifest as repeated failed commands | Planned |
| SWE-bench Pro | Harder, contamination-resistant variant of SWE-bench; reduces data leakage concerns | Planned |
| LiveCodeBench | Freshly sampled coding problems with no training data overlap; gives a cleaner evaluation signal | Planned |
| SWE-rebench | Continuously refreshed with recent PRs from active repositories | Planned |
7.3.1 Multi-trial SWE-bench Results
To address the single-trial limitation identified in §7.4, we ran 333 total runs (37 instances × 3 independent trials × 3 conditions: A, D, E). Of these, 321 runs logged a resolution. In the other 12 (3.6%) the Docker container hung and was killed after more than 28 minutes; 5 of those 12 have evaluation records marked resolved, so we take every run’s result from its evaluation record and count the other 7 as failures. Results:
| Condition | Trial 1 | Trial 2 | Trial 3 | Mean ± σ |
|---|---|---|---|---|
| A. Baseline | 19/37 (51.4%) | 16/37 (43.2%) | 16/37 (43.2%) | 45.9% ± 4.7% |
| D. Full-stack | 15/37 (40.5%) | 17/37 (45.9%) | 14/37 (37.8%) | 41.4% ± 4.1% |
| E. Naive Cap | 19/37 (51.4%) | 17/37 (45.9%) | 17/37 (45.9%) | 47.7% ± 3.1% |
Statistical finding: The spread of the condition means (σ = 3.3%) is smaller than within-condition nondeterminism (mean σ = 4.0%). The A–D resolve-rate delta (−4.5pp) is about one within-condition standard deviation and not significant (Welch p = 0.28), so we detect no effect of the harness relative to the baseline.
Bootstrap analysis (10,000 resamples): Individual condition 95% CIs: A = [43.2%, 51.4%], D = [37.8%, 45.9%], E = [45.9%, 51.4%]. Two of the three pairwise difference CIs contain zero:
| Comparison | Δ | Bootstrap 95% CI | Welch t (df) | Significant? |
|---|---|---|---|---|
| A − D (harness impact) | +4.5pp | [−0.9pp, +9.9pp] | t(3.9) = 1.25 | No (p ≈ 0.28) |
| A − E (naive cap impact) | −1.8pp | [−6.3pp, +3.6pp] | t(3.5) = −0.55 | No (p ≈ 0.61) |
| D − E (harness vs naive) | −6.3pp | [−10.8pp, −1.8pp] | t(3.7) = −2.11 | Bootstrap CI excludes 0; Welch p ≈ 0.11 |
The D–E gap is the only comparison whose bootstrap interval excludes zero, but the Welch test does not reach significance (p ≈ 0.11). A bootstrap over three trial rates is coarse and power is limited at n=3, so we read this as a possible small cost of full-stack monitoring relative to a naive cap, which more trials should test.
This ~4% within-condition standard deviation is larger than the trial-to-trial spread on τ³-bench, which is 1.2–5.0pp by condition (mean 2.6pp). At a ~4pp noise level, a single-run comparison reporting a delta below ~8pp cannot separate signal from noise.
7.4 Limitations
Four limitations bound the current work:
-
Sample size. While multi-trial evaluation (§7.3.1) confirms non-invasiveness across 333 SWE-bench runs, the 37-instance subset limits statistical power for detecting small effects (<3pp). Larger-scale evaluation on the full SWE-bench Verified set (500 instances) would strengthen conclusions.
-
Warmup sensitivity. The baseline is established from the first turns. If these turns are atypical (an unusually large system prompt, a cold-start penalty, or a non-representative first tool call), the baseline may be miscalibrated. Median aggregation provides partial robustness, but edge cases remain.
-
No causal intervention. State-harness detects and kills spiraling tasks but does not redirect them. The RG decimator addresses context accumulation by compression, but retry storms and policy drift require agent-level architectural fixes that state-harness can only suggest, not implement.
-
Local model custom benchmark scale. The 20-task custom battery is smaller than standard benchmarks. The self-sabotage finding (mean +17.5pp, median +12.5pp for naive cap) is observed consistently across all four model families but requires larger-scale replication to establish effect sizes precisely.
8. Conclusion
We tested Lyapunov stability analysis on multi-turn LLM agent execution trajectories with a 5-condition ablation on four benchmarks: customer service (τ³-bench), software engineering (SWE-bench), multi-turn reasoning (MINT) and local open-weight models (custom battery). We repeated the SWE-bench runs three times (333 runs) and ran the monitor on 5 model families.
Our central contribution is growth-ratio normalization. It turns the raw energy derivative, sound in theory but useless on multi-turn agents, into a self-calibrating leading indicator of task failure. The main results:
-
No measurable effect on task success: On MINT (1–5 turns) the monitor records zero stability violations in 1,136 runs (284 tasks × 4 conditions). On SWE-bench, across 333 multi-trial runs, the A–D resolve-rate delta (−4.5pp) is not significant (Welch p = 0.28).
-
Zero-cost failure diagnostics: When the monitor trips, it assigns one of six failure patterns (context accumulation spiral, retry storm, policy drift, early explosion, budget exhaustion or gradual degradation) and recommends fixes, using only the energy trajectory and no extra LLM calls (§6). Explaining why a task failed is what sets it apart from a plain budget cap.
-
Compute efficiency on long loops: On SWE-bench (10–50 turns), full-stack monitoring cuts compute by 38.6% (945 → 580 nodes) and wall time by 30% (80 → 56 minutes), with <3pp pass-rate impact (single run). Tasks hitting the 50-node ceiling drop from 7 to 0.
-
Lyapunov monitoring alone delivers ~90% of the total benefit. Adding the growth-ratio monitor cuts compute by 34.4%; RG decimation adds 4.2pp more. The simplest integration (5 lines of
GrowthRatioGuardcode) captures most of the value. -
Savings grow with loop length: Across MINT, τ³-bench and SWE-bench, compute savings rise with agent loop length (~0% → 8.1% → 38.6%), consistent with the prediction in [1] that spirals are a property of iterative, open-ended agent scaffolds.
-
A nondeterminism floor of about 4pp: for Gemini 2.5 Flash the within-condition standard deviation is 4.0pp on multi-trial SWE-bench, and the trial-to-trial spread on τ³-bench is 1.2–5.0pp. On these tasks, single-run comparisons with deltas below ~8pp cannot separate signal from noise.
-
Cross-model results: Zero false positives in 80 local-model harness runs on Llama 3.2:3B, Phi-4-Mini, Qwen3:4B and Gemma4:E4B on consumer hardware (Apple M4, 16 GB RAM, Ollama), with no threshold retuning.
-
Small-model self-sabotage: On small models (≤4B parameters), a naive turn limit beats the unconstrained baseline by +17.5pp on average (+12.5pp median). For constrained deployments, limiting turns can preserve capability as well as cut cost.
The engineering idea is simple: monitor an agent’s token use relative to its own baseline, not in absolute terms. With dual-confirmation gating and a configurable threshold, this gives a runtime check that is more precise and less intrusive than the hard budget caps used in production today.
Our prior work [1] predicted that the semantic boundary layer of multi-agent systems needs physics-inspired governance. This paper tests that prediction with a mechanistic ablation on four agent modalities and finds the instabilities it described measurable and controllable.
State-harness is released as open-source at github.com/vishal-dehurdle/state-harness, and installable via pip install state-harness.
References
- [1] Verma, V. (2026). “The Fluid Dynamics of Multi-Agent AI: Resolving d’Alembert’s Paradox of Generative Workflows.” Vishal Verma Labs Research.
- [2] Barres, V., Shi, B., Zytek, O., Ray, S., Dhandhania, K., & Razavi, P. (2026). “τ³-Bench: Advancing agent benchmarking to knowledge and voice.” Sierra blog.
- [3] Shewhart, W. A. (1931). Economic Control of Quality of Manufactured Product. Van Nostrand. (Foundation of statistical process control, the methodological ancestor of growth-ratio monitoring.)
- [4] Khalil, H. K. (2002). Nonlinear Systems (3rd ed.). Upper Saddle River, NJ: Prentice Hall.
- [5] Taylor, J. R. (1997). An Introduction to Error Analysis: The Study of Uncertainties in Physical Measurements (2nd ed.). University Science Books.
- [6] Kanerva, P. (2009). “Hyperdimensional Computing: An Introduction to Computing in Distributed Representation with High-Dimensional Random Vectors.” Cognitive Computation, 1(2), 139–159.
- [7] Wilson, K. G. (1975). “The Renormalization Group: Critical Phenomena and the Kondo Problem.” Reviews of Modern Physics, 47(4), 773–840.
- [8] AgentBudget. (2026). Open-Source SDK for Agent Budget Enforcement. GitHub repository.
- [9] Gupta, G., Kapila, R., & Gupta, K. (2026). “Self-Improving Agentic Systems.” NeoSigma blog.
- [10] Xia, C. S., Deng, Y., Dunn, S., & Zhang, L. (2024). “Agentless: Demystifying LLM-based Software Engineering Agents.” arXiv preprint arXiv:2407.01489.
- [11] Richards, S. M., Berkenkamp, F., & Krause, A. (2018). “The Lyapunov Neural Network: Adaptive Stability Certification for Safe Learning of Dynamical Systems.” Conference on Robot Learning (CoRL), PMLR 87, 466–476.
- [12] Wang, H., Poskitt, C. M., Wei, J., & Sun, J. (2026). “ProbGuard: Proactive Runtime Monitoring for LLM Agent Safety via Probabilistic Prediction.” IEEE/ACM International Conference on Automated Software Engineering (ASE), 1470–1482. arXiv:2508.00500.
- [13] Plate, T. A. (2003). Holographic Reduced Representations: Distributed Representations for Cognitive Structures. CSLI Publications, Stanford.
- [14] Jimenez, C. E., Yang, J., Wettig, A., Yao, S., Pei, K., Press, O., & Narasimhan, K. (2024). “SWE-bench: Can Language Models Resolve Real-World GitHub Issues?” International Conference on Learning Representations (ICLR).
- [15] Wang, X., Wang, Z., Liu, J., Chen, Y., Yuan, L., Peng, H., & Ji, H. (2023). “MINT: Evaluating LLMs in Multi-turn Interaction with Tools and Language Feedback.” arXiv preprint arXiv:2309.10691.
- [16] Lyapunov, A. M. (1892). The General Problem of the Stability of Motion. Kharkov Mathematical Society (English translation: Taylor & Francis, 1992).
- [17] Sontag, E. D. (2008). “Input to State Stability: Basic Concepts and Results.” In Nonlinear and Optimal Control Theory, Lecture Notes in Mathematics, Vol. 1932, 163–220. Springer.
- [18] Ames, A. D., Coogan, S., Egerstedt, M., Notomista, G., Sreenath, K., & Tabuada, P. (2019). “Control Barrier Functions: Theory and Applications.” 18th European Control Conference (ECC), 3420–3431.
- [19] Yao, S., Zhao, J., Yu, D., Du, N., Shafran, I., Narasimhan, K., & Cao, Y. (2023). “ReAct: Synergizing Reasoning and Acting in Language Models.” International Conference on Learning Representations (ICLR).
- [20] Schick, T., Dwivedi-Yu, J., Dessì, R., Raileanu, R., Lomeli, M., Hambro, E., Zettlemoyer, L., Cancedda, N., & Scialom, T. (2023). “Toolformer: Language Models Can Teach Themselves to Use Tools.” Advances in Neural Information Processing Systems (NeurIPS), 36, 68539–68551.
- [21] OpenTelemetry Authors. (2023). “OpenTelemetry: High-quality, ubiquitous, and portable telemetry to enable effective observability.” Cloud Native Computing Foundation (CNCF).
- [22] Wu, Q., Bansal, G., Zhang, J., Wu, Y., Li, B., Zhu, E., Jiang, L., Zhang, X., Zhang, S., Liu, J., Awadallah, A. H., White, R. W., Burger, D., & Wang, C. (2023). “AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation.” arXiv preprint arXiv:2308.08155.
- [23] Örwall, A. (2024). “Moatless Tools: Autonomous Software Engineering Agent with Tree Search.” GitHub Repository.
- [24] Cobbe, K., Kosaraju, V., Bavarian, M., Chen, M., Jun, H., Kaiser, L., Plappert, M., Tworek, J., Hilton, J., Nakano, R., Hesse, C., & Schulman, J. (2021). “Training Verifiers to Solve Math Word Problems.” arXiv preprint arXiv:2110.14168.
- [25] Chen, M., Tworek, J., Jun, H., Yuan, Q., Pinto, H. P. d. O., Kaplan, J., Edwards, H., Burda, Y., Joseph, N., Brockman, G., Ray, A., Puri, R., Krueger, G., … & Zaremba, W. (2021). “Evaluating Large Language Models Trained on Code.” arXiv preprint arXiv:2107.03374.