SShortSingh.
Back to feed

Claude Code Caching Cuts Token Use by Up to 60% in Long Agent Sessions

0
·1 views

Anthropic's Claude Code platform features a tool result caching mechanism that stores outputs from repeated file reads and shell commands during extended coding sessions. When an identical tool call with the same parameters is made again within a session, the API returns a cached result at a significantly lower token cost instead of re-executing the operation. Redundant tool calls—such as reading the same configuration files dozens of times—typically account for 40–60% of total token consumption in multi-hour sessions. Cache entries for file reads are automatically invalidated when a file is modified, while shell command caches may require manual invalidation to reflect system changes. Sessions that vary parameters unpredictably or trigger frequent file rewrites can defeat the caching mechanism entirely, negating its efficiency benefits.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Developer cuts LLM inference costs 45% using self-hosted vLLM on cloud GPUs

A developer building autonomous AI agents and real-time LLM-driven applications found commercial API costs unsustainable due to high volumes of tool calls and token usage. To address this, they deployed a self-hosted inference cluster on cloud GPU platforms RunPod and Vast.ai using the open-source vLLM framework. The setup leveraged PagedAttention, continuous batching, speculative decoding, and prefix prompt caching to optimize performance and memory usage. Benchmarks across 1,000 synthetic agentic prompts showed average Time-To-First-Token dropped to 172ms, compared to roughly 420ms for commercial APIs. The configuration also reduced inference costs by approximately 45% to 74%, bringing estimated spend per million requests down from $1,850 to around $480.

0
ProgrammingDEV Community ·

RAG System Silently Indexed Only 62% of Corpus Due to NFS Blind Spot

A developer discovered that their self-hosted RAG knowledge base had only indexed 62% of its intended corpus, despite all monitoring dashboards showing healthy green statuses. The root cause was the indexer's reliance on inotify filesystem events, which do not propagate across NFS mounts, meaning documents written from remote machines were never detected. Because the system always returns an answer from whatever it has indexed, the coverage gap went unnoticed — the failure was in ingestion, not in the language model itself. The developer also highlighted a broader measurement pitfall: reporting only documents successfully indexed without defining the total eligible corpus turns a metric into a misleading figure. The fix involved replacing event-driven watching with periodic polling using stat(), which works across network filesystems by actively querying rather than waiting for notifications.

0
ProgrammingDEV Community ·

Four Books That Reframe AI as a Social and Political Problem

A developer writing for DEV Community argues that understanding AI requires moving beyond technical literature toward social and philosophical texts. After reading Yuval Noah Harari's Sapiens, the author highlights how AI systems encode societal myths about human worth into algorithmic decisions rather than delivering neutral logic. Cathy O'Neil's Weapons of Math Destruction is cited for exposing how opaque algorithms structurally amplify inequality while shielding decision-makers from accountability. Bruno Latour's We Have Never Been Modern is described as the most challenging read, arguing that technology and values cannot be separated and that AI systems must be governed as social-technical hybrids. The author's central thesis, shaped by Blake's NEXUS, is that debates about AI safety miss the point unless they address who controls these systems and for what purpose.

Claude Code Caching Cuts Token Use by Up to 60% in Long Agent Sessions · ShortSingh