Why Agent Caching Fails and How to Fix It: Structured Intent Canonicalization with Few-Shot Learning
Abstract
Personal AI agents incur substantial cost via repeated LLM calls. We show existing caching methods fail: GPTCache achieves 37.9% accuracy on real benchmarks; APC achieves 0-12%. The root cause is optimizing for the wrong property -- cache effectiveness requires key consistency and precision, not classification accuracy. We observe cache-key evaluation reduces to clustering evaluation and apply V-measure decomposition to separate these on n=8,682 points across MASSIVE, BANKING77, CLINC150, and NyayaBench v2, our new 8,514-entry multilingual agentic dataset (528 intents, 20 W5H2 classes, 63 languages). We introduce W5H2, a structured intent decomposition framework. Using SetFit with 8 examples per class, W5H2 achieves 91.1%+/-1.7% on MASSIVE in ~2ms -- vs 37.9% for GPTCache and 68.8% for a 20B-parameter LLM at 3,447ms. On NyayaBench v2 (20 classes), SetFit achieves 55.3%, with cross-lingual transfer across 30 languages. Our five-tier cascade handles 85% of interactions locally, projecting 97.5% cost reduction. We provide risk-controlled selective prediction guarantees via RCPS with nine bound families.
Figures & tables
| Technique | Domain | Acc. (%) | Latency | Multilingual | Verdict |
|---|---|---|---|---|---|
| LSH (SimHash) | IR/Hashing | 30–40 | ms | No | Reject |
| Semantic hashing | Deep learning | 75–80 | ms | Partial | Maybe |
| Frame semantic parsing | Linguistics | 65–75 | 50–100ms | Limited | Promising |
| Query fingerprinting | Databases | 70–85 | ms | With NER | Useful |
| Winnowing | Plagiarism det. | 35–45 | ms | No | Reject |
| SetFit (contrastive) | Few-shot ML | 91–97 | ms | Yes | Winner |
| Method | Accuracy | Hit Rate | Latency | Training |
| GPTCache @0.70 | 83.1% | 16.9% | ms | None |
| GPTCache @0.85 | 84.8% | 5.6% | ms | None |
| GPTCache KMeans ( ) | 49.1% | 98.3% | ms | None |
| SetFit-EN (22M) | 55.3 1.0% | 98.3% | 2.4ms | 160 examples |
| SetFit-EN 16-shot | 62.6 1.5% | — | — | 320 examples |
| SetFit-Multi (118M) | 55.4% (EN) | — | — | 160 examples |
| Benchmark | Method | Classes | Shots/class | Accuracy |
|---|---|---|---|---|
| MASSIVE | LLM 0-shot (GPT-oss-20b) | 8 | 0 | 68.8% |
| MASSIVE | LLM 4-shot | 8 | 4 | 79% |
| MASSIVE | BERT-base (supervised) | 8 | full | 97.3% |
| MASSIVE | SetFit-EN (22M) | 8 | 8 | 91.1 1.7% |
| MASSIVE | SetFit-Multi (118M) | 8 | 8 | 84.4% |
| CLINC150 | SetFit-EN | 150 | 8 | 85.9% |
| Method | Training | Acc. (%) | Latency | Cost/1K | |
|---|---|---|---|---|---|
| LLM 0-shot (GPT-oss-20b) | 0 examples | 68.8 | 3,447ms | $0.089 | 0.650 |
| LLM 2-shot | 16 examples | 75 | 4,000ms | $0.11 | — |
| LLM 4-shot | 32 examples | 79 | 4,500ms | $0.13 | — |
| Rule-based (W5H2) | 0 examples | 60.7 | ms | $0.00 | — |
| SetFit-Multi (118M) | 64 examples | 84.4 | 5ms | $0.00 | — |
| SetFit-EN (22M) | 64 examples | 91.1 1.7 | 2–5ms | $0.00 | 0.813 |
| Benchmark | Method | AMI | Keys | |||
|---|---|---|---|---|---|---|
| MASSIVE ( , 8 cls) | Oracle | 1.000 | 1.000 | 1.000 | 1.000 | 8 |
| SetFit-EN 8-shot | 0.817 | 0.810 | 0.813 | 0.810 | 8 | |
| GPTCache ( ) | 0.784 | 0.788 | 0.786 | 0.784 | 8 | |
| LLM (GPT-oss-20b) | 0.638 | 0.662 | 0.650 | 0.645 | 8 | |
| Random / APC | 1.000 | 0.277 | 0.433 | 0.000 | 1102 | |
| BANKING77 ( , 77 cls) | Oracle | 1.000 | 1.000 | 1.000 | 1.000 | 77 |
| Family | Languages | Mean Acc. (%) | Range |
|---|---|---|---|
| Indo-European (Indic) | hi, gu, mr, pa, ne, si, ur | 33.5 | 17.0–44.5% |
| Indo-European (Slavic) | cs, ru, uk | 50.7 | 47.5–54.0% |
| Indo-European (Germanic) | da, no | 46.0 | 42.0–50.0% |
| Indo-European (Romance) | ro | 51.0 | — |
| Dravidian | ta, te, kn, ml | 15.8 | 12.5–20.5% |
| Turkic | az, uz | 46.0 | 44.0–48.0% |
| Benchmark | Condition | Classes | Rate | Acc | |||
|---|---|---|---|---|---|---|---|
| MASSIVE ( ) | Raw-17 W5H2 map | 18 | 0.842 | 0.840 | 0.841 | 3.0 | 93.3% |
| W5H2-8 (ours) | 8 | 0.791 | 0.777 | 0.784 | 3.0 | 88.8% | |
| Target-only (7 cls) | 7 | 0.770 | 0.843 | 0.805 | 2.8 | 94.1% | |
| Action-only (5 cls) | 5 | 0.491 | 0.686 | 0.573 | 2.3 | 81.8% | |
| Random-8 (control) | 8 | 0.495 | 0.490 | 0.492 | 3.0 | 68.0% | |
| BANKING77 ( ) | Raw-77 | 77 | 0.831 | 0.836 | 0.833 | 6.3 | 78.4% |
| Decomposition | MASSIVE (8-cls) | NyayaBench v2 (20-cls) | ||||
|---|---|---|---|---|---|---|
| Acc. (%) | Classes | Acc. (%) | Classes | |||
| W5H2 (What, Where) | 90.1 | 0.804 | 8 | 52.4 | 0.603 | 20 |
| Target-only | 92.7 | 0.819 | 7 | 52.8 | 0.452 | 13 |
| Semantic Role (Action, Patient) | 86.8 | 0.783 | 11 | 49.1 | 0.763 | 49 |
| Nyaya Pramana Ensemble | 82.4 | 0.787 | 8 | 48.0 | 0.516 | 20 |
| Verb-only (ablation) | 74.1 | 0.554 | 5 | 42.8 | 0.641 | 40 |
| Benchmark | Coverage | Acc. (cached) | Unsafe % | ||
|---|---|---|---|---|---|
| MASSIVE | 0.00 | 100% | 92.4% | 7.6% | 1,102 |
| 0.25 | 88.0% | 95.4% | 4.6% | 970 | |
| 0.35 | 58.5% | 98.6% | 1.4% | 645 | |
| 0.60 | 3.4% | 100% | 0% | 37 | |
| NyayaBench v2 | 0.00 | 100% | 55.7% | 44.3% | 280 |
| 0.15 | 42.5% | 69.7% | 30.3% | 119 |
| Benchmark | Method | Accuracy | Consistency | Train time | |
|---|---|---|---|---|---|
| MASSIVE (8-class) | Vanilla | 91.56 1.47% | 0.819 | 89.4% | 4.5s |
| Consist-Reg | 90.92 1.59% | 0.808 | 89.0% | 15.5s | |
| s | |||||
| NyayaBench v2 (20-class) | Vanilla | 21.6 1.8% | 0.179 | 66.5% | 10.0s |
| Consist-Reg | 21.7 1.5% | 0.188 | 58.8% | 39.0s | |
| s |
| Strategy | Monthly Cost | Savings | Local % |
|---|---|---|---|
| No Cache (all Claude Sonnet) | $31.72 | — | 0% |
| APC (6% hit rate) | $29.82 | 5.9% | 6% |
| GPTCache (37.9% hit rate) | $19.70 | 37.9% | 37.9% |
| W5H2 (85% local) | $0.80 | 97.5% | 85% |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Language | Accuracy (%) | Family |
|---|---|---|
| az (Azerbaijani) | 48.0 | Turkic |
| cs (Czech) | 54.0 | Slavic |
| da (Danish) | 42.0 | Germanic |
| el (Greek) | 49.5 | Hellenic |
| fi (Finnish) | 43.5 | Uralic |
| gu (Gujarati) | 40.0 | Indic |
| W5H2 Class | EN Test | Accuracy (%) |
|---|---|---|
| check_info | 155 | 57.4 |
| control_home | 146 | 86.3 |
| create_content | 135 | 48.9 |
| search_web | 109 | 54.1 |
| manage_tasks | 104 | 26.9 |
| analyze_data | 84 | 46.4 |
| Benchmark | Method | AMI | FMI | Rate (bits) | |||
|---|---|---|---|---|---|---|---|
| MASSIVE | Oracle | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 3.00 |
| SetFit-EN | 0.817 | 0.810 | 0.813 | 0.810 | 0.833 | 3.00 | |
| GPTCache ( ) | 0.784 | 0.788 | 0.786 | 0.784 | — | 3.00 | |
| LLM (GPT-oss-20b) | 0.638 | 0.662 | 0.650 | 0.645 | — | 3.00 | |
| GPTCache ( ) | 0.534 | 0.835 | 0.652 | 0.650 | — | 2.00 | |
| Majority (1 key) | 0.000 | 1.000 | 0.000 | 0.000 | 0.408 | 0.00 |
| Scale | Req/day | No Cache | GPTCache | W5H2 | Savings |
|---|---|---|---|---|---|
| Individual | 50 | $31.72 | $19.70 | $0.80 | 97.5% |
| Power User | 200 | $126.90 | $78.80 | $3.19 | 97.5% |
| Small Team (5) | 1,000 | $634.50 | $394.02 | $15.95 | 97.5% |
| Startup (50) | 10,000 | $6,345 | $3,940 | $159 | 97.5% |
| Enterprise (500) | 100,000 | $63,450 | $39,402 | $1,595 | 97.5% |
LLM Agent Serving
Large language model agent serving runs tool-using, multi-step agents efficiently by coordinating inference, memory, and workflow execution.
See all 35 papers