Why Local Agents Crash: A Real-World Report from 4,265 Actual Sessions

Real-world testing of 4,265 sessions reveals tool lists and KV cache limits as the true killers of local AI Agents.
A developer's month-long study of 4,265 Claude Code/Codex sessions exposes why local Agents fail on consumer hardware. Tool definitions alone consume 41% of KV cache at median, q4_0 quantization causes 280%+ perplexity degradation on small models, and even oracle-level eviction strategies only improve throughput by 11.88%. The report recommends q8_0 KV cache, trimming tool lists, and session-based cache release as the most impactful optimizations.
One Month of Testing: The Truth Behind Local Agent Crashes on Consumer Hardware
As the wave of local LLM deployment grows, more and more developers are trying to run coding Agents (like local alternatives to Claude Code and Codex) on personal computers. However, reality falls far short of expectations. One Reddit developer spent an entire month meticulously measuring 4,265 real Claude Code / Codex sessions, arriving at a series of sobering conclusions.
Every number here is measured, not estimated. That's what makes this report so valuable—it transforms the vague question of "where exactly do local Agents get stuck" from fuzzy intuition into quantifiable engineering facts.

Core Finding: 75% of Real Sessions Simply Don't Fit
When running on a 16GB Mac, in three-quarters of real sessions, at least one conversation turn had a prompt larger than the entire KV cache pool. Note: this was measured with no other programs running.
In other words, many developers assume local models fail because "the model is too big" or "there's not enough VRAM," but the real bottleneck often emerges at the context management layer—your prompt overflows the cache before any substantive conversation even begins.
To understand this problem, you need to know how KV cache works. KV cache (Key-Value Cache) is the core optimization mechanism for Transformer model inference. During autoregressive generation, the model needs to compute attention over all previous tokens for each new token generated. KV cache stores the Key and Value matrices of previous tokens to avoid redundant computation. However, KV cache memory usage scales linearly with sequence length and is proportional to the number of model layers and attention heads. For example, a model with 32 layers, 32 heads, and dimension 128 uses approximately 0.5MB of KV cache per token in fp16—an 8K context session requires about 4GB of KV cache space. This is why KV cache becomes a more intractable bottleneck than model weights on consumer hardware.
The Culprit: Tool Lists
The author's measurements point to a counterintuitive conclusion: the number one culprit dragging down local Agents is tool definitions (tool list).
In modern AI Agent frameworks, tool definitions are injected into system prompts as structured JSON Schema. Each tool requires a description of its name, functionality, parameter types, required/optional fields, and more. A coding Agent like Claude Code might need to define dozens of tools for file I/O, terminal execution, search, Git operations, etc., with each tool definition consuming 200-500 tokens. When tool count reaches 30-50, the tool list alone can consume 6,000-15,000 tokens. These tokens must be fully retained in context every conversation turn, since the model needs to decide which tool to call at any moment.
System Prompt + Tool Definitions Eat Half the Cache
Before any conversation begins, the system prompt plus tool definitions consume 41% of the cache pool at the median; at p90 (90th percentile), it reaches 105%—meaning these "opening remarks" alone already exceed the entire cache capacity.
This means that for Agent applications heavily dependent on tool calls, the first optimization step isn't switching to a stronger model or adding memory—it's trimming the tool list. Every unnecessary tool definition directly erodes the already limited context space.
Smart Eviction Strategies Don't Help
Many people's first reaction is: let's design a smarter cache eviction strategy. The author throws cold water on this idea.
He built a simulator calibrated against vLLM with only 0.29% error. vLLM is a high-performance LLM inference engine developed at UC Berkeley, whose core innovation is PagedAttention—splitting KV cache into fixed-size memory pages, similar to OS virtual memory management. Cache eviction strategies borrow from CPU cache and database buffer management approaches, with common strategies including LRU (Least Recently Used), LFU (Least Frequently Used), and FIFO (First In, First Out). The Oracle strategy is a theoretical baseline assuming the system can perfectly predict which cache entries will be reused (similar to Bélády's algorithm), representing the theoretical optimal upper bound for eviction strategies.
Using this reliable simulation environment, he tested various eviction strategies:
- Best real-world available strategy: only +2.75% improvement
- A "clairvoyant" cheating Oracle: only +11.88%
11.88% is the theoretical ceiling. In other words, spending enormous effort designing clever eviction algorithms yields extremely limited returns. Even more interesting: a fixed TTL (Time-To-Live) strategy performs worse than simply releasing the cache when a session ends. TTL is a simple time-based strategy where cache entries automatically expire after a fixed duration—but in Agent scenarios, session boundaries themselves are the most natural cache lifecycle demarcation points.
KV Cache Quantization: q4_0 Is a Trap
To save memory, many people quantize their KV cache. Quantization maps high-precision floating-point numbers to low-bit integers: q8_0 means quantizing each value to an 8-bit integer (no offset), q4_0 means 4-bit. The author's measurements reveal a serious trap.
q4_0 Destroys Small Models
On Qwen3-0.6B, q4_0 quantized KV cache performs catastrophically poorly, and gets worse as context grows longer:
| Context Length | q8_0 | q4_0 |
|---|---|---|
| 512 | +0.07% | +280% |
| 2048 | +0.07% | +302% |
| 8192 | +0.03% | +525% |
The percentages here refer to perplexity degradation relative to the fp16 baseline. Perplexity is the standard metric for measuring language model prediction quality—lower values indicate more accurate predictions. +280% means the model's prediction quality has catastrophically collapsed, making output virtually unusable.
What you might not have noticed: q4_0's absolute perplexity bottoms out around 2K tokens, then actually worsens as context increases—beyond 2K, more context means worse results. This means quantization error accumulates and amplifies through the attention mechanism as sequence length grows.
The Problem Is in the Keys
The author further decomposed the issue and found the crux lies in Key quantization:
- K in f16, V in q4_0: only +0.33%
- Both K and V in q4_0: +280%
The difference is approximately 850x. Key matrices are more sensitive to quantization because the dot product between Query and Key in the attention mechanism directly determines the attention weight distribution—small quantization errors in Keys get amplified before softmax, causing severe attention allocation drift. Value matrix quantization errors only linearly weight the final output, making their impact relatively minor. This asymmetry is an important finding in recent KV cache compression research.
But that mixed configuration (K in f16, V in q4_0) is actually larger than pure q8_0 and 5x slower on Metal. So the conclusion is straightforward: use q8_0 for both K and V—2x capacity improvement with only about 0.06% perplexity cost.
Cache Expiration and the Hidden Cost of Memory Layers
Anthropic's Cache Expires in 5 Minutes
The author observed that Anthropic's prompt caching mechanism is "all or nothing." Anthropic's prompt cache is an API-level optimization: when consecutive requests share the same prefix (like system prompts and tool definitions), the server caches the computed KV state, and subsequent requests only need to compute the new portion (incremental prefill). Prefill refers to the phase where the model processes the input prompt, requiring parallel attention computation over all input tokens—as opposed to the token-by-token decode phase—making it the most computationally intensive part of inference.
Measured data shows:
- Interval less than 5 minutes: only needs to re-prefill 2,559 tokens
- Interval over 5 minutes: needs to re-prefill 140,154 tokens
A 54.8x difference. You either refresh the cache in time or lose everything—there's no middle ground. Prefilling 140,154 tokens takes several seconds even on an A100 GPU, meaning cache invalidation causes significant latency and cost increases (Anthropic charges less for cache-hit requests). The 5-minute TTL means the developer's interaction pace directly impacts cost—thinking too long causes the entire cache to expire.
Token Overhead of Memory Layers
In the memory layer comparison, the differences are equally striking:
- Mem0: injects 116 tokens per turn
- MemPalace: injects 12,513 tokens per turn (108x)
Mem0 and MemPalace represent two different long-term memory management philosophies. Mem0 uses lightweight structured memory extraction, compressing conversation history into concise factual memory entries (e.g., "user prefers Python," "project uses React framework"), injecting very few tokens each time. MemPalace uses a richer memory palace metaphor, retaining more contextual detail and relationships at the cost of massive token overhead. Top-k=20 means retrieving the 20 most relevant memories from the memory store to inject into context.
With top-k=20, MemPalace alone can blow out the entire cache pool. The author also notes that most of the memory layer's benefit actually comes from not sending complete history, rather than the memory mechanism itself—an illuminating insight for understanding the true value of memory layers. This means memory systems primarily benefit from compressing and filtering historical information, not from memory retrieval accuracy. A simple history summary might achieve 80% of a memory system's effectiveness.
Four Practical Tips for Local Agent Users
Combining all measurement results, the author provides an extremely pragmatic optimization checklist:
- Enable q8_0 KV cache — 2x capacity with only ~0.06% perplexity cost
- Prioritize trimming tool lists — this is the biggest space killer
- Release cache immediately when sessions end — more effective than fixed TTL
- Don't bother designing clever eviction strategies — the ceiling is only 11.88%
The author also honestly lists limitations: perplexity experiments used only one small model (Qwen3-0.6B); quantization sensitivity is highly dependent on specific model architecture and parameter scale; perplexity doesn't equal task accuracy—degradation in actual coding tasks could be more or less severe; the simulator models memory block allocation rather than end-to-end latency. This rigorous attitude significantly boosts the report's credibility.
Self-Hosting vs. API: A Question Worth Pondering
At the end of the report, the author poses a thought-provoking question: these are all measurement data, but he's not sure whether these problems are worth paying to solve, or merely annoying.
He asks those who actually use local models for work (not as a hobby):
- Why did you choose self-hosting over APIs?
- What broke unexpectedly?
- Did you spend money fixing it (hardware, consultants, tools, labor)? Roughly how much?
- What other broken things would you pay to fix?
These questions touch on the most fundamental business and engineering contradiction in the local deployment wave: self-hosting saves API costs, but trades them for massive hidden engineering optimization costs. Taking the issues revealed in this article as an example, a team might spend weeks understanding and solving KV cache overflow problems—time costs that often far exceed the cost of simply using APIs. For any team considering local Agent deployment, this measured data serves as an invaluable "pitfall avoidance guide"—using hard numbers to tell you which optimization directions are worth pursuing and which are dead ends.
Key Takeaways
Related articles

Gemini 3.7 Flash Spotted in Google Cloud Console — Launch Countdown Begins
Developers spot Gemini 3.7 Flash in Google Cloud Console, sparking discussion about its relationship to Pro and Google's model distillation strategy.

AI-Memory: Building a Cross-Tool Long-Term Memory System for Coding AIs
AI-Memory is a Rust-based open-source project providing long-term memory for Claude Code, Cursor, Aider and other Agent coding CLIs, enabling seamless handoff between vendors.

Bullet Enters the Stage: YC Newcomer Bets on a Faster Coding Agent
YC S26 startup Bullet launches a speed-focused coding Agent targeting developer latency pain points. Analysis of its differentiation, acceleration techniques, and market opportunity against Cursor and Claude Code.