cd /news/developer-tools/the-tokens-you-have-to-keep-yourself · home topics developer-tools article
[ARTICLE · art-81469] src=pub.towardsai.net ↗ pub= topic=developer-tools verified=true sentiment=· neutral

The Tokens You Have to Keep Yourself

A developer's report on the Rust-based terminal coding agent plank reveals that running the DeepSeek V4 Flash engine in-process turns prompt caching from a provider-side discount into a local data structure requiring manual identity computation and invariant preservation, with no error channel—mistakes silently trigger full recomputation and slower responses. The author chose to port a C agent to Rust to link the engine directly, accepting this caching overhead as a deliberate trade-off for tighter integration.

read1 min views1 publishedJul 31, 2026
The Tokens You Have to Keep Yourself
Image: Pub (auto-discovered)

Member-only story

When you call a hosted model, the cache is somebody else’s data structure. You send text, a provider tokenizes it, and if a prefix of your request matches something it still has warm, you get billed less. You never see the tokens. You never learn where the reuse boundary fell. The whole mechanism is a discount that shows up on an invoice.

Run the model in your own process and that discount becomes a data structure you maintain. It has an identity you have to compute, an invariant you have to preserve on every turn, and no error channel at all: when you get it wrong it does not fail, it just recomputes everything and hands you the right answer slowly. This is a report on what that turned out to cost.

The program it comes from is plank, a terminal coding agent written in Rust that links the DeepSeek V4 Flash engine directly rather than talking to a server, so the model runs inside the same process as the agent driving it. That arrangement is the whole reason any of this is my problem, and it was a deliberate choice.

Why port a C agent instead of extending a Rust one #

The obvious path was already open. Eugene, the agent from the series, had grown a provider that called straight into the DeepSeek V4 Flash engine through its C header, no subprocess and no pipe. Once you are in…

── more in #developer-tools 4 stories · sorted by recency
── more on @plank 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/the-tokens-you-have-…] indexed:0 read:1min 2026-07-31 ·