Skip to main content

AgentStreamEvent

Enum AgentStreamEvent 

Source
pub enum AgentStreamEvent<Output = Value> {
Show 14 variants RunStart { run_id: String, step: u32, }, RequestStart { step: u32, }, TextDelta { content: String, part_index: usize, }, ToolCallStart { name: String, tool_call_id: Option<String>, index: usize, }, ToolCallDelta { args_delta: String, index: usize, }, ToolCallComplete { name: String, args: Value, index: usize, }, ToolResult { name: String, result: Value, success: bool, index: usize, }, ThinkingDelta { content: String, index: usize, }, PartialOutput { output: Output, }, ResponseComplete { response: ModelResponse, }, UsageUpdate { usage: RequestUsage, }, FinalOutput { output: Output, }, RunComplete { run_id: String, total_steps: u32, }, Error { message: String, recoverable: bool, },
}
Expand description

Events emitted during streaming.

Variants§

§

RunStart

Run started.

Fields

§run_id: String

The run ID.

§step: u32

Step number (0 for start).

§

RequestStart

Model request started.

Fields

§step: u32

Current step number.

§

TextDelta

Text delta received.

Fields

§content: String

The text content.

§part_index: usize

Index of the part this delta belongs to.

§

ToolCallStart

Tool call started.

Fields

§name: String

Tool name.

§tool_call_id: Option<String>

Tool call ID (if available).

§index: usize

Index of this tool call.

§

ToolCallDelta

Tool call arguments delta.

Fields

§args_delta: String

Arguments delta (JSON string).

§index: usize

Index of this tool call.

§

ToolCallComplete

Tool call completed.

Fields

§name: String

Tool name.

§args: Value

Complete arguments.

§index: usize

Index of this tool call.

§

ToolResult

Tool result received.

Fields

§name: String

Tool name.

§result: Value

Result content.

§success: bool

Whether the tool succeeded.

§index: usize

Index of this tool call.

§

ThinkingDelta

Thinking delta (for Claude extended thinking).

Fields

§content: String

The thinking content.

§index: usize

Index of this thinking part.

§

PartialOutput

Partial output available (validated incrementally).

Fields

§output: Output

The partial output.

§

ResponseComplete

Model response complete.

Fields

§response: ModelResponse

The complete response.

§

UsageUpdate

Usage update.

Fields

§usage: RequestUsage

Current usage.

§

FinalOutput

Final output ready.

Fields

§output: Output

The final output.

§

RunComplete

Run complete.

Fields

§run_id: String

The run ID.

§total_steps: u32

Total steps.

§

Error

Error occurred.

Fields

§message: String

Error message.

§recoverable: bool

Whether the error is recoverable.

Implementations§

Source§

impl<Output> AgentStreamEvent<Output>

Source

pub fn run_start(run_id: impl Into<String>, step: u32) -> Self

Create a run start event.

Source

pub fn text_delta(content: impl Into<String>, part_index: usize) -> Self

Create a text delta event.

Source

pub fn error(message: impl Into<String>, recoverable: bool) -> Self

Create an error event.

Source

pub fn is_terminal(&self) -> bool

Check if this is the final event.

Source

pub fn is_error(&self) -> bool

Check if this is an error event.

Source

pub fn as_text(&self) -> Option<&str>

Get the text content if this is a text delta.

Source

pub fn as_output(&self) -> Option<&Output>

Get the output if this is a final output event.

Source

pub fn map_output<U, F>(self, f: F) -> AgentStreamEvent<U>
where F: FnOnce(Output) -> U,

Map the output type.

Trait Implementations§

Source§

impl<Output: Clone> Clone for AgentStreamEvent<Output>

Source§

fn clone(&self) -> AgentStreamEvent<Output>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Output: Debug> Debug for AgentStreamEvent<Output>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, Output> Deserialize<'de> for AgentStreamEvent<Output>
where Output: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<Output: Display> Display for AgentStreamEvent<Output>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Output> Serialize for AgentStreamEvent<Output>
where Output: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<Output> Freeze for AgentStreamEvent<Output>
where Output: Freeze,

§

impl<Output> RefUnwindSafe for AgentStreamEvent<Output>
where Output: RefUnwindSafe,

§

impl<Output> Send for AgentStreamEvent<Output>
where Output: Send,

§

impl<Output> Sync for AgentStreamEvent<Output>
where Output: Sync,

§

impl<Output> Unpin for AgentStreamEvent<Output>
where Output: Unpin,

§

impl<Output> UnwindSafe for AgentStreamEvent<Output>
where Output: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,