Expand description
Content-addressed recovery (CCR) for the proxy’s lossy rewrites (#482).
When the proxy prunes an old tool_result from conversation history, the
lossy stub used to say “re-read the file” — which is stale-unsafe by
construction: in an agent session files are edited or deleted between turns,
so a re-read returns the current bytes (or fails), not the historical
version the conversation actually showed. The model could then silently
reason about the wrong content.
CCR fixes this by persisting the verbatim original to the shared,
content-addressed tee store ({state}/tee/, reused from the shell path) and
embedding a retrieval handle — the absolute path of that file — in the
stub. These legacy copies have no source authority and are only available
without an active policy. Protected file recovery uses source-bound archives.
§Cache-safety (#448)
The handle is the file path, and the path is a pure function of the content
hash (crate::core::hasher::hash_short). For a fixed pruned message the
handle is therefore byte-identical on every later turn, so the provider
prompt-cache prefix is preserved for available copies. Failed or unauthorized
persistence returns no handle; a deterministic path is not proof of recovery.
The proxy splices in-band markers back into requests (proxy::ccr); the
store, its resolver and its bounded read live here, below every caller.
Enums§
- TeeResolve
Error - Why a canonical tee handle could not be resolved.
Constants§
- EXPAND_
CLOSE - Closing delimiter of an in-band retrieval marker.
- EXPAND_
OPEN - Opening delimiter of an in-band retrieval marker:
<lc_expand:HASH>(#493). - LITELLM_
HASH_ LEN - Length of a LiteLLM gateway retrieval hash (#702): LiteLLM’s headroom
guardrail scans compressed text with
hash=([a-f0-9]{24})(BerriAI/litellm#31681), so the marker must carry exactly 24 lowercase hex. - MIN_
TEE_ BYTES - Originals smaller than this are not worth a tee file + handle; the caller keeps its plain stub. Matches the spirit of the prune length thresholds.
Functions§
- inband_
locator - The in-band marker for
handleonly when in-band CCR is enabled (#493), elseNone. Stub sites use this to advertise an echo-able<lc_expand:HASH>solely in in-band mode: a normal (shared-filesystem) deployment keeps its path handle, so the model never sees a marker the proxy would not splice. - inband_
marker - The in-band retrieval marker
<lc_expand:HASH>for a CCRhandle(#493). - litellm_
hash - The 24-hex gateway retrieval hash for
content(#702): the first 24 chars of the full blake3 hex. A strict extension of the 16-hex tee name (crate::core::hasher::hash_shortis the same digest truncated to 16), sohash[..16]resolves the tee file while the extra 8 chars keep the marker collision-resistant on the gateway side. Pure — the marker embedding it stays byte-stable per content (#498). - persist
- Persist
contentverbatim (best-effort, secret-redacted) to the content-addressed tee store and return its retrieval handle (the absolute path). ReturnsNonefor protected originless data, invalid/oversized input or persistence failure. Re-persisting identical content keeps the same path; callers must preserve useful fresh output when no recovery handle is available. - persist_
conversation - Persist a dropped conversation message under a compact
conv_handle. - persist_
html - Persist an HTML page’s verbatim original (#1124) under the
html_prefix and return its{state}/tee/html_{hash}.loghandle. The extracted markdown is the compressed form; the full HTML is recoverable viaresolve_tee/ctx_expand. Shares the content-address and best-effort write contract ofpersist. - persist_
json - Persist a JSON crusher’s verbatim original (#936) under the
json_prefix and return its{state}/tee/json_{hash}.loghandle. Used by the lossy crush stage so a dropped column is always recoverable out-of-band viaresolve_tee/ctx_expand, never reconstructed from the (lossy) text. Shares the content-address and best-effort write contract ofpersist, so the embedded handle stays deterministic (cache-safe). - persist_
once - Like
persist, but a content-addressed copy that is already on disk is named as it is: no rewrite, no new relevance registration. A copy the TTL cleanup removed is written again (self-healing). Under protection nothing originless is named, existing or not. - persist_
tabular - Persist a tabular (CSV/TSV) crusher’s verbatim original (#982) under the
tbl_prefix and return its{state}/tee/tbl_{hash}.loghandle. Used by the lossy column-drop stage so a dropped column is always recoverable out-of-band viaresolve_tee/ctx_expand, never reconstructed from the (lossy) text. Shares the content-address and best-effort write contract ofpersist. - persist_
tool_ definition - Persist the full definition of a tool whose description the proxy shortened
(K26) under the
tool_prefix. Returns the basename, likepersist_conversation: it resolves throughctx_expandand keeps a machine-specific path out of the provider prompt, so the shortened tool list is the same bytes on every machine and turn. - persist_
yaml - Persist a YAML crusher’s verbatim original (#985) under the
yaml_prefix and return its{state}/tee/yaml_{hash}.loghandle. Used by the lossy column-drop stage so a dropped column is always recoverable out-of-band viaresolve_tee/ctx_expand, never reconstructed from the (lossy) text. Shares the content-address and best-effort write contract ofpersist. - read_
checked_ tee - One bounded, no-follow read shared by selectors, HTTP, CLI and in-band recovery. Policy is freshly resolved before I/O and rechecked at publication.
- read_
tee - Resolve and read a tee handle in one step.
- read_
tee_ detailed - read_
tee_ file - Read a tee file that
resolve_teereturned. One read path for every caller: bounded, no-follow and bound to the checked file, re-checked against the current policy and re-admitted by the context gateway. - resolve_
tee - Back-compatible resolver used by
ctx_expand. - resolve_
tee_ checked - Resolve a retrieval ID through the same canonical store path used by
ctx_expand, while distinguishing malformed IDs and policy refusals. - retrieve_
litellm - Resolve a LiteLLM
hash=<24hex>retrieval id (#702) back to the verbatim original in the tee store, forGET /v1/retrieve/{hash}. Shape-locked to LiteLLM’s own regex (24 lowercase hex — uppercase or any other length is rejected, never coerced) so only a string the guardrail could actually have captured resolves; the first 16 chars are theproxy_tee content-address. - write_
tee - Never publish an incomplete, oversized, unfiltered or protected originless copy. Atomic replacement preserves shell’s latest-output handle contract.