PanCode
All research

In the release. Not yet measured.

Subsystem6 min read

Drivers: the model you have, on its own wire

How PanCode shapes each request for its provider wire, names the cause of a cache break, and an experiment to measure the saving.

Written for
v0.9.1
Works in
Terminal
Basis
Read from source; first experiment not yet run
Updated
On this pageThe design Source map The question What is known so far Why it matters Use PanCode on it today First experiment Open questions How to join

A model reaches PanCode through a wire format, and each wire caches, prices, and constrains a request in its own way. The driver layer shapes every request for its wire and records what the provider's cache did with it. This page describes that design, where it lives in the source, and how to measure it.

The design

  • A pinned prefix, split per wire. The prompt compiler orders sections by how long their bytes stay fixed and hashes the part that is the same across an installation. Each wire marks that boundary its own way: a cache breakpoint on Anthropic, a separate input item on Codex, and a breakpoint part on Responses.
  • Cache-break attribution. Every request is digested field by field. When the provider reads far less from cache than the previous request wrote, PanCode names a cause. It first compares request fingerprints (model, system prompt, thinking, tool choice), then consults reasons the host stamped, such as a compaction or an idle period past the cache lifetime.
  • Tool rounds that keep the prefix. When a turn must call one named tool, wires that allow it keep the full tool list and name the tool, so the cached tool block survives. A provider's rejection is remembered for that connection and model.
  • Keepalive that has to pay for itself. While a turn waits on a long tool, a small request can keep the cache warm. It is sent only when the expected saving exceeds its own cost by at least five cents.
  • Capabilities from the live server. A probe of the inference server decides tools, vision, and reasoning before a packaged profile does, and an operator setting can only lower what was found. A context window that nobody reported stays unknown.
  • Per-model repairs. Parsers recover tool calls from models that emit them in a nonstandard channel, and a response that stops with thinking and no answer is retried once at a lower thinking level.

Reasoning, vision, and diffusion models run through this layer. For a diffusion model, PanCode renders refinement frames in the terminal, and the agent loop is the same one other models use. A decision model is a separate, opt-in engine for typed questions.

Source map

Mechanism Source Default Switch
Pinned prefix src/domains/prompts/compiler.ts, src/engine/provider-diagnostics.ts On None yet
Cache-break attribution src/engine/request-structure.ts, src/core/cache-telemetry.ts On Instrumentation
Tool-round control src/engine/provider-payload.ts On None yet
Keepalive src/engine/cache-keepalive.ts On chat.cacheKeepalive
Prewarm src/session-control/turn-prewarm.ts Off chat.prewarm
Live capabilities src/domains/providers/capabilities.ts On Connection capabilities

The question

Does shaping each request for its wire reduce the fresh input a session pays for, and by how much on each model lineage? The answer could be no. A provider may cache well enough without help that the split adds nothing.

What is known so far

These are facts about the design, read from source. They are not study results.

  • Behavior on the Codex wire rests on measurements of one model on one date.
  • The thresholds that declare a cache break are empirical, and some breaks still record an unknown cause.
  • The pinned prefix and tool-round control have no off switch, so they cannot be compared with a baseline yet.
  • Prompt wording changes very little between model lineages.
  • Nothing in the loop, the budgets, or tool handling is specific to diffusion models.

Why it matters

Input tokens dominate the cost of an agent session, and providers bill cached input at a fraction of fresh input. A harness that breaks the cache without noticing pays full price for the same bytes on every turn. Attribution turns that from a suspicion into a recorded cause someone can fix.

Use PanCode on it today

  1. Read what a session's cache did

    Shell

    pancode telemetry tokens --session <id> --by-source --json

    Each turn reports its cached input, fresh input, and output tokens. --by-source splits the prompt by where its bytes came from.

  2. Compare with keepalive off

    Shell

    pancode config set chat.cacheKeepalive false

    Run the same long task again and compare cached input on the turns that follow a slow tool call.

  3. Check what a connection reports

    Shell

    pancode connections --probe

    The probe shows the capabilities each connection answered with.

Worked example: Choose a model for your project.

First experiment

Pick one long task and one model from each lineage your subscription offers. Run it three times with keepalive on and three times with it off, holding the repository and thinking level fixed. Record cached and fresh input per turn, and the recorded cause of every cache break.

The main mechanism needs a switch first. Until the pinned prefix can be turned off, only keepalive and prewarm can be compared with a baseline.

Open questions

How to join

Open a GitHub issue that says what you plan to measure, and read the contributor guide. Results are published on this page with their numbers, including null and negative ones.

By Anthony Kougkas · PanCode

Continue with the documentation