pub struct MessageMetadata {
pub timestamp: u64,
pub importance_score: f64,
pub compression_status: CompressionStatus,
pub estimated_tokens: usize,
pub source: Option<String>,
}Expand description
Metadata attached to every message in the conversation history.
Skipped during serialization when None to preserve backward compatibility
with all existing persistence formats (session archives, snapshots, etc.).
Fields§
§timestamp: u64Unix millisecond timestamp when the message was created.
importance_score: f64Importance score in [0.0, 1.0]: 0.0 = low (safe to drop first), 1.0 = high (preserve as long as possible).
Initialised to 0.5 (neutral) and adjusted by the compression/pruning system or by explicit agent reflection.
compression_status: CompressionStatusCurrent compression status of this message.
estimated_tokens: usizeCached token estimate for this message. Populated on creation and updated after compression.
source: Option<String>Origin of this message: “user_input”, “llm_response”, “tool_result”, “system”, or “synthetic”.
Implementations§
Source§impl MessageMetadata
impl MessageMetadata
Sourcepub fn user_input(timestamp: u64, estimated_tokens: usize) -> Self
pub fn user_input(timestamp: u64, estimated_tokens: usize) -> Self
Create metadata for a message originating from a user.
Sourcepub fn llm_response(timestamp: u64, estimated_tokens: usize) -> Self
pub fn llm_response(timestamp: u64, estimated_tokens: usize) -> Self
Create metadata for a message originating from an LLM response.
Sourcepub fn tool_result(timestamp: u64, estimated_tokens: usize) -> Self
pub fn tool_result(timestamp: u64, estimated_tokens: usize) -> Self
Create metadata for a tool result message.
Sourcepub fn system(timestamp: u64, estimated_tokens: usize) -> Self
pub fn system(timestamp: u64, estimated_tokens: usize) -> Self
Create metadata for a system message.
Sourcepub fn synthetic(timestamp: u64, estimated_tokens: usize) -> Self
pub fn synthetic(timestamp: u64, estimated_tokens: usize) -> Self
Create metadata for a synthetic (e.g., recovery/injected) message.
Sourcepub fn mark_compressed(
&mut self,
original_tokens: usize,
compressed_tokens: usize,
)
pub fn mark_compressed( &mut self, original_tokens: usize, compressed_tokens: usize, )
Mark this message as compressed, recording the original and new token counts.
Sourcepub fn mark_summarized(&mut self, original_tokens: usize, summary_tokens: usize)
pub fn mark_summarized(&mut self, original_tokens: usize, summary_tokens: usize)
Mark this message as summarized.
Sourcepub fn set_importance(&mut self, score: f64)
pub fn set_importance(&mut self, score: f64)
Set the importance score (clamped to [0.0, 1.0]).
Sourcepub fn original_token_count(&self) -> usize
pub fn original_token_count(&self) -> usize
Returns the original (pre-compression) token count, or the current count if the message was never compressed.
Sourcepub fn effective_token_count(&self) -> usize
pub fn effective_token_count(&self) -> usize
Returns the effective (post-compression) token count.
Trait Implementations§
Source§impl Clone for MessageMetadata
impl Clone for MessageMetadata
Source§fn clone(&self) -> MessageMetadata
fn clone(&self) -> MessageMetadata
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 MessageMetadata
impl Debug for MessageMetadata
Source§impl<'de> Deserialize<'de> for MessageMetadata
impl<'de> Deserialize<'de> for MessageMetadata
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>,
Source§impl PartialEq for MessageMetadata
impl PartialEq for MessageMetadata
Source§fn eq(&self, other: &MessageMetadata) -> bool
fn eq(&self, other: &MessageMetadata) -> bool
self and other values to be equal, and is used by ==.