pub trait AgentStep {
type Answer;
// Required methods
fn into_config(self) -> AgentStepConfig;
fn answer(output: StepOutput) -> Result<Self::Answer, EngineError>;
}Expand description
An agent configuration WorkflowContext::agent
accepts, and the answer it returns for it.
A config built with output::<T>() answers with the
T itself; every other config answers with the raw StepOutput.
§Examples
use ironflow_engine::config::{AgentStep, AgentStepConfig};
use ironflow_engine::executor::{StepArtifacts, StepOutput};
use rust_decimal::Decimal;
use schemars::JsonSchema;
use serde::Deserialize;
use serde_json::json;
#[derive(Deserialize, JsonSchema)]
struct Verdict {
approved: bool,
}
let config = AgentStepConfig::new("Review").max_turns(2).output::<Verdict>();
let output = StepOutput {
output: json!({"approved": true}),
duration_ms: 0,
cost_usd: Decimal::ZERO,
input_tokens: None,
cache_read_input_tokens: None,
cache_creation_input_tokens: None,
output_tokens: None,
model: None,
debug_messages: None,
artifacts: StepArtifacts::default(),
};
let verdict: Verdict = answer(&config, output)?;
assert!(verdict.approved);Required Associated Types§
Required Methods§
Sourcefn into_config(self) -> AgentStepConfig
fn into_config(self) -> AgentStepConfig
The configuration, without its typestate.
Sourcefn answer(output: StepOutput) -> Result<Self::Answer, EngineError>
fn answer(output: StepOutput) -> Result<Self::Answer, EngineError>
Read the step output as the answer.
§Errors
Returns EngineError::Serialization when a typed answer does not
match its type.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".