pub struct AgentSession {
pub session_id: SessionId,
pub history: Vec<ChatCompletionRequestMessage>,
pub working_dir: PathBuf,
pub last_known_prompt_tokens: Option<u32>,
pub snapshot_message_count: usize,
}Expand description
A single conversation session with its own message history.
Fields§
§session_id: SessionId§history: Vec<ChatCompletionRequestMessage>§working_dir: PathBuf§last_known_prompt_tokens: Option<u32>The last known exact prompt token count from API usage.prompt_tokens.
Used as a calibration anchor: last_known_prompt_tokens is the precise
token count for the first snapshot_message_count messages in history.
New messages appended after the snapshot are estimated incrementally.
Invalidated (set to None) when history is truncated/compressed.
snapshot_message_count: usizeNumber of messages in history that last_known_prompt_tokens covers.
If history.len() < snapshot_message_count, the snapshot is stale
(truncation/compression happened) and calibration is invalid.
Implementations§
Source§impl AgentSession
impl AgentSession
Sourcepub fn with_history(
session_id: SessionId,
working_dir: PathBuf,
system_prompt: String,
history: Vec<ChatCompletionRequestMessage>,
) -> Self
pub fn with_history( session_id: SessionId, working_dir: PathBuf, system_prompt: String, history: Vec<ChatCompletionRequestMessage>, ) -> Self
Create session with pre-loaded history
Auto Trait Implementations§
impl Freeze for AgentSession
impl RefUnwindSafe for AgentSession
impl Send for AgentSession
impl Sync for AgentSession
impl Unpin for AgentSession
impl UnsafeUnpin for AgentSession
impl UnwindSafe for AgentSession
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