Skip to main content

ContextPartitions

Struct ContextPartitions 

Source
pub struct ContextPartitions {
    pub system: Partition,
    pub knowledge: Partition,
    pub task_state: TaskState,
    pub signals: Vec<String>,
    pub history: Partition,
}
Expand description

Three-partition context model aligned with LLM API slots:

Slot 1 — Identity (system): who the agent is; role, rules, constraints. Maps to: Anthropic system[0] cache_control, OpenAI system role. Never changes within a run.

Slot 2 — Knowledge (knowledge): what the agent knows; memory retrievals, skill definitions, artifacts. Low-frequency changes. Maps to: Anthropic system[1] cache_control.

Slot 3 — State (task_state + signals): what the agent is doing right now. task_state = goal/plan/progress (structured). signals = runtime events (rollback notes, interrupts). Maps to: messages[0] user turn, rebuilt every call.

Slot 4 — History (history): what the agent has done; conversation turns, tool calls and results. Compression pipeline target. Maps to: messages[1..N].

Fields§

§system: Partition§knowledge: Partition§task_state: TaskState§signals: Vec<String>

Runtime signals injected into the current turn (rollback notes, interrupts). Cleared after each render — signals are ephemeral per-turn events.

§history: Partition

Implementations§

Source§

impl ContextPartitions

Source

pub fn new(_config: &ContextConfig) -> Self

Source

pub fn total_tokens(&self, engine: &ContextTokenEngine) -> u32

Total token count across all slots. task_state tokens are measured from its rendered compact form.

Trait Implementations§

Source§

impl Default for ContextPartitions

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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, 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.