Byte-stable prefix, one session per ticket

The idea

The prefix stays reusable: one prompt and tool catalog per item, stage notes appended to the transcript, the model held within a stage, and cache breakpoints per provider. Claude Code runs as one live process.

The problem
Main-line cache reads were 28% against a 0.7 target, and resumes added empty message pairs.
Why it matters
The same bytes are reused across the item, so calls cost less.
Where it stands
In production as of

A step-by-step replay of this idea is not published yet. The library adds one when a recorded run shows it.

  • Cache-aware online compaction

    The main line compacts at a finished plan step only when the estimated cache-read savings are larger than the cost to rewrite, fold and carry.

  • Context contract per role

    Each model call carries only its role's layers, in a fixed order. People's messages enter as task state with their ids. Budgets are kept by folding and ranking, never by cutting the prefix.

  • ObservationPack and folded results

    A tool result of 10 KiB or more is stored whole. The step keeps the head, the tail and exact diagnostic anchors. Older results fold to one recall line, and the worker can read exact pages back.

  • Model failure handling and outage recovery

    An unusable answer moves one tier up in the same call. Quota or auth failures put an arm on cooldown. A timeout retries at lower effort. A transient outage parks the item on a backoff timer and resumes the same run.

Turn the numbers into shipped work.

Crewshal runs these choices for you: a persistent AI worker with memory and rules, on your Claude and Codex subscriptions.