PIN / FOLD / DROP — there is no gray “both cacheable and non-cacheable” state.
The Band enum
Defined in ir.py:
_BAND_RANK = {PIN: 0, FOLD: 1, DROP: 2}.
| Band | Semantics | Cache behavior |
|---|---|---|
| PIN 🟢 | Tool defs, system prompt, the current question | Permanent. The immutable base of every request’s prefix hash. |
| FOLD 🟡 | Conversation history, tool results, large docs (ref-pool) | Cacheable, compactable. Replaced by a summary under pressure — PIN bytes stay untouched. |
| DROP 🔴 | Timestamps, CWD, git status, PIDs, per-turn envelopes | Excluded entirely from the prefix hash; must come after all breakpoints. |
The ordering invariant (§5)
Within each segment, blocks must be physically arranged aspin* → fold* → drop* — across every
message, across the full prompt, at every layer. A violation immediately raises TelosInvariantError.
This is the only hard constraint; everything else is a soft recommendation.
Validation functions
enforce_band_order(blocks)— stably sorts blocks intopin* → fold* → drop*(preserving insertion order within the same band). Called as a fallback when a harness assembles a message.assert_band_order(blocks, where)— an O(n) single-pass scan; raisesTelosInvariantErrorthe moment a rank regression is found.assert_ir_invariants(ir)— runs full validation over the entire IR, additionally requiring thattoolsare allband=PIN.
How content is banded
The harness layer assigns bands when it parses a raw request (the rules are common to all three harnesses):| Upstream content | Band | Notes |
|---|---|---|
tools[] | PIN | kind=tool_def |
system text (≤ 2048 chars) | PIN | |
system text (> 2048) / <file> block | FOLD (into ref-pool) + a PIN reference stub | Threshold _REFPOOL_THRESHOLD = 2048 |
| user text | split into PIN / FOLD / DROP | see below |
user tool_result | FOLD | |
assistant text / tool_use / thinking | FOLD |
Splitting a user message
_user_split.split_user_text divides one user message into PIN (the actual question) + FOLD (history
echo) + DROP (envelope), using a regex set:
- DROP — the envelope that changes each round:
<environment_info>,<system-reminder>,<command-message>,<command-name>,Current time: … - FOLD — explicitly wrapped history echo:
<prev>…</prev> - PIN — whatever remains after stripping the above is the user’s question.
TelosMessage.
Why ordering is the invariant
If a high-variability DROP block (a timestamp) appears before a PIN block, the PIN bytes shift to a different byte offset every time the timestamp changes — and the engine’s prefix match breaks. Keeping DROP strictly last means the volatile bytes can never contaminate the stable prefix.The Protocol
The three invariants and the monotonic-append guarantee.
ref-pool
How oversized FOLD content is pointer-ized and folded without breaking the prefix.