Local LLM inference · drop-in prefix caching for llama.cpp

Reuse the KV cache.
Never regenerate
the same context twice.

An OpenAI-compatible daemon in front of llama-server. Agents that share a long system prompt compute it once, then replay it from memory.

  • 97.1% cache hit rate on real agent workloads
  • Zero patches to llama-server, to your client, to your model
  • Every backend llama-server ships
toki, the launcher live in this tab

The toki launcher: the agents it can start, the model in use, and the settings. Use the arrow keys to move, Enter to open, S for the settings, and the right arrow for the model list. Nothing here is connected to a model.

time to first token
+96.2%
prefill throughput
+1282.5%
cache hit rate
97.1%
model patches
0

Best measured result: Qwen3.5-122B-A10B, summarization, 65k context, AMD Ryzen AI MAX+ 395. The full table and the method.

The prompt arrives. The prefix matches.
The prefill disappears.

The mechanism

Every request is compared against the KV blocks already in memory.

Token by token. The longest identical prefix is replayed instead of recomputed. There is no second model, no separate cache server, no client change.

match
exact prefix, byte for byte
cache
one KV pool, shared by every client
client
OpenAI-compatible: point at the daemon and keep going

The web UI

The one screen we do not fake.

A single-page chat over the same daemon, with the cache made visible: every reply says whether it was cached, how many tokens it read, and how long the first token took.

Raw mode, cached mode, and a side-by-side comparison.

A real toki web session: the left rail lists the daemon, the model and the slots; the transcript shows cached replies with their token counts and timings.
mode cached
The session is running against the shared KV cache.
59 tok in
The context the reply reports reading.
367 ms
Time to the first token of that reply.
2503 ms
The whole turn, first token to last.

Swipe the window to see the rest of it.

The launcher

Every agent you run, in one window.

The full-screen terminal launcher ships with the package: the agents it can start, the model in use, the settings that matter, and a restart warning when a change needs one.

It is a terminal program. It reads and writes like one.

The toki launcher in a terminal: the TOKI wordmark, the model in use, and the full list of agents it can start, from toki and OpenCode through DeepSeek Harness, Claude Code, Kimi and OMP.
Captured from the real launcher. Every row is a program it can start with the selected model.
↑↓
Move between agents.
1–9
Jump straight to a row.
→
Open the model list.
m
Change the model or its context.
s
Settings, with the restart warning.
enter
Launch the highlighted agent.

Swipe the window to see the rest of it.

Everything in the package.

The daemon is only half of it. These are the parts you get on the same install.

Three commands from cold start to a shared cache.

Boot the stack, wire your clients at the daemon, and let the prefix matcher do the rest.

  1. Boot, toki model use starts llama-server plus the toki daemon, wires your CLI tools at it, and writes the effective context it can actually hold.
  2. Stream, clients call the daemon's OpenAI-compatible API. Shared prefixes hit the cached KV blocks instead of re-running the model.
  3. Persist, toki cache save / toki cache restore snapshot caches to disk; toki cache stats shows hits, misses, and savings.
prompt computed once replayed from memory
The same prefix, computed once. Every later request reads it back.

Benchmarks

Cache-hit efficiency & throughput.

Measured on an AMD Ryzen AI MAX+ 395 (Ryzen AI Halo) via llama-server. Four models, nine workloads each.

WorkloadTTFT ΔPrefill ΔHitScoreGrade
realistic_mixed+66.8%+560.9%88.1%84.4A
summarization+90.7%+1090.7%95.0%92.0A+
code_review+77.8%+379.5%96.7%90.0A+
agent_long_output+22.9%+41.2%98.0%64.4C
agent_100+45.0%+264.0%99.0%47.3F
rag_chunks+47.0%+226.0%87.5%47.7F
agent_long_context+47.7%+264.6%90.0%47.1F
no_overlap+16.7%+18.0%0.0%12.0F
stress_adversarial+20.4%+33.1%52.2%52.3D

