# Google's developer blog on agent context cost, and a measured host-side fix: 169x fewer tokens a step (Gemini 3.8 Flash)

> Source: <https://dev.to/shalendra_gaur_ecd0567a49/googles-developer-blog-on-agent-context-cost-and-a-measured-host-side-fix-169x-fewer-tokens-a-4phb>
> Published: 2026-11-24 17:04:31+00:00

**Recommendation:** Rebuild a short prompt from host-held state each step instead of resending the full chat history, and validate model proposals against rules before committing them.
More in the playbook "Designing agent systems": <https://wpnews.pro/playbooks/agent-architecture>

In December 2025 the Google Developers Blog described what happens in production agent systems: cost and time to first token climb as the context grows, stale context hurts the model, and a bigger window does not remove the problem ([Hangfei Lin, "Architecting efficient context-aware multi-agent framework for production"](https://developers.googleblog.com/architecting-efficient-context-aware-multi-agent-framework-for-production/)). A developer on the Google developer forums describes a session growing from about 2K to over 80K tokens in five turns, with latency, drift and cost following ([ADK thread, September 2026](https://discuss.google.dev/t/best-practices-for-handling-context-compaction-and-token-blowup-in-recursive-adk-agent-tool-loops/396215)). The Gemini caching documentation explains the cost saving that implicit caching passes on; it gives no latency figure ([Context caching](https://ai.google.dev/gemini-api/docs/caching)).

All of these are about a conversation that carries its own history. We measured the other way: do not carry it.

AXI, by **Rajnish Choubey**, is a layer on the host side, between a model and the state it edits. The model is unchanged. At every step it proposes one change; the host checks the proposal against the rules, completes what the rules can complete, commits it all or not at all, and shows the model the exact state again in a short prompt rebuilt from what the host holds. Nothing is kept in the chat.

One long, heavy job on Gemini 3.8 Flash: a service graph edited request by request, 1,500 requests, each with about 40 lines of routine operations log. Once with the whole chat kept and sent again at every turn (until it reached the model's window: 457 turns, 949,591 tokens), once with AXI.

|  | Chat kept | AXI | 
|---|---|---|
| Prompt tokens per step | 476,835 on average | 2,824, flat for all 1,500 steps (169 times fewer) | 
| Tokens sent in all | 217.5 million in 457 turns | 4.6 million in 1,500 steps | 
| First token, median | 9.13 s once the prompt passes 500,000 tokens | 2.27 s, flat (2.15 to 2.35 s in every tenth) | 
| Seconds a step | 7.13 on average | 3.07 | 
| State if each reply is applied as it comes | exact until turn 286, wrong on every turn after | exact on 1,500 of 1,500 steps | 
| Exact steps an hour | 488 | 1,157 | 

On a second job, a 400-turn conversation in plain, ambiguous sentences, the same model sent 39.9 million tokens with the chat kept and 0.53 million with AXI (76 times fewer). Once the prompt passed 150,000 tokens the kept chat's first token took a median 5.57 s with 97.0 percent of its prompt served from the cache; AXI's stayed at 2.41 s.

And a different question, on the same model: 4,000 consecutive steps of a dense job with strict rules. The state the host held was exactly the intended state on 4,000 of 4,000 steps. The model's own replies were exactly right on 3,954; on the other 46 it had left out a service's dependants when asked to delete the service and an edge, and the fixed repair rule completed them. Applied as written, those replies would each have left edges pointing at a deleted service. On the first 400 requests the replies applied as written left the right state on 85 steps, and a step with the right state cost 4.5 times as much.

No key, no model, no GPU:

```
git clone https://github.com/gaurshalendra2412/axi-runtime
cd axi-runtime/python
python3 quickstart_replay.py
```

It replays the saved real replies of the 4,000-step run through the repository's own code and recomputes the held state at every step; it stops with an error if one replayed step differs from the saved one. Prefer a browser: there is a [one-click Colab notebook](https://colab.research.google.com/github/gaurshalendra2412/axi-runtime/blob/main/python/colab/axi_try_it.ipynb). With your own Gemini key (a free one is enough) `python3 live_check.py` runs the same harness live for 15 steps.

These are one job and one run of each arm on one model, and every claim is about the state the host holds, not about the model in general or anyone's servers. A reply that is readable, inside the request's scope and wrong is applied; the gate and the repair keep what is true and cut what is false. This is not affiliated with Google.

Other groups build commit boundaries around agent state with their own settings and evaluations: [Cordon](https://arxiv.org/abs/2606.17573) and [MemTX](https://arxiv.org/abs/2607.23929). The repository's related-work page says the idea of a commit boundary is not ours to claim.

Tests built and run by Shalendra Gaur, with an AI coding assistant as a tool (disclosed in the README).
