pub struct AgentResult {
pub messages: Vec<AgentMessage>,
pub stop_reason: StopReason,
pub usage: Usage,
pub cost: Cost,
pub error: Option<String>,
pub transfer_signal: Option<TransferSignal>,
}Expand description
The value returned by non-streaming invocations.
Fields§
§messages: Vec<AgentMessage>All new messages produced during the run.
stop_reason: StopReasonThe final stop reason from the last assistant message.
usage: UsageAggregated token usage across all turns in the run.
cost: CostAggregated cost across all turns in the run.
error: Option<String>Optional error string if the run ended in an error state.
transfer_signal: Option<TransferSignal>Optional transfer signal when the run ended with StopReason::Transfer.
Implementations§
Source§impl AgentResult
impl AgentResult
Sourcepub fn assistant_text(&self) -> String
pub fn assistant_text(&self) -> String
Extract the text content from the last assistant message, if any.
Iterates messages in reverse order, finds the first Assistant message,
and returns its concatenated text blocks. Returns an empty string if no
assistant message is found or if the assistant message contains no text.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AgentResult
impl !RefUnwindSafe for AgentResult
impl Send for AgentResult
impl Sync for AgentResult
impl Unpin for AgentResult
impl UnsafeUnpin for AgentResult
impl !UnwindSafe for AgentResult
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