pub struct DialogueSession {
pub session_id: String,
/* private fields */
}Expand description
A single conversation session holding an ordered history of turns.
The session is keyed by a session_id string supplied by the caller (e.g.
a UUID or a stable user-facing conversation ID).
Fields§
§session_id: StringCaller-assigned stable identifier for this session.
Implementations§
Source§impl DialogueSession
impl DialogueSession
Sourcepub fn new(session_id: impl Into<String>) -> Self
pub fn new(session_id: impl Into<String>) -> Self
Create a new, empty DialogueSession with the given ID.
Sourcepub fn append_turn(
&mut self,
role: Role,
content: impl Into<String>,
) -> Result<(), AgentRuntimeError>
pub fn append_turn( &mut self, role: Role, content: impl Into<String>, ) -> Result<(), AgentRuntimeError>
Append a new turn to the session.
Returns Err if either role or content would be empty after
trimming, to guard against accidental blank entries.
Sourcepub fn get_history(&self) -> &[DialogueTurn]
pub fn get_history(&self) -> &[DialogueTurn]
Return a slice of all turns in chronological order.
Sourcepub fn turn_count(&self) -> usize
pub fn turn_count(&self) -> usize
Return the number of turns currently stored.
Sourcepub fn summary(&self) -> Option<&str>
pub fn summary(&self) -> Option<&str>
Return the optional summary string, if one has been produced by
[summarize_if_long].
Sourcepub fn summarize_if_long(
&mut self,
keep_last: usize,
) -> Result<bool, AgentRuntimeError>
pub fn summarize_if_long( &mut self, keep_last: usize, ) -> Result<bool, AgentRuntimeError>
Truncate the history to the most recent keep_last turns, setting
summary to a brief sentence describing how many turns were dropped.
If the total number of turns is already ≤ keep_last, this is a no-op
and Ok(false) is returned. When truncation occurs Ok(true) is
returned.
§Errors
Returns Err if keep_last is zero, since a zero-length history
would discard all context.
Sourcepub fn build_context(&self, episodic_context: Option<&str>) -> String
pub fn build_context(&self, episodic_context: Option<&str>) -> String
Assemble the full session into a single prompt-ready context string.
The optional episodic_context prefix (recalled memories) is prepended
before the dialogue history. If a summary is present it is inserted
between the episodic context and the turn history.
Trait Implementations§
Source§impl Clone for DialogueSession
impl Clone for DialogueSession
Source§fn clone(&self) -> DialogueSession
fn clone(&self) -> DialogueSession
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more