Bigger and sparser is better: the 122B-A10B MoE tops every table (realistic_mixed 89.7, summarization 95.8), and the 35B-A3B beats the dense 9B, the more of each prompt's prefill that can be skipped, the larger the relative gain. Disclaimer: all scores are based on multiple benchmark runs on this hardware (AMD Ryzen AI Halo) and depend on the hardware, environment, and model, the benchmark may score better or worse elsewhere.

Platforms

Where it runs.

Toki Recur is pure Python over the llama-server HTTP API. It runs on any x86_64 or aarch64 device running Linux, macOS or Windows, with whatever GPU backend your llama-server build has.

PlatformArchllama-server backendsStatus
Linuxx86_64 CUDA (auto NVIDIA) · ROCm (auto AMD/HIP) · SYCL (explicit Intel Arc) · OpenVINO (explicit Intel) · Vulkan · CPU stable
Linuxaarch64 CUDA (auto NVIDIA) · Vulkan · CPU stable
macOSx86_64, arm64 Metal (one universal build; runs CPU-only with -ngl 0) stable
Windowsx86_64 CUDA (auto NVIDIA) · SYCL (auto Intel Arc) · Vulkan (auto AMD) · ROCm/HIP (explicit AMD) · OpenVINO (explicit Intel) · CPU beta
Windowsaarch64 CUDA (auto NVIDIA) · Vulkan · CPU beta

Every GPU install verifies the vendor runtime and a real device line from llama-server --list-devices before reporting success, so a missing driver cannot silently degrade to CPU.

toki the bear mascot, waving, wearing the Toki Recur recycling mark
Mascot

Meet toki.

toki is the mascot of Toki Recur, the bear who recurs. He wears the recycle symbol because the whole product is one idea: don't recompute what you've already read. Long system prompts, RAG corpora, agent tool definitions, all get computed once, then streamed from cache on every subsequent request.

He's here to remind you that cache reuse is the boring superpower underneath every fast local model.

Install and run.

Nothing is preinstalled. Clone, run the installer, pull one model, open the launcher.

macOS / Linux

git clone https://github.com/lhadzic377-netizen/TokiRecur.git
cd TokiRecur
./install.sh
toki model pull Qwen/Qwen3-4B-GGUF --use
toki

Windows (cmd or PowerShell)

git clone https://github.com/lhadzic377-netizen/TokiRecur.git
cd TokiRecur
install.bat
toki model pull Qwen/Qwen3-4B-GGUF --use
toki

Supported today: x86_64 and arm64 Linux and macOS are stable; Windows is beta. GPU support depends on the llama-server backend you install. The docs have the full platform and backend matrix. Optional systemd/launchd daemon mode is included. The macOS/Linux installer runs behind a yellow progress bar while the real output still streams live.

A note on compatibility

Some models work. Some need a tweak. I'm honest about it.

toki model pull accepts every GGUF on Hugging Face, so the answer to "does this model work?" depends on the model, the quant, and your hardware. Some GGUFs boot clean and chat on the first try. Others need a chat template swap, a smaller context, a different quant, or a small edit to the registry. I test what I recommend and fix what I ship, but I won't pretend every combination works the same.

It will keep getting better. The failure modes I hit this week (broken chat templates, runtime crashes on a quant, ETXTBSY on a binary swap) feed the next round of fixes. Better auto-detection, fewer surprises, more recovery paths baked in. The project is MIT licensed, and the path from "this model is broken" to "this model works" is one fix away.

Tested on a small set of machines: AMD Strix Halo (Linux), M2 (macOS), Intel i7-8650U (Windows), Intel Core Ultra 155U (Linux), GTX 1650 Mobile (Windows). That's five configs, not a hardware matrix. Different GPU, different VRAM, different kernel, different driver; any one of them can change the outcome. That's where the next bug report usually comes from.

Your server. Your cache. Your tokens.