Part of the Determesh series.
What
Model APIs are stateless. Every call sends the whole prompt. Providers soften that with a prefix cache: if a request starts with exactly what an earlier request sent, that part is read from cache at a fraction of the price. Determesh builds every prompt so that as much of it as possible is an exact repeat of the last one.
Measured on real traffic, 77 percent of the orchestrator’s prompt tokens are served from cache.
Why
The orchestrator rereads everything
The orchestrator’s conversation grows with every round: the user’s messages, each tool call, each resource’s answer. A five round request sends the system prompt five times, the first message five times, the first answer four times. Without caching, cost grows with the square of the conversation length.
The cache is exact
A prefix cache does not forgive. Change one character near the top, and everything after it misses. Prompt caching is not a setting to switch on. It is a property of how prompts are assembled, and every bit of convenience, like a timestamp in the system prompt, can quietly turn it off.
On DeepSeek the cache is automatic and matched in fixed-size chunks, so short prompts never benefit. Anthropic’s models need explicit cache points. The design below works for both.
How
Most stable first
Every role’s prompt is ordered by how often each part changes:
- The role’s system prompt. Ours, and the same for every company.
- The company’s summary and settings. Changes when the admin edits them.
- The user’s style note, for the reply writer only.
- The thread summary, after compaction.
- The messages since the summary.
- The new message.
The first block is shared by every company, so it is cached across all of them. The second is shared by every user of one company. Only the tail is unique.
Append only
Nothing earlier in a conversation is ever edited. A tool result is not rewritten when a later one supersedes it. A message is not reformatted. Fields in any structured block always come in the same order.
Each role’s conversation is append-only on its own, and each has its own cache entries. The orchestrator’s and the resource assistants’ conversations benefit most, because they keep growing. The reply writer and the evaluator start fresh each time, so only their fixed system prompt is cached, which is still most of their input.
Time without breaking the prefix
Models need to know the time. Without today’s date, the evaluator once marked real data as invented because the dates looked like the future. Without send times, a user asking “what did I say yesterday” got “I have no record of that”, because the whole thread read as one moment.
Both are solved without touching the cached top:
- Today’s date goes into each role’s prompt. It changes once a day, so the cache holds all day.
- Send times are stamped on each user message as it is added, like
[sent 2026-10-22 23:46 UTC]. Past messages never change, so their stamps never change. Only user messages are stamped, so the model does not copy the tag into its replies.
The system prompt also says the user may be in another time zone, so “tomorrow morning” is not taken as UTC.
Per-run context goes after the cached start
Some context changes every run: the channel the message came in on, the user’s email on file, requests waiting for this person. Those go as lines after the stable conversation, not into the system prompt. The cache covers everything up to them.
The panel shows those lines as one collapsed step in the thread, and when they are identical to the run before, it just says “same as before”.
Compaction resets, then the cache rebuilds
When a long thread is compacted, the next call is a fresh prompt with the summary in place of the old messages. That one call misses. From then on the conversation grows from the summary and hits again. A compaction costs one full price request, which is far cheaper than sending the uncompacted history every time.
Log it, or it is a guess
Every call records the provider’s cache hit and miss token counts. That is the only way to know caching is working, and the first sign when a change has broken it. The 77 percent figure comes from those rows, not from an estimate.
The same counts feed billing. Cached tokens are charged to the company at the cached price, so the savings reach them too.
Previous: Running the Tool Loop Ourselves
Next: Search, Don’t Browse: Finding the Right Resource