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: StringBackend-assigned step identifier.
step_index: u32Zero-based index within the current turn.
kind: StepTypeWhat kind of event this step represents.
source: StepSourceWho produced this step.
target: StepTargetIntended audience.
status: StepStatusLifecycle state.
content: StringAccumulated text content.
content_delta: StringIncremental text delta since the last step.
thinking: StringAccumulated thinking (reasoning) text.
thinking_delta: StringIncremental 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::chunks → StreamChunk::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: StringError 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
impl Step
Sourcepub fn text_delta(trajectory_id: &str, step_index: u32, delta: &str) -> Self
pub fn text_delta(trajectory_id: &str, step_index: u32, delta: &str) -> Self
A streamed text delta (model → user, Active, non-terminal).
Sourcepub fn thought_delta(trajectory_id: &str, step_index: u32, delta: &str) -> Self
pub fn thought_delta(trajectory_id: &str, step_index: u32, delta: &str) -> Self
A streamed thinking (reasoning) delta (model → user, Active,
non-terminal).
Sourcepub fn tool_call(step_index: u32, call: ToolCall, status: StepStatus) -> Self
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).
Sourcepub fn tool_result(step_index: u32, result: ToolResult) -> Self
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_results — ChatResponse::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).
Sourcepub 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
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.
Sourcepub fn turn_error(step_index: u32, message: impl Into<String>) -> Self
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.
Sourcepub fn is_terminal_response(&self) -> bool
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.