TURF: Uncertainty Quantification for Tool-Calling Agents

TURF (Trajectory Uncertainty via Risk Fusion, arXiv:2612.04571) is a training-free failure-ranking method for tool-interacting LLM agents. Fusing observable outcome dispersion (DB, OS, web state) with semantic disagreement across final summaries, TURF achieves 0.774 AUROC and 0.859 AUPR (+5.14 pp AUROC over SGD) while TURF-Adaptive cuts rollouts by 24.0%.
TURF: Uncertainty Quantification for Tool-Calling Agents: TURF (Trajectory Uncertainty via Risk Fusion, arXiv:2612.04571) is a training-free failure-ranking method for tool-interacting LLM agents. Fusing observable outcome dispersion (DB, OS, web state) with semantic disagreement across final summaries, TURF achieves 0.774 AUROC and 0.859 AUPR (+5.14 pp AUROC over SGD) while TURF-Adaptive cuts rollouts by 24.0%. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.
- Dual-Signal Risk Fusion: Pairs Count Risk (dispersion across observable DB, OS, and purchase state signatures) with Semantic Risk (disagreement across final reports).
- +5.14 pp AUROC Over 15 Baselines: Evaluated on 6,854 matched records across GAIA, AgentBench-DB, AgentBench-OS, and WebShop, reaching 0.774 AUROC and 0.859 AUPR at B=16.
- 24.0% Fewer Rollouts via TURF-Adaptive: A Bayesian two-view stopping rule halts early whenever rollouts match the anchor outcome, losing only 0.56 pp AUROC vs fixed B=16.
- Training-Free Pre-Commit Gate: Plugs directly into multi-rollout MCP pipelines without modifying model weights or requiring reference calibration cohorts.
import { createAgent } from '@smoke-monkey/harness';// Outcome-grounded risk ranking before executing state-changing MCP writesconst agent = createAgent({agentId: 'turf-risk-verifier',provider: 'anthropic',model: 'claude-sonnet-4-5',workspacePath: process.cwd(),permissions: {read_file: 'allow',write_file: 'ask',run_command: 'ask',},});async function main() {const result = await agent.run('Execute 4 dry-run SQL rollout traces against staging, hash resulting state signatures, and compute TURF count + semantic risk.');console.log('TURF Risk Verdict:', result.summary);}main().catch(console.error);
Watch: Related Video Guides
What is Tool Calling? Connecting LLMs to Your Data
Training an Open LLM for Tool Calling with Reasoning
What Is TURF and Why Do Text-Only Uncertainty Methods Miss Tool Failures?
TURF (Trajectory Uncertainty via Risk Fusion) (arXiv:2612.04571) is a training-free uncertainty quantification framework that ranks task failure risk in tool-interacting LLM agents. By combining observable execution-outcome dispersion with semantic summary disagreement, TURF catches silent database, shell, and web-action failures that text-only self-consistency misses.
An LLM agent frequently writes a confident success message even after a SQL query returns an empty set, an OS script exits cleanly on the wrong path, or a checkout step drops an option. Text-only baselines such as Semantic Entropy or EigV inspect only final prose, whereas TURF normalizes observable backend states into hashable outcome buckets across GAIA, AgentBench-DB, AgentBench-OS, and WebShop.
| Method (6,854 Matched Records, 4 Envs) | B = 2 AUROC / AUPR | B = 4 AUROC / AUPR | B = 8 AUROC / AUPR | B = 12 AUROC / AUPR | B = 16 AUROC / AUPR |
|---|---|---|---|---|---|
| TURF-Fixed | .700 / .804 | .735 / .832 | .758 / .848 | .771 / .857 | .774 / .859 |
| TURF-Adaptive (Bayesian Stop) | .700 / .804 | .735 / .832 | .757 / .848 | .765 / .855 | .768 / .856 (-24% cost) |
| SGD (Strongest Baseline) | .652 / .773 | .690 / .809 | .704 / .816 | .715 / .825 | .722 / .830 |
Implementing TURF-Adaptive Bayesian Stopping in Staging Rollouts
Running 16 full tool-use trajectories for every routine query wastes tokens and API latency. TURF-Adaptive compares each incoming rollout against the first anchor rollout in both observable state and semantic embedding space, halting as soon as posterior anchor-agreement exceeds a confidence threshold—cutting rollout inspections by 24.00% at cap 16 with just 0.56 pp AUROC variance.
import math
from collections import Counter
def turf_count_risk(outcomes: list[str]) -> float:
# Penalizes both bucket entropy and low-sample-size uncertainty
n = len(outcomes)
counts = Counter(outcomes)
entropy = -sum((c / n) * math.log(c / n) for c in counts.values())
max_share = max(counts.values()) / n
return 0.5 * entropy + 0.5 * (1.0 - max_share)
print("Consistent DB writes:", turf_count_risk(["row_hash_a"] * 4))
print("Divergent SQL writes:", turf_count_risk(["row_hash_a", "row_hash_b", "err_null", "row_hash_a"]))Normalize Non-Deterministic Timestamps Before Hashing Outcomes
When building Count Risk buckets on AgentBench-DB or AgentBench-OS, strip ephemeral request IDs, UUIDs, and timestamps so identical logical state transitions land in the same outcome bucket.
Frequently Asked Questions
Q:How does TURF measure uncertainty beyond final LLM text?
TURF fuses Count Risk—measured over normalized observable execution outcomes such as database state signatures and OS exit schemas—with Semantic Risk across final answer summaries.
Q:How much compute does TURF-Adaptive save over fixed rollout budgets?
Using a Bayesian two-view stopping rule anchored on the first rollout, TURF-Adaptive inspects 24.00% fewer rollouts at a cap of 16 while retaining 0.768 AUROC versus 0.774 for TURF-Fixed.
Q:Which benchmarks were used to evaluate TURF?
TURF was evaluated on 6,854 matched task-setting records spanning four tool-use environments: GAIA, AgentBench-DB, AgentBench-OS, and WebShop across three LLM backbones.
Q:Does TURF require training a separate reward or verifier model?
No. Both TURF-Rank and reference-free TURF-Raw are completely training-free and operate over repeated rollout trajectories.
Related Alternatives & Comparisons
Related Architecture Guides
View all guidesBest Open Source Coding Agents in 2026: Free, Local & Fully Hackable Harnesses
MCP Server Security Best Practices: Hardening Model Context Protocol Agents in 2026
Open Source Coding Agent Harness: Build a Forkable, Local AI Engineering Runtime
Build with Smoke Monkey Harness
Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.