pub enum RegionKind {
Pinned,
SlidingWindow {
max_items: usize,
eviction_strategy: EvictionStrategy,
},
Temporary,
Compacting {
threshold_tokens: usize,
},
Clearable,
CompactHistory {
source_region: String,
},
HashMap {
max_entries: Option<usize>,
},
Custom {
script: String,
persistent: bool,
},
}Expand description
A typed memory region within an agent’s context window.
Regions have different lifecycle policies controlling how they behave when the context window fills up. This is inspired by hardware memory architectures like SNES VRAM, where different memory regions serve distinct purposes with their own access patterns and constraints.
Variants§
Pinned
Never evicted or compacted. Architecture diagrams, constraints, identity.
Like SNES OAM (Object Attribute Memory) - fixed format, always present. Use for content that defines the agent’s core identity, constraints, and architectural understanding. This content persists for the entire agent lifecycle.
SlidingWindow
Maintains the last N items, oldest rolls off. Conversation history.
Like a ring buffer with configurable size. When the buffer is full, the oldest item is removed to make room for new content. Use for conversation history or any sequential data where recent items are most relevant.
Fields
eviction_strategy: EvictionStrategyStrategy used to evict entries when the window is full
Temporary
First to be evicted when space is needed. Tool outputs, intermediate results.
Cheapest to regenerate, lowest priority to keep. Use for content that can be easily regenerated or has low value after immediate use, such as tool execution results or temporary computations.
Compacting
Compacts (summarizes) when threshold is hit, then cleared.
When token count exceeds the threshold, the region’s content is summarized and moved to a paired CompactHistory region, then the original Compacting region is completely cleared, giving fresh capacity.
Clearable
Wiped entirely in one shot when space is needed. All-or-nothing eviction.
Unlike Temporary (which evicts oldest entries one at a time), Clearable regions are dumped completely and immediately when eviction is needed. Use for scratch space or temporary working data where partial results are useless.
CompactHistory
Receives summaries from paired Compacting regions, never evicted.
When a Compacting region hits its threshold and summarizes, the summary moves here. CompactHistory regions hold compressed knowledge indefinitely and are never evicted. Can also support sliding window behavior (oldest summaries drop off) and re-compaction (combine multiple summaries).
HashMap
Key-value region where entries are indexed by string key. Writing with an existing key replaces that entry (upsert semantics). When over token budget, evicts least-recently-updated entries (LRU).
Custom
Script-backed region: a user-authored Rhai script owns how the region
renders into the assembled context (render), may transform or reject
each incoming entry (on_write), and may choose what to drop under
budget pressure (on_overflow).
script is the blueprint-dir-relative path to the .rhai file; path
resolution and compilation happen in the CLI spawner (this crate stays
filesystem-free), and the compiled script travels on the runtime’s
context window keyed by this path. persistent regions behave like
Pinned for lifecycle - never evicted, immune to edge
Clear transforms, counted as fixed budget - while non-persistent
regions behave like Temporary.
Note: this kind is orthogonal to RegionSchema’s (unwired)
custom_script field, which is a content-validation concept.
Implementations§
Source§impl RegionKind
impl RegionKind
Sourcepub fn cache_hint(&self) -> CacheHint
pub fn cache_hint(&self) -> CacheHint
Return the cache hint appropriate for this region kind.
Trait Implementations§
Source§impl Clone for RegionKind
impl Clone for RegionKind
Source§fn clone(&self) -> RegionKind
fn clone(&self) -> RegionKind
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RegionKind
impl Debug for RegionKind
Source§impl<'de> Deserialize<'de> for RegionKind
impl<'de> Deserialize<'de> for RegionKind
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for RegionKind
Source§impl PartialEq for RegionKind
impl PartialEq for RegionKind
Auto Trait Implementations§
impl Freeze for RegionKind
impl RefUnwindSafe for RegionKind
impl Send for RegionKind
impl Sync for RegionKind
impl Unpin for RegionKind
impl UnsafeUnpin for RegionKind
impl UnwindSafe for RegionKind
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.