Skip to main content

Step

Struct Step 

Source
pub struct Step {
Show 16 fields pub id: String, pub step_index: u32, pub kind: StepType, pub source: StepSource, pub target: StepTarget, pub status: StepStatus, pub content: String, pub content_delta: String, pub thinking: String, pub thinking_delta: String, pub tool_calls: Vec<ToolCall>, pub tool_results: Vec<ToolResult>, pub error: String, pub is_complete_response: Option<bool>, pub structured_output: Option<Value>, pub usage_metadata: Option<UsageMetadata>,
}
Expand description

One event in the agent’s response stream.

Fields§

§id: String

Backend-assigned step identifier.

§step_index: u32

Zero-based index within the current turn.

§kind: StepType

What kind of event this step represents.

§source: StepSource

Who produced this step.

§target: StepTarget

Intended audience.

§status: StepStatus

Lifecycle state.

§content: String

Accumulated text content.

§content_delta: String

Incremental text delta since the last step.

§thinking: String

Accumulated thinking (reasoning) text.

§thinking_delta: String

Incremental thinking delta.

§tool_calls: Vec<ToolCall>

Tool calls the model is requesting.

§tool_results: Vec<ToolResult>

Dispatched tool RESULTS (a Step::tool_result observability step). Stream consumers (ChatResponse::chunksStreamChunk::ToolResult) read these to flip a tool block from “running” to ok/err and render inline result cards. Empty on every other step kind; omitted from the wire when empty (old-shape compatible).

§error: String

Error message, if any.

§is_complete_response: Option<bool>

Explicit flag that this step ends the turn.

§structured_output: Option<Value>

Structured JSON output from the finish tool.

§usage_metadata: Option<UsageMetadata>

Token usage for this step.

Implementations§

Source§

impl Step

Source

pub fn text_delta(trajectory_id: &str, step_index: u32, delta: &str) -> Self

A streamed text delta (model → user, Active, non-terminal).

Source

pub fn thought_delta(trajectory_id: &str, step_index: u32, delta: &str) -> Self

A streamed thinking (reasoning) delta (model → user, Active, non-terminal).

Source

pub fn tool_call(step_index: u32, call: ToolCall, status: StepStatus) -> Self

A tool-call step (model → environment, non-terminal) surfacing call on the stream. status is StepStatus::Active when emitted ahead of dispatch (the live backends) or StepStatus::Done when the call was already dispatched inline and the step is observability-only (the mock backend — the Agent’s step dispatcher skips Done steps).

Source

pub fn tool_result(step_index: u32, result: ToolResult) -> Self

A resolved-tool-result step (model → environment, Done, non-terminal, NO tool_calls) carrying the full dispatched ToolResult in tool_resultsChatResponse::chunks surfaces it as StreamChunk::ToolResult so a UI can flip the tool block from “running” to ok/err and render the inline result card. Done + Model→Environment so it is observability-only: the step dispatcher skips Done steps, and it never trips the System+Error turn-failure translation in subscribe_steps (a tool error must not abort the turn — it also rides in error for step-level consumers).

Source

pub fn turn_complete( trajectory_id: impl Into<String>, step_index: u32, status: StepStatus, content: impl Into<String>, error: impl Into<String>, finished: bool, structured_output: Option<Value>, usage_metadata: Option<UsageMetadata>, ) -> Self

The turn-terminating step (model → user, terminal). kind is StepType::Finish when the model called the finish tool (finished == true) OR carried structured output (a bare finish with no output arg still flags Finish), else StepType::TextResponse. The Finish kind is the canonical “the model said it’s done” signal — consumers (the in-tab loop) read it to stop auto-continuing and to suppress an empty-response bubble on a pure-tool/finish turn.

Source

pub fn turn_error(step_index: u32, message: impl Into<String>) -> Self

A System-sourced turn-failure step (terminal, status Error) carrying message. Backends whose subscribe_steps translates turn failures convert exactly this shape into a stream Err.

Source

pub fn is_terminal_response(&self) -> bool

A turn-terminating step: model-sourced, user-facing, status DONE, with content. Mirrors is_complete_response semantics in the Python SDK.

Trait Implementations§

Source§

impl Clone for Step

Source§

fn clone(&self) -> Step

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Step

Source§

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

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

impl<'de> Deserialize<'de> for Step

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 PartialEq for Step

Source§

fn eq(&self, other: &Step) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Step

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
Source§

impl StructuralPartialEq for Step

Auto Trait Implementations§

§

impl Freeze for Step

§

impl RefUnwindSafe for Step

§

impl Send for Step

§

impl Sync for Step

§

impl Unpin for Step

§

impl UnsafeUnpin for Step

§

impl UnwindSafe for Step

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more