pub struct RenderedContext {
pub system_text: String,
pub system_stable: String,
pub system_knowledge: String,
pub turns: Vec<Message>,
pub state_turn: Option<Message>,
pub frozen_prefix_len: Option<usize>,
}Expand description
Structured render output aligned with LLM API slots.
Slot 1 — system_stable: Identity (system partition). Anthropic system[0] cache_control. Slot 2 — system_knowledge: Knowledge partition. Anthropic system[1] cache_control. Slot 3 — turns[0..N]: History turns (stable, cacheable prefix). Slot 4 — state_turn: State (task_state + signals), rebuilt every call.
The State turn is kept OUT of turns so the history prefix stays byte-stable
across turns and can be prompt-cached. Providers place state_turn themselves:
Anthropic appends it AFTER the message-history cache breakpoint (so the volatile
state is the cheap uncached tail); OpenAI-family prepend it (preserving today’s
ordering). When this struct is produced by an older binding that has not been
rebuilt, state_turn is absent and turns[0] still carries the State turn —
providers handle both shapes.
system_text = system_stable + system_knowledge (for OpenAI which has one system slot).
Fields§
§system_text: StringIdentity + Knowledge combined — for providers with a single system slot (OpenAI).
system_stable: StringIdentity only (system partition). Anthropic system[0] with cache_control.
system_knowledge: StringKnowledge (memory retrievals, skill definitions, artifacts). Anthropic system[1] with cache_control.
turns: Vec<Message>History turns only — the stable, cacheable message prefix.
state_turn: Option<Message>Volatile State turn (task_state + signals), rebuilt every call. Rendered
after the cacheable history. None when there is no task state or signals.
frozen_prefix_len: Option<usize>P1-E: number of leading turns that form the frozen prefix — byte-stable until the
next compaction. Providers that place explicit cache breakpoints (Anthropic) pin one deep
breakpoint at this boundary (a long-lived cache that survives many turns and is immune to
the 20-block lookback miss on heavy tool turns) and roll the other at the tail. None when
there is no distinct frozen region yet (pre-first-compaction, or the whole render is hot) —
providers then fall back to the rolling-pair placement. Providers clamp out-of-range values.
Implementations§
Source§impl RenderedContext
impl RenderedContext
Sourcepub fn prefix_fingerprint(&self) -> PrefixFingerprint
pub fn prefix_fingerprint(&self) -> PrefixFingerprint
Compute the PrefixFingerprint for this render. See its docs for the
cache-reuse contract it certifies.
Trait Implementations§
Source§impl Clone for RenderedContext
impl Clone for RenderedContext
Source§fn clone(&self) -> RenderedContext
fn clone(&self) -> RenderedContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more