Skip to main content
One demo left: the two halves of this course shaking hands. We take the agent workload described earlier and run it on the fleet you spent six modules learning to operate. In this lesson we act as a coding agent across eight turns and observe how a program-scale cache behaves — doing for code what a scratchpad did for conversation. Every real agent session begins with a brief: who you are, which tools exist, the rules, the task, and repository background. Our example prompt is fictional but plausibly shaped. Note its size — this prompt alone is larger than a full cache block.
This session prompt defines available tools and strict rules: each step the agent must choose exactly one tool, explain the choice in one sentence, and stop after proposing the tool call. This constraint forces short, focused tool interactions and simulates an agent operating in a CI environment.
Session prompt (multiline for readability):
Multi-turn loop Each lap of the loop appends a tool result to SESSION, asks the model for the next action, and records prompt token counts and elapsed time. The shell loop below runs eight turns. It mimics a real agent session where tool outputs accumulate in the prompt and make the model’s context grow.
Why context balloons The loop’s additions are what make agent context balloon: each turn adds tool results that contain file paths, test logs, and other real-world noise. Typically, each tool result contributes many more tokens than the model emits in its decision, so the prompt grows fast while the model’s output remains compact. Example observed run (prompt token growth and elapsed wall time):
For quick reference, here’s the same data as a table (useful for SEO and readability): Key observations
  • Tool outputs are verbose and typically account for most of the token growth. In this example, each tool result often contributes roughly six times the tokens the model itself generates.
  • Prompt tokens grow substantially across turns while wall-clock elapsed seconds per turn stay relatively flat. This demonstrates that token count and latency are related but not the same: on CPU-backed workloads, waiting often dominates end-to-end time.
Architectural point The front of the context is previously saved work (the cache/prefill). Each turn only pays for the delta it adds. That incremental shape — previously cached state at the front plus small deltas appended each turn — is the published trace for agent workloads in miniature. Prometheus metrics: measuring program-level cache hit concentration To quantify cache behavior across the fleet, we query Prometheus for prefix cache hits aggregated by pod. The results show concentrated program-level hits: across the 8-turn agent run, almost everything the servers were asked to read was already in cache, and one pod owned the bulk of the program’s cache. Example Prometheus output (prefix cache hits summed by pod over 5m):
Summary table (pod series and hits):
One pod owned the entire program-level cache for this run. This shows how program affinity can concentrate lookups and why routing and cache partitioning are critical design decisions. Also note: on CPU-based serving, overall latency is often dominated by compute and I/O, so token counts alone don’t predict wall-clock waiting.
Why this matters
  • The token counts and Prometheus queries together make the proof emphatic: program-level caching concentrates reads and reduces cross-pod duplication.
  • A single pod can end up owning the program for a multi-turn session, which is efficient for cache utilization but requires careful balancing to avoid hot spots.
  • These observations ground the architectural decisions you’ve seen earlier: splitting prefill from decode, using a router that respects program affinity, and designing fleet configs with observable metrics.
Where to go from here You started with an everyday question you couldn’t see inside, and you built the entire answer: models as files, GPUs/CPUs running them, servers sharing state, token loops producing program behavior, and caches preserving context across turns. Everything you need to reproduce these results — quick starts for building clusters, fleet shapes, and the benchmarks behind speed claims — is published at llm-d.ai. Further reading and references

Watch Video