pub struct TurnContext {Show 20 fields
pub session_id: u64,
pub turn_number: u32,
pub ttft_ms: u64,
pub llm_duration_ms: u64,
pub duration_ms: u64,
pub tool_duration_ms: u64,
pub usage: Option<UsageInfo>,
pub full_text_len: u64,
pub has_thinking: bool,
pub tools_used: Vec<String>,
pub tool_call_count: u32,
pub tool_success: u32,
pub tool_failed: u32,
pub outcome: RunOutcome,
pub error_message: Option<String>,
pub user_input: String,
pub model: String,
pub plan_updates: u32,
pub approval_count: u32,
pub llm_calls: u32,
}Expand description
Pure-data snapshot of a completed turn iteration, passed to turn-end hooks.
Contains all raw data a consumer needs to build turn-level metrics — agent-base itself performs no aggregation, no persistence, and no business-level interpretation of this data.
Fields§
§session_id: u64Numeric session identifier (agent-base internal).
turn_number: u321-based turn number within the session.
ttft_ms: u64Time-to-first-token in milliseconds (user-perceived latency).
llm_duration_ms: u64LLM stream duration in milliseconds.
duration_ms: u64Total wall-clock turn duration in milliseconds (llm + tool + overhead).
tool_duration_ms: u64Total tool execution duration in milliseconds.
usage: Option<UsageInfo>Token usage from the LLM response, if available.
full_text_len: u64Length of the full assistant text response in bytes.
has_thinking: boolWhether the response included thinking/reasoning content.
tools_used: Vec<String>Tool names called in this turn iteration.
tool_call_count: u32Total number of tool calls made.
tool_success: u32Number of tools that succeeded.
tool_failed: u32Number of tools that failed.
outcome: RunOutcomeOutcome of this turn iteration (Completed / Failed / Cancelled / MaxTurnsExceeded).
error_message: Option<String>Error message if the turn errored.
user_input: StringThe user’s input text (may be truncated).
model: StringModel name used for the LLM call.
plan_updates: u32Plan-update events emitted during this turn iteration (taken from EventBus).
approval_count: u32Approval-request events emitted during this turn iteration (taken from EventBus).
llm_calls: u32Number of LLM calls made (≥ 1; includes retries).
Trait Implementations§
Source§impl Clone for TurnContext
impl Clone for TurnContext
Source§fn clone(&self) -> TurnContext
fn clone(&self) -> TurnContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more