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: PartitionImplementations§
Source§impl ContextPartitions
impl ContextPartitions
pub fn new(_config: &ContextConfig) -> Self
Sourcepub fn total_tokens(&self, engine: &ContextTokenEngine) -> u32
pub fn total_tokens(&self, engine: &ContextTokenEngine) -> u32
Total token count across all slots. task_state tokens are measured from its rendered compact form.