pub struct Session {
pub path: PathBuf,
pub format: String,
pub metadata: SessionMetadata,
pub turns: Vec<Turn>,
pub parent_id: Option<String>,
pub agent_id: Option<String>,
pub subagent_type: Option<String>,
}Expand description
A parsed session in unified format.
Fields§
§path: PathBufPath to the original session file.
format: StringName of the format that parsed this session.
metadata: SessionMetadataSession metadata (IDs, timestamps, provider info).
turns: Vec<Turn>Conversation turns (request/response pairs).
parent_id: Option<String>Parent session ID (set when this session is a subagent).
agent_id: Option<String>Agent ID for subagent sessions (e.g. “agent-a5c5ccc9c2b61e757”).
subagent_type: Option<String>Subagent type (e.g. “general-purpose”, “Explore”, “Plan”).
Implementations§
Source§impl Session
impl Session
Sourcepub fn is_subagent(&self) -> bool
pub fn is_subagent(&self) -> bool
Whether this session is a subagent (has a parent session).
Sourcepub fn message_count(&self) -> usize
pub fn message_count(&self) -> usize
Total number of messages across all turns.
Sourcepub fn messages_by_role(&self, role: Role) -> usize
pub fn messages_by_role(&self, role: Role) -> usize
Count messages by role.
Sourcepub fn tool_uses(&self) -> impl Iterator<Item = (&str, &Value)>
pub fn tool_uses(&self) -> impl Iterator<Item = (&str, &Value)>
Iterate over all tool use blocks.
Sourcepub fn tool_results(&self) -> impl Iterator<Item = (&str, bool)>
pub fn tool_results(&self) -> impl Iterator<Item = (&str, bool)>
Iterate over all tool results.
Sourcepub fn total_tokens(&self) -> TokenUsage
pub fn total_tokens(&self) -> TokenUsage
Total token usage across all turns.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Session
impl<'de> Deserialize<'de> for Session
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
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