pub struct StepOutput {
pub output: Value,
pub duration_ms: u64,
pub cost_usd: Decimal,
pub input_tokens: Option<u64>,
pub output_tokens: Option<u64>,
pub model: Option<String>,
pub debug_messages: Option<Vec<DebugMessage>>,
}Expand description
Result of executing a single step.
Fields§
§output: ValueSerialized output (stdout for shell, body for http, value for agent).
For agent steps with a JSON schema, the value may not strictly conform
to the schema: Claude CLI can flatten wrapper objects with a single
array field, returning a bare array instead of {"items": [...]}.
Callers should handle both the expected wrapper and a bare value.
duration_ms: u64Wall-clock duration in milliseconds.
cost_usd: DecimalCost in USD (agent steps only).
input_tokens: Option<u64>Input token count (agent steps only).
output_tokens: Option<u64>Output token count (agent steps only).
model: Option<String>Model identifier used for agent steps (e.g. "claude-sonnet-4-20250514").
debug_messages: Option<Vec<DebugMessage>>Conversation trace from verbose agent invocations.
Implementations§
Source§impl StepOutput
impl StepOutput
Sourcepub fn debug_messages_json(&self) -> Option<Value>
pub fn debug_messages_json(&self) -> Option<Value>
Serialize debug messages to a JSON Value for store persistence.
Returns None when verbose mode was off (no messages captured).
Sourcepub fn exit_code(&self) -> Option<i64>
pub fn exit_code(&self) -> Option<i64>
Exit code of a shell step.
Returns None for non-shell steps or when the field is absent.
§Examples
use ironflow_engine::executor::StepOutput;
use rust_decimal::Decimal;
use serde_json::json;
let output = StepOutput {
output: json!({"stdout": "ok\n", "stderr": "", "exit_code": 0}),
duration_ms: 3,
cost_usd: Decimal::ZERO,
input_tokens: None,
output_tokens: None,
model: None,
debug_messages: None,
};
assert_eq!(output.exit_code(), Some(0));Sourcepub fn stdout(&self) -> &str
pub fn stdout(&self) -> &str
Standard output of a shell step, or an empty string for other kinds.
§Examples
use ironflow_engine::executor::StepOutput;
use rust_decimal::Decimal;
use serde_json::json;
let output = StepOutput {
output: json!({"stdout": "42 tests passed\n", "stderr": "", "exit_code": 0}),
duration_ms: 3,
cost_usd: Decimal::ZERO,
input_tokens: None,
output_tokens: None,
model: None,
debug_messages: None,
};
assert!(output.stdout().contains("42 tests"));Sourcepub fn stderr(&self) -> &str
pub fn stderr(&self) -> &str
Standard error of a shell step, or an empty string for other kinds.
§Examples
use ironflow_engine::executor::StepOutput;
use rust_decimal::Decimal;
use serde_json::json;
let output = StepOutput {
output: json!({"stdout": "", "stderr": "warning: unused", "exit_code": 0}),
duration_ms: 3,
cost_usd: Decimal::ZERO,
input_tokens: None,
output_tokens: None,
model: None,
debug_messages: None,
};
assert_eq!(output.stderr(), "warning: unused");Sourcepub fn status(&self) -> Option<u16>
pub fn status(&self) -> Option<u16>
HTTP status code of an HTTP step.
Returns None for non-HTTP steps or when the field is absent.
§Examples
use ironflow_engine::executor::StepOutput;
use rust_decimal::Decimal;
use serde_json::json;
let output = StepOutput {
output: json!({"status": 204, "body": ""}),
duration_ms: 3,
cost_usd: Decimal::ZERO,
input_tokens: None,
output_tokens: None,
model: None,
debug_messages: None,
};
assert_eq!(output.status(), Some(204));Sourcepub fn body(&self) -> &str
pub fn body(&self) -> &str
Response body of an HTTP step, or an empty string for other kinds.
§Examples
use ironflow_engine::executor::StepOutput;
use rust_decimal::Decimal;
use serde_json::json;
let output = StepOutput {
output: json!({"status": 200, "body": "{\"ok\":true}"}),
duration_ms: 3,
cost_usd: Decimal::ZERO,
input_tokens: None,
output_tokens: None,
model: None,
debug_messages: None,
};
assert_eq!(output.body(), "{\"ok\":true}");Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Whether the step succeeded from the point of view of its own kind.
- Shell step: the exit code is
0. - HTTP step: the status is in the
2xxrange. - Any other kind:
false, since no success marker is recorded.
Mostly useful after a step configured with allow_failure(), since a
failing step otherwise returns an error from the context method.
§Examples
use ironflow_engine::executor::StepOutput;
use rust_decimal::Decimal;
use serde_json::json;
let shell = StepOutput {
output: json!({"stdout": "", "stderr": "", "exit_code": 1}),
duration_ms: 3,
cost_usd: Decimal::ZERO,
input_tokens: None,
output_tokens: None,
model: None,
debug_messages: None,
};
assert!(!shell.is_success());
let http = StepOutput { output: json!({"status": 201, "body": ""}), ..shell.clone() };
assert!(http.is_success());Sourcepub fn json<T: DeserializeOwned>(&self) -> Result<T, EngineError>
pub fn json<T: DeserializeOwned>(&self) -> Result<T, EngineError>
Deserialize the step output into T.
Intended for agent steps constrained by a JSON schema, and for custom operations that return structured JSON.
§Errors
Returns EngineError::Serialization when the output does not match T.
§Examples
use ironflow_engine::executor::StepOutput;
use rust_decimal::Decimal;
use serde::Deserialize;
use serde_json::json;
#[derive(Deserialize)]
struct Review {
score: u8,
}
let output = StepOutput {
output: json!({"score": 8}),
duration_ms: 3,
cost_usd: Decimal::ZERO,
input_tokens: None,
output_tokens: None,
model: None,
debug_messages: None,
};
let review: Review = output.json()?;
assert_eq!(review.score, 8);Trait Implementations§
Source§impl Clone for StepOutput
impl Clone for StepOutput
Source§fn clone(&self) -> StepOutput
fn clone(&self) -> StepOutput
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more