Multi-Tier Caching for AI Agents in Production: The 2026 Guide

A production AI agent makes hundreds of LLM calls and thousands of tool invocations daily [1]. Most teams cache the LLM responses — but stop there. The result: repeated tool executions hit the same APIs, session state recomputes on every turn, and costs scale linearly with traffic.
Two new open-source projects are changing this in 2026. Agent-cache, a multi-tier caching SDK backed by Valkey or Redis, unifies three cache tiers behind a single connection with framework adapters for LangChain, LangGraph, and Vercel AI SDK. The Calfkit SDK takes a different architectural approach — event-driven agents on Kafka with built-in state management.
This post focuses on the caching problem: what the three tiers are, when each matters, and how to implement them.
The Cache Blind Spot in AI Agent Development
Most agent stacks start with per-LLM-response caching. The pattern is simple: hash the prompt + model + temperature, check cache, return cached if hit. LangChain has CacheBackedLLM, Vercel AI SDK has experimental_cache. This tier alone cuts API costs by 40-60% for deterministic workloads [1].
But two other cache tiers are routinely ignored:
- Tool result caching. An agent that calls
search_web("latest AI news")once per turn — or across different agents in a multi-agent setup — hits the same search API with the same query. That’s wasted latency and API cost. - Session state caching. Every conversation turn recomputes the full session context. For multi-hour agent sessions with large tool outputs, this adds seconds per turn.
A 2025 survey of production agent deployments found that only 23% of teams had any form of agent-level caching beyond LLM responses [1]. The early 2026 landscape is changing fast.
Three Tiers of Agent Caching
Tier 1: LLM Response Cache
Hashes the complete input (system prompt + messages + tools) and stores the generated completion. Effective for:
- Repeated system prompts with minor variations
- Structured output extraction (same schema, different inputs are rare)
- Agent retries on transient failures (reuse previous successful path)
Tools: CacheBackedLLM (LangChain), experimental_cache (Vercel AI SDK), litellm.cache.
TTL should be short — 5-15 minutes for most production workloads. Cache poisoning is a real risk when serving cached LLM responses across different user sessions.
Tier 2: Tool Result Cache
Caches the output of tool invocations keyed by (tool_name, arguments_hash, timestamp_bucket). Critical for:
- Search/web scraping tools — same query returns same result within a time window
- Database queries — SELECT results that don’t change frequently
- API calls with rate limits — cache reduces hitting the rate ceiling
A common pattern in 2026 production deployments: tool result cache with a configurable TTL per tool type. Search results get 5-minute TTLs, database lookups get 30-second TTLs, file system reads get 60-second TTLs.
Tier 3: Session State Cache
Stores the running agent state — conversation history, accumulated tool outputs, intermediate variables — so that on reconnect or multi-turn interactions, the agent doesn’t recompute everything from scratch.
This is the most neglected tier. Most frameworks store session state in-memory, which doesn’t survive process restarts. A multi-tier approach stores session state in Redis/Valkey with periodic snapshots to object storage.
The Agent-Cache Pattern
The new agent-cache SDK (flagged on Hacker News in May 2026 with 18 points [2]) implements all three tiers behind a single Valkey or Redis connection. Key design decisions:
- No modules required. Works on vanilla Valkey 7+ and Redis 6.2+. No Redis Stack or RedisJSON needed.
- Framework adapters. Drop-in integrations for LangChain, LangGraph, and Vercel AI SDK. Each adapter wraps the framework’s native caching interface.
- Observability built in. OpenTelemetry spans and Prometheus metrics for cache hit rates, latency, and eviction counts per tier. Cluster mode support landed in v0.2.0.
- TTL inheritance. Tool and session caches inherit default TTLs from the tier configuration — you set policy once, not per call.
The architectural insight: three cache tiers behind one connection means a single cache cluster handles LLM responses, tool results, and session state. This simplifies deployment (one Valkey cluster instead of three separate caches) and ensures consistent eviction policy across all tiers.
Implementing Multi-Tier Caching
Here’s what a production setup looks like with agent-cache:
from agent_cache import AgentCache, CacheConfig
from agent_cache.adapters import LangChainAdapter
# Configure all three tiers with one config
config = CacheConfig(
host="valkey-cluster.internal",
port=6379,
tier_ttls={
"llm": 300, # 5 minutes
"tool": 60, # 1 minute
"session": 3600, # 1 hour
},
max_memory="4gb",
eviction_policy="allkeys-lfu",
)
cache = AgentCache(config)
# Wrap an existing LangChain agent
adapter = LangChainAdapter(cache)
agent = adapter.wrap(my_langchain_agent)
# Tool caching is automatic — same args = cache hit
result = await agent.tools.search("latest AI news") # first call, cache miss
result = await agent.tools.search("latest AI news") # cache hit, ~5ms
For teams not using framework adapters, the cache can be called directly:
# Direct tool result caching
cache_key = f"tool:search:{hash_query}:{time_bucket}"
if cached := await cache.get(cache_key):
return cached
result = await execute_search(query)
await cache.set(cache_key, result, ttl=60)
return result
Key Takeaways
- Cache all three tiers, not just LLM responses. Tool result caching alone can cut external API costs by 30-50% [1]. Session state caching reduces per-turn latency by 200-500ms for complex agents.
- One cache cluster beats three separate ones. Multi-tier caches behind Valkey or Redis reduce operational overhead and ensure consistent eviction policy.
- Framework adapters reduce integration risk. Agent-cache’s drop-in adapters for LangChain, LangGraph, and Vercel AI SDK mean you don’t need to restructure your agent code.
- Observability is non-negotiable. If you can’t see cache hit rates per tier, you can’t tune TTLs. Agent-cache’s built-in OpenTelemetry and Prometheus metrics make this trivial.
- Short TTLs prevent poisoning. LLM response caches should never exceed 15 minutes in multi-tenant deployments. Tool caches can be longer but need per-tool-type TTL policies.
Sources
- n8n AI Agent Development Tools Landscape Report, 2025
- Agent-cache on Hacker News (18 points, May 2026)
- Calfkit SDK — Event-driven AI agents on Kafka


