pub struct Segment {
pub kind: SegmentKind,
pub role: Role,
pub content: String,
pub age_index: u32,
pub tool_name: Option<String>,
pub base_importance: f32,
pub freshness: Option<ContextFreshness>,
}Expand description
One logical segment of the prompt window.
Fields§
§kind: SegmentKindCoarse classification.
role: RoleSpeaker / origin.
content: StringRaw text content (the orchestrator may compress this).
age_index: u320 = newest, larger = older. Used by recency scoring.
tool_name: Option<String>Optional tool name for ToolResult / ToolDefinitions segments.
base_importance: f32Caller-provided base importance hint (default 1.0). Boosts always-keep segments
implicitly via SegmentKind::is_always_keep regardless of this value.
freshness: Option<ContextFreshness>Freshness signal at the time this segment was assembled (e.g. repo-knowledge currency).
Used by crate::HeuristicScorer to rank stale segments lower per
SELF_LEARNING_INTEGRATION_MAP §15.2.
Implementations§
Source§impl Segment
impl Segment
Sourcepub fn user_prompt(content: impl Into<String>) -> Self
pub fn user_prompt(content: impl Into<String>) -> Self
Construct a fresh user-prompt segment (the latest user message).
Sourcepub fn system_prompt(content: impl Into<String>) -> Self
pub fn system_prompt(content: impl Into<String>) -> Self
Construct a system-prompt segment.
Sourcepub fn recent_turn(
role: Role,
content: impl Into<String>,
age_index: u32,
) -> Self
pub fn recent_turn( role: Role, content: impl Into<String>, age_index: u32, ) -> Self
Construct a recent-turn segment with explicit age.
Sourcepub fn older_turn(
role: Role,
content: impl Into<String>,
age_index: u32,
) -> Self
pub fn older_turn( role: Role, content: impl Into<String>, age_index: u32, ) -> Self
Construct an older-turn segment (eligible for compaction).
Sourcepub fn tool_result(
tool_name: impl Into<String>,
content: impl Into<String>,
age_index: u32,
) -> Self
pub fn tool_result( tool_name: impl Into<String>, content: impl Into<String>, age_index: u32, ) -> Self
Construct a tool-result segment.
Sourcepub fn tool_definitions(content: impl Into<String>) -> Self
pub fn tool_definitions(content: impl Into<String>) -> Self
Construct a tool-definitions segment.
Sourcepub fn memory_block(
label: impl Into<String>,
content: impl Into<String>,
) -> Self
pub fn memory_block( label: impl Into<String>, content: impl Into<String>, ) -> Self
Construct a memory-block segment (graph-memory-derived).
Sourcepub fn token_estimate(&self) -> usize
pub fn token_estimate(&self) -> usize
Token estimate via the shared ainl_compression::tokenize_estimate heuristic.