#[non_exhaustive]pub struct AgentMetrics {
pub cycle_count: u64,
pub accumulated_usage: Usage,
pub accumulated_metrics: Metrics,
pub agent_invocations: Vec<InvocationMetricsData>,
pub tool_metrics: Vec<(String, ToolMetricsData)>,
pub total_duration: u64,
pub latest_context_size: Option<u64>,
pub projected_context_size: Option<u64>,
}Expand description
Read-only snapshot of an agent’s aggregated loop metrics (AgentMetrics).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.cycle_count: u64Total number of agent loop cycles across all invocations.
accumulated_usage: UsageToken usage accumulated across all model calls.
accumulated_metrics: MetricsPerformance metrics accumulated across all model calls.
agent_invocations: Vec<InvocationMetricsData>Metrics of the most recent invocations (at most 50).
tool_metrics: Vec<(String, ToolMetricsData)>Per-tool metrics by tool name, in first-use order.
total_duration: u64Total duration of all cycles in milliseconds.
latest_context_size: Option<u64>The whole prompt of the last model call, cached tokens included.
projected_context_size: Option<u64>Projected context size of the next model call: the last prompt plus its output.
Implementations§
Source§impl AgentMetrics
impl AgentMetrics
Sourcepub fn with_latest_context_size(self, size: u64) -> Self
pub fn with_latest_context_size(self, size: u64) -> Self
Sets the latest context size.
Sourcepub fn with_projected_context_size(self, size: u64) -> Self
pub fn with_projected_context_size(self, size: u64) -> Self
Sets the projected context size.
Sourcepub fn latest_agent_invocation(&self) -> Option<&InvocationMetricsData>
pub fn latest_agent_invocation(&self) -> Option<&InvocationMetricsData>
The most recent invocation.
Sourcepub fn accumulated_data(&self) -> (&Usage, &Metrics)
pub fn accumulated_data(&self) -> (&Usage, &Metrics)
Accumulated usage and performance metrics together.
Sourcepub fn average_cycle_time(&self) -> f64
pub fn average_cycle_time(&self) -> f64
Average cycle duration in milliseconds, or 0 without cycles.
Sourcepub fn tool(&self, name: &str) -> Option<&ToolMetricsData>
pub fn tool(&self, name: &str) -> Option<&ToolMetricsData>
Metrics of one tool by name.
Sourcepub fn tool_usage(&self) -> Vec<(String, ToolUsage)>
pub fn tool_usage(&self) -> Vec<(String, ToolUsage)>
Per-tool statistics with averages and success rates.
Trait Implementations§
Source§impl Clone for AgentMetrics
impl Clone for AgentMetrics
Source§impl Debug for AgentMetrics
impl Debug for AgentMetrics
Source§impl Default for AgentMetrics
impl Default for AgentMetrics
Source§impl<'de> Deserialize<'de> for AgentMetrics
impl<'de> Deserialize<'de> for AgentMetrics
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>,
impl Eq for AgentMetrics
Source§impl PartialEq for AgentMetrics
impl PartialEq for AgentMetrics
Source§impl Serialize for AgentMetrics
impl Serialize for AgentMetrics
impl StructuralPartialEq for AgentMetrics
Auto Trait Implementations§
impl Freeze for AgentMetrics
impl RefUnwindSafe for AgentMetrics
impl Send for AgentMetrics
impl Sync for AgentMetrics
impl Unpin for AgentMetrics
impl UnsafeUnpin for AgentMetrics
impl UnwindSafe for AgentMetrics
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more