TRACE: Tool-Relevance KV Cache Eviction with Conformal Guarantees

TRACE (`arXiv:2611.34954`) is a tool-relevance-aware KV cache eviction framework with distribution-free Conformal Risk Control (CRC) guarantees for agentic LLMs. Because uninvoked tool schemas consume 77% to 86% of an agent's prompt prefix, TRACE ranks per-turn tool relevance, prefills only the calibrated keep set, and achieves 3.9x to 6.2x eviction-only reduction at risk budget alpha=0.10.
TRACE: Tool-Relevance KV Cache Eviction with Conformal Guarantees: TRACE (`arXiv:2611.34954`) is a tool-relevance-aware KV cache eviction framework with distribution-free Conformal Risk Control (CRC) guarantees for agentic LLMs. Because uninvoked tool schemas consume 77% to 86% of an agent's prompt prefix, TRACE ranks per-turn tool relevance, prefills only the calibrated keep set, and achieves 3.9x to 6.2x eviction-only reduction at risk budget alpha=0.10. 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.
- Solves the Schema Compression Ceiling: Uninvoked MCP/function schemas occupy 77%–86% of agent prefixes on BFCL (~28 tools exposed, 1.7 called/turn).
- 3.9x–6.2x Prefix Eviction: Calibrated keep-size policies slash KV memory while bounding task-success degradation.
- Distribution-Free CRC Guarantees: Calibrates keep size K against an explicit user risk budget (e.g. `alpha = 0.10`) without model retraining.
- Beats Attention-Score Baselines: Outperforms perplexity-tuned and attention-eviction heuristics that drop critical JSON parameter definitions.
import { createAgent } from '@smoke-monkey/harness';const conformalToolAgent = createAgent({agentId: 'trace-conformal-mcp-router',provider: 'custom',baseUrl: 'http://127.0.0.1:8000/v1',model: 'qwen3.8:27b',workspacePath: process.cwd(),permissions: {read_file: 'allow',write_file: 'allow',run_command: 'ask',},// Restrict active per-turn MCP tool injection via TRACE-calibrated top-KmaxActiveToolsPerTurn: 6,});async function executeBoundedTurn() {const result = await conformalToolAgent.run('Select the top-K relevant MCP tools for Postgres schema migration under alpha=0.10 risk budget, then run dry-run verification.');console.log('Conformal Agent Output:', result.summary);}executeBoundedTurn().catch(console.error);
Watch: Related Video Guides
How KV Cache Speeds Up LLMs for Faster AI Models on GPUs
What is Prompt Caching? Optimize LLM Latency with AI Transformers
What Is TRACE? Solving the 86% Tool-Schema KV Cache Wall
Modern coding and MCP agents routinely expose dozens of tool schemas on every turn, yet on the Berkeley Function Calling Leaderboard (BFCL) an average turn exposes ~28 tools while reference executions invoke only 1.7 tools. Those 26+ unused JSON schemas consume 77% to 86% of the entire prompt KV cache—establishing a hard memory ceiling that generic perplexity-based KV eviction fails to break.
TRACE (arXiv:2611.34954) replaces token-level attention heuristics with structured, turn-level tool-schema gating: a lightweight predictor scores each available tool against the current conversation state, a keep rule prefills only the top-ranked schemas, and a Conformal Risk Control (CRC) calibration layer selects the minimum keep count satisfying a formal task-loss ceiling.
TRACE Compression Ratios & Conformal Risk Control Results
Because dropping a single required tool schema causes catastrophic argument failures while removing unused schemas is near-lossless, TRACE's relevance-first eviction strictly dominates equal-memory random or attention-score baselines.
| Compression Policy | Retained Prefix Share | Effective Eviction Ratio | Task Success Impact | Formal Guarantee |
|---|---|---|---|---|
| Full Uncompressed Prefix | 100% (77–86% schemas) | 1.0x | Baseline | Exact |
| TRACE Best-Effort (Base) | 17% | ~5.9x | -3 to -5 pts | Empirical frontier |
| TRACE Best-Effort (Long-Ctx) | 25% | ~4.0x | -3 to -5 pts | Empirical frontier |
| TRACE CRC (`alpha = 0.10`) | 16%–26% (4/4 settings) | 3.9x – 6.2x | <= 10% risk budget | Distribution-free CRC |
| Random Same-Count Eviction | 17%–25% | 4x–6x | Catastrophic drop | None |
Across all four evaluated model-context configurations, CRC at alpha = 0.10 selected a genuinely compressed keep-size member while certifying worst-case task-success loss.
Calibrating Per-Turn Tool Keep Sizes via Conformal Risk Control
Engineers deploying 50+ MCP tools in vLLM or custom agent harnesses can replicate TRACE's calibration step offline on a small validation split of tool traces, computing the monotone majorant threshold k_hat that caps expected turn breakage under alpha.
import numpy as np
def calibrate_crc_keep_size(loss_matrix: np.ndarray, k_grid: list[int], alpha: float = 0.10):
"""
loss_matrix: shape (n_calib, len(k_grid)), binary/bounded task loss in [0, 1]
where larger K yields <= loss.
"""
n = loss_matrix.shape[0]
for idx, k in enumerate(k_grid):
# Finite-sample CRC upper bound: (sum(L_i) + 1) / (n + 1) <= alpha
empirical_risk = (loss_matrix[:, idx].sum() + 1.0) / (n + 1.0)
if empirical_risk <= alpha:
return k, empirical_risk
return k_grid[-1], 0.0Why Relevance Beats Perplexity for Agent KV Caches
Perplexity-tuned compressors preserve boilerplate JSON syntax uniformly across all 28 tools; TRACE preserves 100% of the 2–5 relevant schemas intact and evicts irrelevant schemas completely.
Scaling to 2,500+ MCP Tools in Smoke Monkey Harness
When Smoke Monkey Harness connects to large MCP catalogs, dumping every tool schema into the system prompt burns VRAM and throttles prefill latency. Combining per-turn semantic tool ranking with TRACE-style conformal keep-size bounds keeps GPU KV memory flat while guaranteeing the agent retains the exact schemas needed for the active task.
Frequently Asked Questions
Q:Why do standard KV cache compression methods struggle on tool-calling agents?
On benchmarks like BFCL, unused tool schemas make up 77% to 86% of the prefix. Perplexity-driven token eviction cannot tell which JSON schema is relevant to the current turn and degrades active schemas.
Q:What guarantee does TRACE's Conformal Risk Control (CRC) layer provide?
CRC calibrates the per-turn tool keep size `K` on historical traces so that expected task-success loss from cache eviction stays within a user-chosen distribution-free risk budget such as `alpha = 0.10`.
Q:How much prefix memory does TRACE save?
At `alpha = 0.10`, TRACE achieves 3.9x to 6.2x eviction-only reduction across all four evaluated settings, retaining 17% of base prefixes and 25% of long-context prefixes at best-effort points.
Q:Does TRACE require fine-tuning the underlying LLM?
No. TRACE operates at prefill/eviction time using a lightweight external tool relevance predictor and conformal keep-size calibration over an existing frozen model.
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.