Skip to main content

RenderedContext

Struct RenderedContext 

Source
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: String

Identity + Knowledge combined — for providers with a single system slot (OpenAI).

§system_stable: String

Identity only (system partition). Anthropic system[0] with cache_control.

§system_knowledge: String

Knowledge (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

Source

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

Source§

fn clone(&self) -> RenderedContext

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RenderedContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for RenderedContext

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for RenderedContext

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.