pub struct AgentSession {
pub session_id: String,
pub agent_id: AgentId,
pub steps: Vec<ReActStep>,
pub memory_hits: usize,
pub graph_lookups: usize,
pub duration_ms: u64,
pub checkpoint_errors: Vec<String>,
}Expand description
The result of a single agent run.
Fields§
§session_id: StringStable unique identifier for this session (UUID v4 string).
agent_id: AgentIdThe agent ID used for this session.
steps: Vec<ReActStep>All ReAct steps executed during the session.
memory_hits: usizeNumber of episodic memory retrievals made during the session.
graph_lookups: usizeNumber of graph lookups made during the session.
duration_ms: u64Wall-clock duration of the session in milliseconds.
checkpoint_errors: Vec<String>Non-fatal errors encountered while saving per-step checkpoints.
Populated only when a persistence backend is configured. A non-empty list means some step snapshots may be missing from storage, but the session itself completed successfully.
Implementations§
Source§impl AgentSession
impl AgentSession
Sourcepub fn step_count(&self) -> usize
pub fn step_count(&self) -> usize
Return the number of steps in the session.
Each ReActStep in steps carries a step_duration_ms field measuring
wall-clock time from inference call to observation for that individual step.
Use this to identify slow steps:
for (i, step) in session.steps.iter().enumerate() {
println!("step {i}: {}ms", step.step_duration_ms);
}Sourcepub fn final_answer(&self) -> Option<String>
pub fn final_answer(&self) -> Option<String>
Return the final answer text from the last step, if available.
Extracts the content after FINAL_ANSWER in the last step’s action field.
Returns None if there are no steps or the last action is not a FINAL_ANSWER.
Sourcepub fn is_successful(&self) -> bool
pub fn is_successful(&self) -> bool
Return true if the session ended with a FINAL_ANSWER action.
This is the normal successful exit from a ReAct loop. false means the
loop was cut short by a timeout, max-iterations limit, or an error.
Sourcepub fn elapsed(&self) -> Duration
pub fn elapsed(&self) -> Duration
Return the session wall-clock duration as a std::time::Duration.
Sourcepub fn tool_calls_made(&self) -> usize
pub fn tool_calls_made(&self) -> usize
Return the number of tool-call actions dispatched during the session.
Each ReActStep whose action parses as a ToolCall (not a FinalAnswer)
is counted.
Sourcepub fn total_step_duration_ms(&self) -> u64
pub fn total_step_duration_ms(&self) -> u64
Return the sum of all individual step durations in milliseconds.
This is the cumulative inference + tool execution time across all steps,
which may differ from duration_ms due to overhead between steps.
Sourcepub fn average_step_duration_ms(&self) -> u64
pub fn average_step_duration_ms(&self) -> u64
Return the average step duration in milliseconds.
Returns 0 when there are no steps.
Sourcepub fn slowest_step(&self) -> Option<&ReActStep>
pub fn slowest_step(&self) -> Option<&ReActStep>
Return a reference to the slowest step (highest step_duration_ms).
Returns None when there are no steps.
Sourcepub fn fastest_step(&self) -> Option<&ReActStep>
pub fn fastest_step(&self) -> Option<&ReActStep>
Return a reference to the fastest step (lowest step_duration_ms).
Returns None when there are no steps.
Sourcepub fn filter_tool_call_steps(&self) -> Vec<&ReActStep>
pub fn filter_tool_call_steps(&self) -> Vec<&ReActStep>
Return references to all steps that are tool calls (not FINAL_ANSWER).
Sourcepub fn slowest_step_index(&self) -> Option<usize>
pub fn slowest_step_index(&self) -> Option<usize>
Return the zero-based index of the slowest step, or None if there are no steps.
Sourcepub fn fastest_step_index(&self) -> Option<usize>
pub fn fastest_step_index(&self) -> Option<usize>
Return the zero-based index of the fastest step, or None if there are no steps.
Sourcepub fn last_step(&self) -> Option<&ReActStep>
pub fn last_step(&self) -> Option<&ReActStep>
Return a reference to the last step, or None if there are no steps.
Sourcepub fn first_step(&self) -> Option<&ReActStep>
pub fn first_step(&self) -> Option<&ReActStep>
Return a reference to the first step taken, or None if there are no steps.
Sourcepub fn step_at(&self, idx: usize) -> Option<&ReActStep>
pub fn step_at(&self, idx: usize) -> Option<&ReActStep>
Return a reference to the step at zero-based index idx, or None if out of bounds.
Sourcepub fn observation_at(&self, idx: usize) -> Option<&str>
pub fn observation_at(&self, idx: usize) -> Option<&str>
Return the observation string at step idx, or None if out of bounds.
Sourcepub fn action_at(&self, idx: usize) -> Option<&str>
pub fn action_at(&self, idx: usize) -> Option<&str>
Return the action string at step idx, or None if out of bounds.
Sourcepub fn observations_matching(&self, pattern: &str) -> Vec<&ReActStep>
pub fn observations_matching(&self, pattern: &str) -> Vec<&ReActStep>
Return steps whose observation contains pattern (case-insensitive).
Sourcepub fn thoughts_containing(&self, pattern: &str) -> Vec<&ReActStep>
pub fn thoughts_containing(&self, pattern: &str) -> Vec<&ReActStep>
Return steps whose thought contains pattern (case-insensitive).
Sourcepub fn has_action(&self, action_name: &str) -> bool
pub fn has_action(&self, action_name: &str) -> bool
Return true if any step in this session used action_name.
Sourcepub fn thought_at(&self, idx: usize) -> Option<&str>
pub fn thought_at(&self, idx: usize) -> Option<&str>
Return the thought string at step idx, or None if out of bounds.
Sourcepub fn step_count_for_action(&self, action_name: &str) -> usize
pub fn step_count_for_action(&self, action_name: &str) -> usize
Count how many steps used action_name as their action.
Returns 0 if the action was never invoked. Complements
has_action, which only tests for presence.
Sourcepub fn observations(&self) -> Vec<&str>
pub fn observations(&self) -> Vec<&str>
Return all observation strings in step order.
Each string is a borrow of the corresponding ReActStep::observation
field. Useful for bulk post-processing of tool results.
Sourcepub fn observation_count(&self) -> usize
pub fn observation_count(&self) -> usize
Return the number of steps that have a non-empty observation string.
Sourcepub fn last_n_observations(&self, n: usize) -> Vec<&str>
pub fn last_n_observations(&self, n: usize) -> Vec<&str>
Return up to the last n non-empty observation strings, ordered oldest
to newest.
Empty observations are skipped. If the session has fewer than n
non-empty observations, all of them are returned.
Sourcepub fn actions_in_window(&self, n: usize) -> Vec<&str>
pub fn actions_in_window(&self, n: usize) -> Vec<&str>
Return the action names from the last n steps, ordered oldest to newest.
If the session has fewer than n steps, all action names are returned.
Sourcepub fn steps_without_observation(&self) -> usize
pub fn steps_without_observation(&self) -> usize
Return the number of steps whose observation string is empty.
Sourcepub fn first_thought(&self) -> Option<&str>
pub fn first_thought(&self) -> Option<&str>
Return the thought string from the first step, or None if the session
has no steps.
Sourcepub fn last_thought(&self) -> Option<&str>
pub fn last_thought(&self) -> Option<&str>
Return the thought string from the last step, or None if the session
has no steps.
Sourcepub fn first_action(&self) -> Option<&str>
pub fn first_action(&self) -> Option<&str>
Return the action name from the first step, or None if the session
has no steps.
Sourcepub fn last_action(&self) -> Option<&str>
pub fn last_action(&self) -> Option<&str>
Return the action name from the last step, or None if the session
has no steps.
Sourcepub fn last_n_steps(&self, n: usize) -> &[ReActStep]
pub fn last_n_steps(&self, n: usize) -> &[ReActStep]
Return a slice of the last n steps.
If n is greater than or equal to the total step count, all steps are
returned. An empty slice is returned for sessions with no steps.
Sourcepub fn first_n_steps(&self, n: usize) -> &[ReActStep]
pub fn first_n_steps(&self, n: usize) -> &[ReActStep]
Return a slice containing at most the first n steps.
If the session has fewer than n steps all steps are returned.
Returns an empty slice for n == 0 or an empty session.
Sourcepub fn steps_with_tool<'a>(&'a self, tool_name: &str) -> Vec<&'a ReActStep>
pub fn steps_with_tool<'a>(&'a self, tool_name: &str) -> Vec<&'a ReActStep>
Return references to steps whose action string contains tool_name.
Useful for auditing which steps invoked a specific tool. The comparison is case-sensitive.
Sourcepub fn total_chars(&self) -> usize
pub fn total_chars(&self) -> usize
Return the total character count across all thought, action, and observation strings in the session.
Useful for estimating context consumption. Returns 0 for empty sessions.
Sourcepub fn step_durations_ms(&self) -> Vec<u64>
pub fn step_durations_ms(&self) -> Vec<u64>
Return all per-step durations in milliseconds, in order.
Useful for computing custom percentiles or detecting slow outlier steps.
Sourcepub fn total_latency_ms(&self) -> u64
pub fn total_latency_ms(&self) -> u64
Return the sum of all step durations in milliseconds.
Equivalent to step_durations_ms().iter().sum() but avoids allocating
a temporary Vec.
Sourcepub fn avg_step_duration_ms(&self) -> f64
pub fn avg_step_duration_ms(&self) -> f64
Return the arithmetic mean step duration in milliseconds.
Returns 0.0 for sessions with no steps.
Sourcepub fn longest_step(&self) -> Option<&ReActStep>
pub fn longest_step(&self) -> Option<&ReActStep>
Return a reference to the step with the largest step_duration_ms.
Returns None if the session has no steps. When multiple steps share
the maximum duration the first one (lowest index) is returned.
Sourcepub fn shortest_step(&self) -> Option<&ReActStep>
pub fn shortest_step(&self) -> Option<&ReActStep>
Return a reference to the step with the smallest step_duration_ms.
Returns None if the session has no steps. When multiple steps share
the minimum duration the first one (lowest index) is returned.
Sourcepub fn action_sequence(&self) -> Vec<String>
pub fn action_sequence(&self) -> Vec<String>
Return the sequence of action names taken, in step order.
Unlike all_actions() this returns owned Strings so the result can
outlive the session borrow.
Sourcepub fn unique_tools_used(&self) -> Vec<String>
pub fn unique_tools_used(&self) -> Vec<String>
Return the sorted, deduplicated set of tool names invoked during the session.
Tool-call steps are identified by the same heuristic as tool_calls_made:
a non-empty action that does not start with FINAL_ANSWER.
Sourcepub fn all_thoughts(&self) -> Vec<&str>
pub fn all_thoughts(&self) -> Vec<&str>
Collect all thought strings from every step, in order.
Sourcepub fn all_actions(&self) -> Vec<&str>
pub fn all_actions(&self) -> Vec<&str>
Collect all action strings from every step, in order.
Sourcepub fn all_observations(&self) -> Vec<&str>
pub fn all_observations(&self) -> Vec<&str>
Collect all observation strings from every step, in order.
Sourcepub fn failed_steps(&self) -> Vec<&ReActStep>
pub fn failed_steps(&self) -> Vec<&ReActStep>
Return references to steps where the observation indicates a tool error.
A step is classified as failed when its observation starts with
{"error" (the structured error JSON produced by required-field
validation) or contains the substring "error" (case-insensitive).
Sourcepub fn failed_tool_call_count(&self) -> usize
pub fn failed_tool_call_count(&self) -> usize
Return the number of tool-call steps whose observation indicates an error.
Equivalent to failed_steps().len() but avoids collecting a Vec.
Sourcepub fn action_counts(&self) -> HashMap<String, usize>
pub fn action_counts(&self) -> HashMap<String, usize>
Return a count of how many times each action was taken in this session.
The map key is the action name (e.g. "search", "FINAL_ANSWER").
Sourcepub fn unique_actions(&self) -> Vec<String>
pub fn unique_actions(&self) -> Vec<String>
Return a sorted list of unique action names used in this session.
Sourcepub fn has_duplicate_actions(&self) -> bool
pub fn has_duplicate_actions(&self) -> bool
Return true when at least one action string appears more than once.
Useful for detecting repetitive or looping agent behaviour without iterating over the full step list manually.
Sourcepub fn step_indices_with_tool(&self, tool_name: &str) -> Vec<usize>
pub fn step_indices_with_tool(&self, tool_name: &str) -> Vec<usize>
Return the 0-based indices of steps whose action contains tool_name.
Returns an empty Vec when no step matches. Useful when you need
positions rather than step references for further slicing.
Sourcepub fn most_used_action(&self) -> Option<String>
pub fn most_used_action(&self) -> Option<String>
Return the action name used most often during the session.
Returns None for sessions with no steps. When multiple actions tie
for the maximum count, any one of them may be returned.
Sourcepub fn last_observation(&self) -> Option<&str>
pub fn last_observation(&self) -> Option<&str>
Return the observation string from the most recent step that has one.
Steps with an empty observation are skipped. Returns None when no
step has produced an observation yet.
Sourcepub fn thought_count(&self) -> usize
pub fn thought_count(&self) -> usize
Return the number of steps that have a non-empty thought string.
Sourcepub fn observation_rate(&self) -> f64
pub fn observation_rate(&self) -> f64
Return the fraction of steps that contain a non-empty observation.
Returns 0.0 for sessions with no steps.
Sourcepub fn has_graph_lookups(&self) -> bool
pub fn has_graph_lookups(&self) -> bool
Return true if at least one knowledge-graph lookup was performed during
this session.
Sourcepub fn consecutive_same_action_at_end(&self) -> usize
pub fn consecutive_same_action_at_end(&self) -> usize
Return how many times the last action in the session repeats consecutively at the end of the step list.
Returns 0 for empty sessions or single-step sessions where no repeat
is possible. Useful for detecting a stuck agent that keeps retrying the
same action.
Sourcepub fn action_repetition_rate(&self) -> f64
pub fn action_repetition_rate(&self) -> f64
Return the fraction of steps (from the second onward) that repeat the immediately preceding action.
Returns 0.0 for sessions with fewer than two steps. A high value
may indicate the agent is stuck in a loop.
Sourcepub fn max_consecutive_failures(&self) -> usize
pub fn max_consecutive_failures(&self) -> usize
Return the length of the longest consecutive run of failed steps.
A step is considered failed when its observation starts with {"error"
or contains the substring "error" (case-insensitive).
Returns 0 for sessions with no steps or no failures.
Sourcepub fn avg_thought_length(&self) -> f64
pub fn avg_thought_length(&self) -> f64
Return the mean character length of non-empty thought strings.
Only steps with a non-empty thought field are included.
Returns 0.0 when no step has a thought.
Sourcepub fn graph_lookup_rate(&self) -> f64
pub fn graph_lookup_rate(&self) -> f64
Return the rate of knowledge-graph lookups per step.
Computed as graph_lookups / step_count. Returns 0.0 when there
are no steps, to avoid division by zero.
Sourcepub fn has_checkpoint_errors(&self) -> bool
pub fn has_checkpoint_errors(&self) -> bool
Return true if any checkpoint errors were recorded during the session.
A non-empty checkpoint_errors list means some step snapshots may be
missing from storage, but the session itself completed successfully.
Sourcepub fn checkpoint_error_count(&self) -> usize
pub fn checkpoint_error_count(&self) -> usize
Return the number of checkpoint errors recorded during this session.
Sourcepub fn graph_lookup_count(&self) -> usize
pub fn graph_lookup_count(&self) -> usize
Return the number of knowledge-graph lookups performed during this session.
Sourcepub fn memory_hit_rate(&self) -> f64
pub fn memory_hit_rate(&self) -> f64
Return the episodic memory hit rate for this session.
Computed as memory_hits / step_count. Returns 0.0 when there are
no steps, to avoid division by zero.
Sourcepub fn total_memory_hits(&self) -> usize
pub fn total_memory_hits(&self) -> usize
Return the raw count of episodic memory hits for this session.
Sourcepub fn throughput_steps_per_sec(&self) -> f64
pub fn throughput_steps_per_sec(&self) -> f64
Return the session throughput in steps per second.
Computed as step_count / (duration_ms / 1000.0). Returns 0.0
if duration_ms is zero.
Sourcepub fn duration_secs(&self) -> u64
pub fn duration_secs(&self) -> u64
Return the session duration in full seconds (rounded down).
Sourcepub fn steps_above_thought_length(&self, threshold: usize) -> usize
pub fn steps_above_thought_length(&self, threshold: usize) -> usize
Return the count of steps whose thought string is longer than threshold bytes.
Sourcepub fn has_final_answer(&self) -> bool
pub fn has_final_answer(&self) -> bool
Return true if any step’s action begins with "FINAL_ANSWER" (case-insensitive).
Sourcepub fn avg_action_length(&self) -> f64
pub fn avg_action_length(&self) -> f64
Return the mean byte length of all step action strings.
Returns 0.0 for empty sessions.
Sourcepub fn has_tool_failures(&self) -> bool
pub fn has_tool_failures(&self) -> bool
Return true if any tool-call steps had error observations.
Sourcepub fn tool_call_rate(&self) -> f64
pub fn tool_call_rate(&self) -> f64
Return the fraction of steps that were tool calls.
Computed as tool_calls_made / step_count. Returns 0.0 for empty
sessions to avoid division by zero.
Sourcepub fn step_success_rate(&self) -> f64
pub fn step_success_rate(&self) -> f64
Return the fraction of tool-call steps that succeeded.
Computed as 1.0 - (failed_tool_call_count / step_count). Returns
1.0 for empty sessions (no failures possible).
Sourcepub fn action_diversity(&self) -> f64
pub fn action_diversity(&self) -> f64
Return the ratio of unique actions to total steps.
Returns 0.0 for sessions with no steps. A value of 1.0 means every
step used a different action; lower values indicate repeated actions.
Sourcepub fn total_thought_length(&self) -> usize
pub fn total_thought_length(&self) -> usize
Return the total byte length of all thought strings across all steps.
Sourcepub fn steps_with_empty_observations(&self) -> usize
pub fn steps_with_empty_observations(&self) -> usize
Return the number of steps whose observation string is empty.
Sourcepub fn observation_lengths(&self) -> Vec<usize>
pub fn observation_lengths(&self) -> Vec<usize>
Return the byte length of each observation, in step order.
Sourcepub fn avg_observation_length(&self) -> f64
pub fn avg_observation_length(&self) -> f64
Return the mean observation byte length across all steps.
Returns 0.0 for empty sessions.
Sourcepub fn min_thought_length(&self) -> usize
pub fn min_thought_length(&self) -> usize
Return the byte length of the shortest non-empty thought, or 0 if
no non-empty thoughts exist.
Sourcepub fn longest_observation(&self) -> Option<&str>
pub fn longest_observation(&self) -> Option<&str>
Return the longest observation string in the session, or None if
the session is empty.
Sourcepub fn thought_lengths(&self) -> Vec<usize>
pub fn thought_lengths(&self) -> Vec<usize>
Return the byte length of each step’s thought string, in step order.
Sourcepub fn most_common_action(&self) -> Option<&str>
pub fn most_common_action(&self) -> Option<&str>
Return the action string that appears most often across all steps.
Returns None if the session has no steps.
Sourcepub fn action_lengths(&self) -> Vec<usize>
pub fn action_lengths(&self) -> Vec<usize>
Return the byte length of each step’s action string, in step order.
Sourcepub fn step_success_count(&self) -> usize
pub fn step_success_count(&self) -> usize
Return the count of steps that did not have a tool failure.
Sourcepub fn longest_thought(&self) -> Option<&str>
pub fn longest_thought(&self) -> Option<&str>
Return the thought string of the step with the most bytes.
Returns None if the session has no steps.
Sourcepub fn shortest_action(&self) -> Option<&str>
pub fn shortest_action(&self) -> Option<&str>
Return the action string of the step with the fewest bytes.
Returns None if the session has no steps.
Sourcepub fn total_thought_bytes(&self) -> usize
pub fn total_thought_bytes(&self) -> usize
Return the sum of byte lengths of all thought strings in the session.
Sourcepub fn total_observation_bytes(&self) -> usize
pub fn total_observation_bytes(&self) -> usize
Return the sum of byte lengths of all observation strings in the session.
Sourcepub fn first_step_action(&self) -> Option<&str>
pub fn first_step_action(&self) -> Option<&str>
Return the action string of the first step in the session.
Returns None if the session has no steps.
Sourcepub fn last_step_action(&self) -> Option<&str>
pub fn last_step_action(&self) -> Option<&str>
Return the action string of the last step in the session.
Returns None if the session has no steps.
Sourcepub fn count_nonempty_thoughts(&self) -> usize
pub fn count_nonempty_thoughts(&self) -> usize
Return the count of steps that have a non-empty thought string.
Sourcepub fn observation_contains_count(&self, substring: &str) -> usize
pub fn observation_contains_count(&self, substring: &str) -> usize
Return the count of steps whose observation contains substring.
Sourcepub fn count_steps_with_action(&self, action: &str) -> usize
pub fn count_steps_with_action(&self, action: &str) -> usize
Return the number of steps whose action string matches action exactly.
Sourcepub fn thought_contains_count(&self, substring: &str) -> usize
pub fn thought_contains_count(&self, substring: &str) -> usize
Return the number of steps whose thought contains substring.
Sourcepub fn failure_rate(&self) -> f64
pub fn failure_rate(&self) -> f64
Return the fraction of steps that had a tool failure observation.
Computed as failed_tool_call_count / step_count. Returns 0.0 for
empty sessions.
Sourcepub fn unique_action_count(&self) -> usize
pub fn unique_action_count(&self) -> usize
Return the number of distinct action names used across all steps.
Sourcepub fn steps_in_range(&self, start: usize, end: usize) -> Vec<&ReActStep>
pub fn steps_in_range(&self, start: usize, end: usize) -> Vec<&ReActStep>
Return references to steps whose indices fall in [start, end).
Clamps end to step_count() so out-of-bounds ranges are safe.
Returns an empty Vec when start >= step_count() or start >= end.
Sourcepub fn median_step_duration_ms(&self) -> u64
pub fn median_step_duration_ms(&self) -> u64
Return the median step duration in milliseconds.
Sorts step durations and picks the middle value (lower median for even
counts). Returns 0 when the session has no steps.
Sourcepub fn p95_step_duration_ms(&self) -> u64
pub fn p95_step_duration_ms(&self) -> u64
Return the 95th-percentile step duration in milliseconds.
Uses the nearest-rank method: the value at index ⌈0.95 × n⌉ − 1 in
the sorted list of step durations. Returns 0 when the session has no
steps.
Sourcepub fn p99_step_duration_ms(&self) -> u64
pub fn p99_step_duration_ms(&self) -> u64
Return the 99th-percentile step duration in milliseconds.
Uses the nearest-rank method: the value at index ⌈0.99 × n⌉ − 1 in
the sorted list of step durations. Returns 0 when the session has no
steps.
Sourcepub fn step_count_above_duration_ms(&self, threshold_ms: u64) -> usize
pub fn step_count_above_duration_ms(&self, threshold_ms: u64) -> usize
Return the count of steps whose step_duration_ms is strictly greater
than threshold_ms.
Useful for identifying sessions that contain outlier-slow steps.
Returns 0 for empty sessions.
Sourcepub fn min_step_duration_ms(&self) -> u64
pub fn min_step_duration_ms(&self) -> u64
Return the minimum step_duration_ms across all steps in the session.
Returns 0 for empty sessions.
Sourcepub fn max_step_duration_ms(&self) -> u64
pub fn max_step_duration_ms(&self) -> u64
Return the maximum step_duration_ms across all steps in the session.
Returns 0 for empty sessions.
Sourcepub fn total_action_bytes(&self) -> usize
pub fn total_action_bytes(&self) -> usize
Return the sum of byte lengths of all action strings in the session.
Useful alongside total_thought_bytes and total_observation_bytes
to estimate the full token budget consumed by a session.
Sourcepub fn step_duration_variance_ms(&self) -> f64
pub fn step_duration_variance_ms(&self) -> f64
Return the population variance of step durations in milliseconds squared.
Returns 0.0 for sessions with fewer than two steps.
Sourcepub fn steps_with_errors(&self) -> Vec<&ReActStep>
pub fn steps_with_errors(&self) -> Vec<&ReActStep>
Return references to steps whose observation contains "error" (case-insensitive).
A quick filter for identifying tool-call failures without inspecting the
full observation string. For more control use observations_matching.
Sourcepub fn steps_with_long_observations(
&self,
threshold_bytes: usize,
) -> Vec<&ReActStep>
pub fn steps_with_long_observations( &self, threshold_bytes: usize, ) -> Vec<&ReActStep>
Return references to steps whose observation byte length exceeds threshold_bytes.
Useful for identifying steps that produced unusually verbose tool output.
Sourcepub fn observations_above_bytes(&self, min_bytes: usize) -> Vec<&ReActStep>
pub fn observations_above_bytes(&self, min_bytes: usize) -> Vec<&ReActStep>
Return steps whose observation is strictly longer than min_bytes.
Equivalent to steps_with_long_observations but uses the name
“above” for consistency with other filtering predicates.
Sourcepub fn total_step_chars(&self) -> usize
pub fn total_step_chars(&self) -> usize
Return the total character count across all steps.
Sums thought.chars().count() + action.chars().count() + observation.chars().count()
for every step. Useful as a proxy for token budget estimation.
Sourcepub fn unique_observations_count(&self) -> usize
pub fn unique_observations_count(&self) -> usize
Return the number of distinct observation strings across all steps.
Two steps with the same observation text are counted as one.
Returns 0 for empty sessions.
Sourcepub fn thought_max_bytes(&self) -> usize
pub fn thought_max_bytes(&self) -> usize
Return the maximum byte length of any thought string in the session.
Returns 0 for empty sessions or sessions where every thought is empty.
Sourcepub fn observation_max_bytes(&self) -> usize
pub fn observation_max_bytes(&self) -> usize
Return the maximum byte length of any observation string in the session.
Returns 0 for empty sessions or sessions where every observation is empty.
Sourcepub fn step_count_below_duration_ms(&self, threshold_ms: u64) -> usize
pub fn step_count_below_duration_ms(&self, threshold_ms: u64) -> usize
Return the count of steps whose step_duration_ms is strictly less
than threshold_ms.
Complements step_count_above_duration_ms. Returns 0 for empty
sessions.
Sourcepub fn max_action_bytes(&self) -> usize
pub fn max_action_bytes(&self) -> usize
Return the maximum byte length of any action string across all steps.
Returns 0 for sessions with no steps or where every action is empty.
Sourcepub fn min_action_bytes(&self) -> usize
pub fn min_action_bytes(&self) -> usize
Return the minimum byte length of any action string across all steps.
Returns 0 for sessions with no steps or where every action is empty.
Sourcepub fn proportion_tool_calls(&self) -> f64
pub fn proportion_tool_calls(&self) -> f64
Return the fraction of steps that are tool calls (not FINAL_ANSWER).
Returns 0.0 for sessions with no steps.
Sourcepub fn thought_density(&self) -> f64
pub fn thought_density(&self) -> f64
Return the ratio of total thought bytes to the total bytes across all step fields (thoughts + actions + observations).
Returns 0.0 for sessions with no steps or where no bytes exist.
Sourcepub fn step_throughput_per_sec(&self) -> f64
pub fn step_throughput_per_sec(&self) -> f64
Return the average number of ReAct steps completed per second.
Computed as step_count / (duration_ms / 1000.0). Returns 0.0 for
sessions with no steps or zero duration.
Sourcepub fn avg_action_bytes(&self) -> f64
pub fn avg_action_bytes(&self) -> f64
Return the mean byte length of action strings across all steps.
Returns 0.0 for sessions with no steps.
Sourcepub fn avg_observation_bytes(&self) -> f64
pub fn avg_observation_bytes(&self) -> f64
Return the mean byte length of observation strings across all steps.
Returns 0.0 for sessions with no steps.
Sourcepub fn total_observation_count(&self) -> usize
pub fn total_observation_count(&self) -> usize
Return the number of steps that have a non-empty observation string.
Steps where the tool produced no output (empty string) are excluded.
Sourcepub fn actions_containing<'a>(&'a self, substring: &str) -> Vec<&'a ReActStep>
pub fn actions_containing<'a>(&'a self, substring: &str) -> Vec<&'a ReActStep>
Return references to steps whose action string contains substring.
The comparison is case-sensitive. Returns an empty slice when no step matches or the session has no steps.
Sourcepub fn avg_thought_bytes(&self) -> f64
pub fn avg_thought_bytes(&self) -> f64
Return the mean byte length of thought strings across all steps.
Returns 0.0 for sessions with no steps.
Sourcepub fn steps_above_action_bytes(&self, min_bytes: usize) -> Vec<&ReActStep>
pub fn steps_above_action_bytes(&self, min_bytes: usize) -> Vec<&ReActStep>
Return references to steps whose action byte length exceeds min_bytes.
Returns an empty Vec for sessions with no steps or when no step
action exceeds min_bytes.
Sourcepub fn steps_between(&self, start: usize, end: usize) -> Vec<&ReActStep>
pub fn steps_between(&self, start: usize, end: usize) -> Vec<&ReActStep>
Return the steps in the half-open index range [start, end).
Both bounds are clamped to [0, step_count]. Returns an empty Vec
when start >= end or the session has no steps.
Sourcepub fn step_observation_rate(&self) -> f64
pub fn step_observation_rate(&self) -> f64
Return the fraction of steps that have a non-empty observation string.
Returns 0.0 for sessions with no steps.
Sourcepub fn steps_below_thought_bytes(&self, max_bytes: usize) -> Vec<&ReActStep>
pub fn steps_below_thought_bytes(&self, max_bytes: usize) -> Vec<&ReActStep>
Return references to steps whose thought byte length is strictly less
than max_bytes.
Returns an empty Vec when no steps qualify or the session is empty.
Sourcepub fn steps_with_duplicate_thoughts(&self) -> Vec<&ReActStep>
pub fn steps_with_duplicate_thoughts(&self) -> Vec<&ReActStep>
Return references to steps whose thought string duplicates an earlier step’s thought.
The first occurrence of each thought is not included; only the subsequent duplicates are returned. Useful for detecting repetitive reasoning loops.
Sourcepub fn max_thought_bytes(&self) -> usize
pub fn max_thought_bytes(&self) -> usize
Return the byte length of the longest thought in this session.
Returns 0 for an empty session or when all thoughts are empty strings.
Sourcepub fn steps_by_action_prefix<'a>(&'a self, prefix: &str) -> Vec<&'a ReActStep>
pub fn steps_by_action_prefix<'a>(&'a self, prefix: &str) -> Vec<&'a ReActStep>
Return references to steps whose action starts with prefix.
Useful for filtering tool-call steps by tool name prefix (e.g. all
"search_" actions). Returns an empty Vec when no step qualifies.
Sourcepub fn action_count(&self) -> usize
pub fn action_count(&self) -> usize
Return the number of tool-call steps in this session.
Counts steps whose action is non-empty and is not a FINAL_ANSWER.
Returns 0 for an empty session.
Sourcepub fn steps_above_observation_bytes(&self, min_bytes: usize) -> Vec<&ReActStep>
pub fn steps_above_observation_bytes(&self, min_bytes: usize) -> Vec<&ReActStep>
Return references to steps whose observation byte length exceeds min_bytes.
Useful for finding steps that produced unexpectedly large observations.
Returns an empty Vec for an empty session or when no step qualifies.
Sourcepub fn steps_matching_observation<'a>(
&'a self,
substr: &str,
) -> Vec<&'a ReActStep>
pub fn steps_matching_observation<'a>( &'a self, substr: &str, ) -> Vec<&'a ReActStep>
Return references to steps whose observation contains substr.
Case-sensitive substring match. Returns an empty Vec when no step
matches or the session is empty.
Sourcepub fn step_action_lengths(&self) -> Vec<usize>
pub fn step_action_lengths(&self) -> Vec<usize>
Return the byte lengths of each step’s action field, in order.
Returns an empty Vec for an empty session.
Sourcepub fn has_thought_starting_with(&self, prefix: &str) -> bool
pub fn has_thought_starting_with(&self, prefix: &str) -> bool
Return true if any step’s thought starts with prefix.
Returns false for an empty session.
Sourcepub fn step_count_above_action_bytes(&self, min_bytes: usize) -> usize
pub fn step_count_above_action_bytes(&self, min_bytes: usize) -> usize
Return the number of steps whose action byte length exceeds min_bytes.
Returns 0 for an empty session.
Sourcepub fn steps_with_empty_action(&self) -> Vec<&ReActStep>
pub fn steps_with_empty_action(&self) -> Vec<&ReActStep>
Return all steps whose action field is empty.
Returns an empty Vec when no steps have an empty action.
Sourcepub fn has_action_containing(&self, substr: &str) -> bool
pub fn has_action_containing(&self, substr: &str) -> bool
Return true if any step’s action contains substr as a substring.
Returns false for an empty session.
Sourcepub fn max_observation_chars(&self) -> usize
pub fn max_observation_chars(&self) -> usize
Return the maximum UTF-8 character count among all observation strings.
Returns 0 for an empty session.
Sourcepub fn step_index_of_longest_thought(&self) -> Option<usize>
pub fn step_index_of_longest_thought(&self) -> Option<usize>
Return the 0-based index of the step with the longest thought by
character count, or None for an empty session.
When multiple steps tie for the longest thought the smallest index wins.
Sourcepub fn observation_word_counts(&self) -> Vec<usize>
pub fn observation_word_counts(&self) -> Vec<usize>
Return the number of whitespace-delimited words in each observation, in step order.
Returns an empty Vec for an empty session.
Sourcepub fn observation_starts_with_any(&self, prefixes: &[&str]) -> bool
pub fn observation_starts_with_any(&self, prefixes: &[&str]) -> bool
Return true if any observation starts with one of the given prefixes.
Returns false for an empty session or when no prefix matches.
Sourcepub fn has_repeated_actions(&self) -> bool
pub fn has_repeated_actions(&self) -> bool
Return true if any action string appears more than once in the session.
Non-empty duplicate actions often signal a stuck or looping agent.
Returns false for a session with fewer than two steps.
Sourcepub fn thought_starts_with_any(&self, prefixes: &[&str]) -> bool
pub fn thought_starts_with_any(&self, prefixes: &[&str]) -> bool
Return true if any step thought starts with one of the given prefixes.
Returns false for an empty session or when no prefix matches.
Sourcepub fn action_word_count(&self) -> usize
pub fn action_word_count(&self) -> usize
Return the total number of whitespace-delimited words across all action strings in this session.
Returns 0 for an empty session.
Sourcepub fn steps_above_thought_chars(&self, min: usize) -> usize
pub fn steps_above_thought_chars(&self, min: usize) -> usize
Return the number of steps whose thought character count exceeds min.
Returns 0 for an empty session.
Sourcepub fn steps_with_non_empty_observation(&self) -> Vec<&ReActStep>
pub fn steps_with_non_empty_observation(&self) -> Vec<&ReActStep>
Return all steps that have a non-empty observation string.
Returns an empty Vec for an empty session.
Sourcepub fn observations_containing(&self, substr: &str) -> Vec<&ReActStep>
pub fn observations_containing(&self, substr: &str) -> Vec<&ReActStep>
Return all steps whose observation contains substr.
Returns an empty Vec for an empty session or no matches.
Sourcepub fn thought_observation_ratio(&self) -> f64
pub fn thought_observation_ratio(&self) -> f64
Return the ratio of total thought characters to total observation characters.
Returns 0.0 when there are no observation characters to avoid
division by zero.
Sourcepub fn steps_matching_thought(&self, substr: &str) -> Vec<&ReActStep>
pub fn steps_matching_thought(&self, substr: &str) -> Vec<&ReActStep>
Return all steps whose thought contains substr as a substring.
Returns an empty Vec for an empty session or no matches.
Sourcepub fn median_observation_chars(&self) -> usize
pub fn median_observation_chars(&self) -> usize
Return the median observation character count across all steps.
Returns 0 for an empty session. Uses the lower median when the step
count is even.
Sourcepub fn cumulative_thought_chars(&self) -> Vec<usize>
pub fn cumulative_thought_chars(&self) -> Vec<usize>
Return the cumulative sum of thought character counts, step by step.
The i-th element is the total thought characters from step 0 through
step i inclusive. Returns an empty Vec for an empty session.
Sourcepub fn count_steps_with_thought_containing(&self, substr: &str) -> usize
pub fn count_steps_with_thought_containing(&self, substr: &str) -> usize
Return the number of steps whose thought contains substr.
Returns 0 for an empty session.
Sourcepub fn min_observation_bytes(&self) -> usize
pub fn min_observation_bytes(&self) -> usize
Return the smallest byte length of non-empty observation strings in this session.
Steps with an empty observation are excluded. Returns 0 if no non-empty
observations exist.
Sourcepub fn min_thought_bytes(&self) -> usize
pub fn min_thought_bytes(&self) -> usize
Return the smallest byte length of non-empty thought strings in this session.
Steps with an empty thought are excluded. Returns 0 if no non-empty
thoughts exist.
Sourcepub fn proportion_empty_thoughts(&self) -> f64
pub fn proportion_empty_thoughts(&self) -> f64
Return the proportion of steps whose thought field is empty.
Returns 0.0 for an empty session.
Sourcepub fn has_failed_steps(&self) -> bool
pub fn has_failed_steps(&self) -> bool
Return true if any step in this session is marked as failed.
A step is considered failed when its observation starts with
"[error]" (the convention used by the built-in tool dispatcher).
Sourcepub fn total_thought_chars(&self) -> usize
pub fn total_thought_chars(&self) -> usize
Return the total number of UTF-8 characters across all step thought fields.
Returns 0 for an empty session.
Sourcepub fn total_action_chars(&self) -> usize
pub fn total_action_chars(&self) -> usize
Return the total number of UTF-8 characters across all step action fields.
Returns 0 for an empty session.
Sourcepub fn total_observation_chars(&self) -> usize
pub fn total_observation_chars(&self) -> usize
Return the total number of UTF-8 characters across all step observation
fields.
Returns 0 for an empty session.
Sourcepub fn action_byte_variance(&self) -> f64
pub fn action_byte_variance(&self) -> f64
Return the statistical variance of action byte lengths across all steps.
Useful for detecting inconsistent action sizes. Returns 0.0 for a
session with fewer than two steps or all equal lengths.
Sourcepub fn non_empty_action_count(&self) -> usize
pub fn non_empty_action_count(&self) -> usize
Return the count of steps that have a non-empty action string.
Returns 0 for an empty session.
Sourcepub fn total_step_bytes(&self) -> usize
pub fn total_step_bytes(&self) -> usize
Return the total byte count across all fields (thought + action +
observation) for every step in the session.
Returns 0 for an empty session.
Sourcepub fn last_thought_bytes(&self) -> usize
pub fn last_thought_bytes(&self) -> usize
Return the byte length of the last step’s thought field, or 0 if
the session has no steps.
Sourcepub fn first_observation_bytes(&self) -> usize
pub fn first_observation_bytes(&self) -> usize
Return the byte length of the first step’s observation field, or 0
if the session has no steps.
Sourcepub fn has_step_with_empty_observation(&self) -> bool
pub fn has_step_with_empty_observation(&self) -> bool
Return true if any step has an empty observation field.
Useful for detecting incomplete ReAct traces where a tool produced no output.
Sourcepub fn thought_to_action_byte_ratio(&self) -> f64
pub fn thought_to_action_byte_ratio(&self) -> f64
Return the ratio of total thought bytes to total action bytes.
Returns 0.0 when there are no action bytes (avoids division by zero).
Sourcepub fn observation_above_bytes_count(&self, min_bytes: usize) -> usize
pub fn observation_above_bytes_count(&self, min_bytes: usize) -> usize
Return the number of steps whose observation byte length exceeds
min_bytes.
Returns 0 when the session is empty or no step qualifies.
Sourcepub fn steps_with_both_thought_and_action(&self) -> usize
pub fn steps_with_both_thought_and_action(&self) -> usize
Return the number of steps where both the thought and action
fields are non-empty.
Returns 0 for an empty session.
Sourcepub fn steps_with_observation_prefix(&self, prefix: &str) -> usize
pub fn steps_with_observation_prefix(&self, prefix: &str) -> usize
Return the number of steps whose observation field starts with
prefix.
Returns 0 for an empty session or when no step qualifies.
Sourcepub fn observation_bytes_total(&self) -> usize
pub fn observation_bytes_total(&self) -> usize
Return the total byte count of all observation fields across all
steps.
Returns 0 for an empty session.
Sourcepub fn first_thought_chars(&self) -> usize
pub fn first_thought_chars(&self) -> usize
Return the character count of the first step’s thought field.
Returns 0 for an empty session.
Sourcepub fn last_observation_chars(&self) -> usize
pub fn last_observation_chars(&self) -> usize
Return the character count of the last step’s observation field.
Returns 0 for an empty session.
Sourcepub fn observation_word_count_total(&self) -> usize
pub fn observation_word_count_total(&self) -> usize
Return the total word count across all observation fields.
Words are split on whitespace. Returns 0 for an empty session.
Sourcepub fn action_ends_with_count(&self, suffix: &str) -> usize
pub fn action_ends_with_count(&self, suffix: &str) -> usize
Return the count of steps whose action field ends with suffix.
Returns 0 for an empty session or when no step qualifies.
Sourcepub fn avg_observation_words(&self) -> f64
pub fn avg_observation_words(&self) -> f64
Return the average word count per observation field across all steps.
Returns 0.0 for an empty session.
Sourcepub fn thought_byte_variance(&self) -> f64
pub fn thought_byte_variance(&self) -> f64
Return the statistical variance of thought byte lengths across all steps.
Returns 0.0 for a session with fewer than two steps.
Sourcepub fn steps_above_thought_bytes(&self, min_bytes: usize) -> Vec<&ReActStep>
pub fn steps_above_thought_bytes(&self, min_bytes: usize) -> Vec<&ReActStep>
Return all steps whose thought byte length exceeds min_bytes.
Returns an empty Vec if no step qualifies.
Sourcepub fn total_empty_steps(&self) -> usize
pub fn total_empty_steps(&self) -> usize
Return the number of steps where all three fields (thought, action,
and observation) are empty strings.
Fully empty steps typically indicate a malformed or aborted iteration.
Sourcepub fn action_starts_with_count(&self, prefix: &str) -> usize
pub fn action_starts_with_count(&self, prefix: &str) -> usize
Return the number of steps whose action begins with prefix.
Returns 0 for an empty session or when no action matches.
Sourcepub fn longest_action(&self) -> Option<&str>
pub fn longest_action(&self) -> Option<&str>
Return the longest action string in the session, or None if the
session is empty.
When multiple steps share the maximum byte length, the first one is returned.
Sourcepub fn thought_completeness(&self) -> f64
pub fn thought_completeness(&self) -> f64
Return the proportion of steps that have a non-empty thought string.
Returns 0.0 for an empty session.
Sourcepub fn final_answer_step_index(&self) -> Option<usize>
pub fn final_answer_step_index(&self) -> Option<usize>
Return the 0-based index of the first FINAL_ANSWER step, or None if
no such step exists in the session.
Useful when you need the position of the answer step rather than just
testing whether one exists (see has_final_answer).
Sourcepub fn step_duration_range_ms(&self) -> (u64, u64)
pub fn step_duration_range_ms(&self) -> (u64, u64)
Return the (min, max) step duration range in milliseconds.
Returns (0, 0) for sessions with no steps.
Sourcepub fn count_unique_thoughts(&self) -> usize
pub fn count_unique_thoughts(&self) -> usize
Return the number of distinct thought strings across all steps.
Two steps with identical thought text are counted once. Returns 0
for empty sessions.
Sourcepub fn steps_with_empty_thoughts(&self) -> Vec<&ReActStep>
pub fn steps_with_empty_thoughts(&self) -> Vec<&ReActStep>
Return references to steps whose thought string is empty.
Useful for detecting steps where the model skipped the reasoning phase.
Sourcepub fn steps_with_long_thoughts(
&self,
threshold_bytes: usize,
) -> Vec<&ReActStep>
pub fn steps_with_long_thoughts( &self, threshold_bytes: usize, ) -> Vec<&ReActStep>
Return references to steps whose thought byte length exceeds threshold_bytes.
Useful for identifying steps with unusually verbose reasoning traces.
Sourcepub fn action_count_containing(&self, substring: &str) -> usize
pub fn action_count_containing(&self, substring: &str) -> usize
Return the number of steps whose action string contains substring.
The comparison is case-sensitive. Returns 0 for empty sessions or
when no step matches.
Sourcepub fn total_thought_count(&self) -> usize
pub fn total_thought_count(&self) -> usize
Return the number of steps that have a non-empty thought string.
Complement of steps_with_empty_thoughts. Returns 0 for empty
sessions.
Sourcepub fn has_thought_containing(&self, substring: &str) -> bool
pub fn has_thought_containing(&self, substring: &str) -> bool
Return true if any step’s thought field contains substring
(case-sensitive).
Returns false for empty sessions or when no step matches.
Sourcepub fn steps_with_action_length_above(
&self,
min_bytes: usize,
) -> Vec<&ReActStep>
pub fn steps_with_action_length_above( &self, min_bytes: usize, ) -> Vec<&ReActStep>
Return references to steps whose action field is longer than
min_bytes bytes.
Returns an empty Vec when no step qualifies.
Sourcepub fn into_steps(self) -> Vec<ReActStep>
pub fn into_steps(self) -> Vec<ReActStep>
Consume this session and return its steps as an owned Vec.
Useful when the caller needs owned ReActStep values — for example to
move them into another data structure — without cloning the entire list.
let steps = session.into_steps();
for step in steps { /* owned */ }Sourcepub fn iter_steps(&self) -> Iter<'_, ReActStep>
pub fn iter_steps(&self) -> Iter<'_, ReActStep>
Return an iterator over the steps in this session.
Equivalent to session.steps.iter() but avoids exposing the raw
field for callers who prefer the method-call style.
Sourcepub fn has_at_least_steps(&self, n: usize) -> bool
pub fn has_at_least_steps(&self, n: usize) -> bool
Return true if the session has at least n steps.
More efficient than step_count() >= n because it uses
steps.len() directly and is easy to read at the call site.
Sourcepub fn all_observations_non_empty(&self) -> bool
pub fn all_observations_non_empty(&self) -> bool
Return true if every step in this session has a non-empty observation.
Returns true for an empty session (vacuously true).
Sourcepub fn avg_combined_step_bytes(&self) -> f64
pub fn avg_combined_step_bytes(&self) -> f64
Return the average combined byte length (thought + action + observation) per step.
Returns 0.0 for an empty session.
Sourcepub fn shortest_observation_step(&self) -> Option<&ReActStep>
pub fn shortest_observation_step(&self) -> Option<&ReActStep>
Return a reference to the step with the shortest observation field.
When multiple steps share the minimum observation length the first is
returned. Returns None for an empty session.
Sourcepub fn unique_observation_count(&self) -> usize
pub fn unique_observation_count(&self) -> usize
Return the number of distinct observation strings across all steps.
Returns 0 for an empty session.
Sourcepub fn avg_thought_word_count(&self) -> f64
pub fn avg_thought_word_count(&self) -> f64
Return the average number of whitespace-delimited words per thought.
Returns 0.0 for an empty session.
Sourcepub fn observation_contains_any(&self, terms: &[&str]) -> bool
pub fn observation_contains_any(&self, terms: &[&str]) -> bool
Return true if any step’s observation contains at least one of the
provided terms (case-sensitive substring match).
Returns false for an empty session or an empty terms slice.
Sourcepub fn step_at_index(&self, index: usize) -> Option<&ReActStep>
pub fn step_at_index(&self, index: usize) -> Option<&ReActStep>
Return the step at index, or None if the index is out of bounds.
Sourcepub fn thought_contains_all(&self, terms: &[&str]) -> bool
pub fn thought_contains_all(&self, terms: &[&str]) -> bool
Return true if any step’s thought contains all of the provided
terms as substrings (case-sensitive).
Returns false for an empty terms slice or an empty session.
Sourcepub fn action_contains_any(&self, terms: &[&str]) -> bool
pub fn action_contains_any(&self, terms: &[&str]) -> bool
Return true if any step’s action contains at least one of the
provided terms (case-sensitive substring match).
Returns false for an empty terms slice or an empty session.
Sourcepub fn max_thought_chars(&self) -> usize
pub fn max_thought_chars(&self) -> usize
Return the maximum thought length in characters across all steps.
Returns 0 for an empty session.
Sourcepub fn min_thought_chars(&self) -> usize
pub fn min_thought_chars(&self) -> usize
Return the minimum thought length in characters, considering only steps that have a non-empty thought.
Returns 0 if there are no non-empty thoughts.
Sourcepub fn avg_action_chars(&self) -> f64
pub fn avg_action_chars(&self) -> f64
Return the average number of Unicode chars in the action field across
all steps.
Returns 0.0 for an empty session.
Sourcepub fn avg_observation_chars(&self) -> f64
pub fn avg_observation_chars(&self) -> f64
Return the average number of Unicode chars in the observation field
across all steps.
Returns 0.0 for an empty session.
Sourcepub fn step_with_longest_action(&self) -> Option<&ReActStep>
pub fn step_with_longest_action(&self) -> Option<&ReActStep>
Return a reference to the step whose action string is the longest
(by Unicode char count), or None for an empty session.
When multiple steps tie, the first is returned.
Sourcepub fn action_ends_with(&self, suffix: &str) -> bool
pub fn action_ends_with(&self, suffix: &str) -> bool
Return true if any step’s action ends with the given suffix.
Sourcepub fn thought_ends_with(&self, suffix: &str) -> bool
pub fn thought_ends_with(&self, suffix: &str) -> bool
Return true if any step’s thought ends with the given suffix.
Sourcepub fn has_step_with_both(&self, thought_term: &str, action_term: &str) -> bool
pub fn has_step_with_both(&self, thought_term: &str, action_term: &str) -> bool
Return true if any step’s thought contains thought_term AND that
same step’s action contains action_term.
Sourcepub fn step_count_with_observation_longer_than(&self, min_bytes: usize) -> usize
pub fn step_count_with_observation_longer_than(&self, min_bytes: usize) -> usize
Return the number of steps whose observation byte length strictly
exceeds min_bytes.
Returns 0 for an empty session.
Sourcepub fn thought_word_counts(&self) -> Vec<usize>
pub fn thought_word_counts(&self) -> Vec<usize>
Return a Vec of word counts for each step’s thought, in order.
Sourcepub fn steps_sorted_by_thought_len(&self) -> Vec<&ReActStep>
pub fn steps_sorted_by_thought_len(&self) -> Vec<&ReActStep>
Return steps sorted by thought byte length in ascending order.
Sourcepub fn steps_with_thought_longer_than(
&self,
min_bytes: usize,
) -> Vec<&ReActStep>
pub fn steps_with_thought_longer_than( &self, min_bytes: usize, ) -> Vec<&ReActStep>
Return all steps whose thought byte length strictly exceeds
min_bytes.
Sourcepub fn steps_with_action_containing(&self, substr: &str) -> Vec<&ReActStep>
pub fn steps_with_action_containing(&self, substr: &str) -> Vec<&ReActStep>
Return all steps whose action contains substr as a substring.
Sourcepub fn observation_max_chars(&self) -> usize
pub fn observation_max_chars(&self) -> usize
Return the maximum observation length in Unicode chars across all
steps. Returns 0 for an empty session.
Sourcepub fn observation_min_chars(&self) -> usize
pub fn observation_min_chars(&self) -> usize
Return the minimum observation length in Unicode chars, considering
only steps with a non-empty observation. Returns 0 if no non-empty
observations exist.
Sourcepub fn action_word_counts(&self) -> Vec<usize>
pub fn action_word_counts(&self) -> Vec<usize>
Return a Vec of word counts for each step’s action, in order.
Sourcepub fn thought_avg_chars(&self) -> f64
pub fn thought_avg_chars(&self) -> f64
Return the average number of Unicode chars in the thought field
across all steps. Returns 0.0 for an empty session.
Sourcepub fn thought_byte_range(&self) -> (usize, usize)
pub fn thought_byte_range(&self) -> (usize, usize)
Return (min_bytes, max_bytes) of the thought field across all steps.
Returns (0, 0) for an empty session.
Trait Implementations§
Source§impl Clone for AgentSession
impl Clone for AgentSession
Source§fn clone(&self) -> AgentSession
fn clone(&self) -> AgentSession
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more