pub struct HistoryEntry {
pub agent: String,
pub sender: String,
pub auto_injected: bool,
pub message: Message,
}Expand description
A single conversation history entry.
The inner message is the wire-level shape sent to providers. The
runtime-only fields are stripped from the wire but persisted to the
session Storage for reload (except sender and auto_injected,
which are session-local state that resets on reload).
Fields§
§agent: StringWhich agent produced this assistant message. Empty = the conversation’s primary agent. Non-empty = a guest agent pulled in via an @ mention or guest turn. Persisted so reloads can reconstruct multi-agent state.
sender: StringThe sender identity (runtime-only, never serialized).
auto_injected: boolWhether this entry was auto-injected by the runtime (runtime-only). Auto-injected entries are stripped before each new run and never persisted as session steps.
message: MessageThe wire-level message sent to providers.
Implementations§
Source§impl HistoryEntry
impl HistoryEntry
Sourcepub fn user_with_sender(
content: impl Into<String>,
sender: impl Into<String>,
) -> Self
pub fn user_with_sender( content: impl Into<String>, sender: impl Into<String>, ) -> Self
Create a new user entry with sender identity.
Sourcepub fn assistant(
content: impl Into<String>,
reasoning: Option<String>,
tool_calls: Option<&[ToolCall]>,
) -> Self
pub fn assistant( content: impl Into<String>, reasoning: Option<String>, tool_calls: Option<&[ToolCall]>, ) -> Self
Create a new assistant entry.
Preserves the content: null vs empty-string discrimination:
- assistant + non-empty
tool_calls+ empty content →"content": null - assistant + empty
tool_calls+ empty content →"content": "" - anything else →
"content": "<the text>"
Sourcepub fn tool(
content: impl Into<String>,
call_id: impl Into<String>,
name: impl Into<String>,
) -> Self
pub fn tool( content: impl Into<String>, call_id: impl Into<String>, name: impl Into<String>, ) -> Self
Create a new tool-result entry.
Sourcepub fn from_message(message: Message) -> Self
pub fn from_message(message: Message) -> Self
Wrap an existing crabllm_core::Message.
Sourcepub fn auto_injected(self) -> Self
pub fn auto_injected(self) -> Self
Mark this entry as auto-injected (chainable).
Sourcepub fn text(&self) -> &str
pub fn text(&self) -> &str
The text content of the message, or "" if absent / empty / non-string.
Sourcepub fn tool_calls(&self) -> &[ToolCall]
pub fn tool_calls(&self) -> &[ToolCall]
The tool calls on this entry, or an empty slice if absent.
Sourcepub fn tool_call_id(&self) -> &str
pub fn tool_call_id(&self) -> &str
The tool call ID on this (tool) entry, or empty if absent.
Sourcepub fn estimate_tokens(&self) -> usize
pub fn estimate_tokens(&self) -> usize
Estimate the number of tokens in this entry (~4 chars per token).
Sourcepub fn to_wire_message(&self) -> Message
pub fn to_wire_message(&self) -> Message
Project to a crabllm_core::Message for sending to a provider.
If this is a guest assistant message (agent non-empty and role is
Assistant), wraps the content in <from agent="..."> tags so other
agents can distinguish speakers in multi-agent conversations.
Trait Implementations§
Source§impl Clone for HistoryEntry
impl Clone for HistoryEntry
Source§fn clone(&self) -> HistoryEntry
fn clone(&self) -> HistoryEntry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more