DeepSeek V4 Agents Got 4x Faster When We Moved The Clock
Verdict: if you serve DeepSeek V4 to agents on llama.cpp, put nothing that changes per turn in the system message. We moved one block of text, the live clock and a few lines of system state, from the end of the system prompt to the head of the user's turn. Prompt time from the second turn on dropped from 6.8 s to 1.55 s on our V4 Flash pool.
| Same agent turn, sent twice | Turn 2 re-read | Served from cache | Prompt time |
|---|---|---|---|
| Clock in the system prompt | 2,514 tokens | 1,610 | 6.8 s |
| Clock at the head of the user turn | 516 tokens | 3,632 | 1.55 s |
That is a 2.1k-token system prompt with 24 tool schemas, measured on DeepSeek V4 Flash running on a DGX Spark. On a real agent with a 6.2k-token prompt, the second call went from re-reading 6,226 tokens in 15.5 s to 517 tokens in 1.6 s.
Why one line of text costs a whole prompt
Every agent call in AitherOS starts with a system message built in layers: identity, rules, capabilities, and then a short dynamic tail, the current time and a few lines of live state. That tail is what lets an agent answer "what time is it" or "is the GPU busy" without a tool call. It changes on every turn.
On most models this costs nothing. llama.cpp keeps the previous prompt's KV cache, finds the longest shared prefix with the new prompt, and only processes what changed. A clock at the end of the system text invalidates a few dozen tokens.
DeepSeek V4 is different in two ways that compound:
- Its compressed attention cache cannot be truncated. llama.cpp cannot cut V4's cache back to an arbitrary token. It resumes from a saved checkpoint near the end of the previous prompt or starts over. A prompt that diverges early is re-read almost in full.
- Its chat template renders the tool schemas after the system message. We checked with
llama.cpp's
/apply-templateendpoint. Even a second system message is hoisted in front of the tools block. So the clock sat in front of every tool definition and the whole conversation.
Put together, a timestamp near the top of the prompt meant every turn re-read the tools and the history. Without tools the effect disappears: both layouts reused the cache in our test, because the divergence then falls close enough to the end. Agents carry tools, so agents paid.
The fix
Our inference queue now moves the dynamic tail out of the system text, for the V4 lane only, right before the request goes to llama.cpp. The tail goes to the head of the last user message, marked as platform context so the model does not read it as the user's words:
[TURN CONTEXT - provided by the platform for this turn, not written by the user]
[SYSTEM STATE]
clock 13:41:07
...
The stable part of the system text, the tool schemas and every earlier turn now form a prefix that repeats exactly across an agent's calls. The only new tokens on turn 2 are the moved tail, the new user message and the reply.
Three details made it safe to ship:
- It is a pure function. It returns a new message list and never mutates the caller's payload, so retries and logging see what the agent built.
- It is advisory. If the layout step fails for any reason the request goes out unchanged. A layout tweak never breaks a call.
- It knows about our other cache mode. When the pool runs in KV-slot mode, which snapshots the system prefix itself, the move is skipped, because that mode computes its cut from the system text.
What to take from this
- Check where your template puts the tools.
/apply-templateon llama-server shows the exact rendered prompt. If tools come after the system message, everything in the system message is in front of them. - Measure
cache_n, not just latency. llama-server returnstimings.prompt_nandtimings.cache_non every response. Send the same agent turn twice. Ifprompt_non the second call is close to the full prompt, something early is changing. - Keep the system message byte-stable across turns. Time, telemetry, per-request IDs: anything that changes belongs in the turn, not the prefix.
This shipped today on the pool that serves every AitherOS agent. Earlier V4 Flash numbers are in DeepSeek V4 Flash at 27 tokens a second on one desk.
The Desk-Side Stack · part 4 of 8
- The KV-Cache Translator That Couldn't Exist
- DeepSeek's Latent Cache Is 3× Smaller. That Makes It Easier, Not Harder.
- NVIDIA Made KV Caches Portable Between Models. We Shipped It The Same Day — On A CPU.
- DeepSeek V4 Agents Got 4x Faster When We Moved The Clock
- A 32,000-Token Document, Answered From 144 Tokens
- 262,144 Tokens on a Desk, and 98.5% of the Next Turn Already Cached
- Opus Plans, DeepSeek Executes: Our Coding Agent Runs on a Tier Map
- Frontier Tokens Are for Deciding, Not for Digging
Keep the journal free
Sponsorship pays for the compute, the hardware and the hours behind these entries.
by email
New journal entries, in your inbox.
What the agents built, broke and fixed. One message per entry.