pub struct ContextSegment {
pub id: String,
pub segment_type: ContextSegmentType,
pub content: String,
pub token_count: usize,
pub priority: ContextPriority,
pub compressible: bool,
pub source_step_id: Option<StepId>,
pub added_at: DateTime<Utc>,
pub sequence: u64,
}Expand description
A portion of the context window
Matches contextSegmentSchema in @enact/schemas
Fields§
§id: StringUnique segment identifier
segment_type: ContextSegmentTypeSegment type
content: StringSegment content
token_count: usizeToken count for this segment
priority: ContextPriorityPriority for compaction decisions
compressible: boolWhether this segment can be compressed
source_step_id: Option<StepId>Source step (for tool results, child summaries)
added_at: DateTime<Utc>Timestamp when segment was added
sequence: u64Sequence number for ordering
Implementations§
Source§impl ContextSegment
impl ContextSegment
Sourcepub fn new(
segment_type: ContextSegmentType,
content: String,
token_count: usize,
sequence: u64,
) -> Self
pub fn new( segment_type: ContextSegmentType, content: String, token_count: usize, sequence: u64, ) -> Self
Create a new context segment
Sourcepub fn system(content: impl Into<String>, token_count: usize) -> Self
pub fn system(content: impl Into<String>, token_count: usize) -> Self
Create a system prompt segment
Sourcepub fn user_input(
content: impl Into<String>,
token_count: usize,
sequence: u64,
) -> Self
pub fn user_input( content: impl Into<String>, token_count: usize, sequence: u64, ) -> Self
Create a user input segment
Sourcepub fn history(
content: impl Into<String>,
token_count: usize,
sequence: u64,
) -> Self
pub fn history( content: impl Into<String>, token_count: usize, sequence: u64, ) -> Self
Create a history segment
Sourcepub fn tool_results(
content: impl Into<String>,
token_count: usize,
sequence: u64,
step_id: StepId,
) -> Self
pub fn tool_results( content: impl Into<String>, token_count: usize, sequence: u64, step_id: StepId, ) -> Self
Create a tool results segment
Sourcepub fn rag_context(
content: impl Into<String>,
token_count: usize,
sequence: u64,
) -> Self
pub fn rag_context( content: impl Into<String>, token_count: usize, sequence: u64, ) -> Self
Create a RAG context segment
Sourcepub fn child_summary(
content: impl Into<String>,
token_count: usize,
sequence: u64,
step_id: StepId,
) -> Self
pub fn child_summary( content: impl Into<String>, token_count: usize, sequence: u64, step_id: StepId, ) -> Self
Create a child summary segment
Sourcepub fn guidance(
content: impl Into<String>,
token_count: usize,
sequence: u64,
) -> Self
pub fn guidance( content: impl Into<String>, token_count: usize, sequence: u64, ) -> Self
Create a guidance segment (from inbox)
Sourcepub fn with_priority(self, priority: ContextPriority) -> Self
pub fn with_priority(self, priority: ContextPriority) -> Self
Set custom priority
Sourcepub fn non_compressible(self) -> Self
pub fn non_compressible(self) -> Self
Mark as non-compressible
Trait Implementations§
Source§impl Clone for ContextSegment
impl Clone for ContextSegment
Source§fn clone(&self) -> ContextSegment
fn clone(&self) -> ContextSegment
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContextSegment
impl Debug for ContextSegment
Source§impl<'de> Deserialize<'de> for ContextSegment
impl<'de> Deserialize<'de> for ContextSegment
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ContextSegment
impl RefUnwindSafe for ContextSegment
impl Send for ContextSegment
impl Sync for ContextSegment
impl Unpin for ContextSegment
impl UnsafeUnpin for ContextSegment
impl UnwindSafe for ContextSegment
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
Mutably borrows from an owned value. Read more