Cut self-hosted LLM cost and latency with the distributed KV caching agent skill

AWS has published a distributed KV caching skill in its Agent Toolkit for AWS, aimed at teams self-hosting large language models on GPUs. The skill is designed to work inside coding agents that support Agent Skills, including Kiro, Claude Code and OpenAI Codex, and takes a user from a diagnosis of slow first tokens through to a running shared cache on Amazon ElastiCache. AWS frames the payoff in two headline numbers: up to 40% lower inference cost and up to 80% lower time to first token (TTFT) for self-hosted workloads.
The problem the skill addresses is redundant computation. During prefill, a GPU computes key-value attention states for every token in a prompt before it generates a word. When a long conversation resumes, or a request lands on a server that never saw that history, the work is repeated from scratch. A shared cache tier beside the GPU fleet lets any server reload that state for days, surviving sessions, routing changes and server failures. The article illustrates this with a legal assistant holding hundreds of thousands of tokens of case history, where a returning lawyer's first response can take minutes.
The skill's first job is a fit check before any spending. The agent runs a read-only describe-instances call on the GPU fleet and counts Elastic Fabric Adapter (EFA) interfaces. It then asks only for details it cannot observe: engine, model, tensor-parallel size, KV data type, server price and how often prompts repeat. It halts and explains the mismatch if the workload does not fit.
The economics hinge on a cutover point. For short prompts, fetching cached KV state can take longer than recomputing it; past a certain prompt length, the read wins. That threshold combined with prompt repetition rates determines whether the cache pays for itself. AWS says the agent uses a tool called KVTrace to estimate savings from the customer's own traffic at no additional charge, and stops if projected savings do not cover the cache's cost.
KVTrace records KV cache events from vLLM or SGLang and replays them offline against a shared cache of each candidate size. The recorder does not write token IDs or prompt text; traces contain block hashes and token counts. Because block hashes derive from token content, AWS advises passing --anonymize-key-file when prompts are sensitive. Recording should cover a representative window on every GPU server, such as a full business day.
On configuration, the agent adds the LMCache connector to an existing vLLM or SGLang engine, including vLLM workers under serving frameworks such as llm-d and Ray Serve, while preserving routing and engine settings. It then sets every inference server to one KV ID mechanism (hash and seed) and an explicit KV data type. This matters because mismatched settings cause key mismatches, where each server writes state the others cannot locate. Before production traffic, the skill empties local tiers and verifies that two cache-loaded runs produce identical output, since a layout mismatch can yield healthy hit counters alongside wrong answers. High-impact operations such as creating, changing or deleting resources require explicit approval.
Prerequisites are specific: a coding agent supporting Agent Skills; GPU instances that support EFA RDMA write, such as p5; LMCache 0.5.8rc1 or later with vLLM 0.11.1 or later (or SGLang 0.5.13 or later); and, when setting up the cache, ElastiCache for Valkey 9.1 or later on cache.i8ge.48xlarge nodes.
The walkthrough covers four conversations. In the first, a diagnosis for a vLLM fleet serving a legal assistant with 64K-token contexts on p5 instances, where returning users wait 13 seconds for a first token, the agent attributes the delay to cold prefill. It first checks for fixes needing no new infrastructure, such as re-enabling prefix caching, and notes that a GPU prefix cache hit rate already above 90% with session affinity may mean a shared cache is unnecessary. It also raises tenant isolation: a shared cache can let one tenant infer from response times whether another sent the same text, so cases needing isolation get separate caches, and tenants sharing a cache add their own ID to the KV hash.
In the second, an 8-instance p5 fleet serving 64,000-token prompts for a multi-turn retrieval-augmented generation assistant, the agent looks up GPU and cache node prices, derives prefill rates and KV size from benchmarks, and recommends two cache.i8ge.48xlarge nodes. With no cache hit rate supplied, it presents scenarios and recommends a KVTrace run. It also flags that freed GPU time becomes money only if fewer servers are run or more traffic is served on the same ones.
In the third, starting from scratch, the agent confirms the node count, Availability Zone and estimated price before creating a security group with EFA permissions and a Valkey 9.1 cluster with a custom parameter group and eviction policies. LMCache receives its own cache user, with the password held in AWS Secrets Manager; one LMCache server starts per GPU server, and the cluster is checked with a small test object and RDMA-loaded KV state for repeated prompts.
In the fourth, a troubleshooting case, the agent reasons from a symptom pattern where BLOB.RDMA_HELLO succeeds but transfers fail and rdma_write_errors climb in INFO largeobj, and identifies a security group blocking EFA traffic among its own members. It supplies commands to check and fix the rule.
Why it matters: Teams self-hosting models on GPU fleets now have a guided path to a shared KV tier that can lower both cost and latency, provided their workloads have long, repetitive prompts. The skill shifts some sizing and setup judgment to a coding agent, but the prerequisite stack, the EFA-capable instances and the extra cache nodes mean adoption is a real infrastructure decision rather than a config toggle. Expect the fit check and KVTrace measurement to be the gating steps in practice, since AWS ties the published savings figures to workloads that clear the cutover point and repeat enough prompts to justify the cache (inference).
Based on reporting from the original publisher. Visit the source for full context and later updates.
Publisher excerpt
Self-hosting LLMs on GPUs means paying to recompute the same context on every turn. Distributed KV caching with Amazon ElastiCache can cut inference cost by up to 40% and time to first token by up to 80%. This post walks through the distributed KV caching skill in the Agent Toolkit for AWS, which evaluates and sets up the cache from your coding agent.