Skip to main content

AgentStep

Trait AgentStep 

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

Source

type Answer

What the step returns to the handler.

Required Methods§

Source

fn into_config(self) -> AgentStepConfig

The configuration, without its typestate.

Source

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".

Implementations on Foreign Types§

Source§

impl AgentStep for AgentConfig<NoTools, NoSchema>

Source§

impl AgentStep for AgentConfig<NoTools, RawSchema>

Source§

impl AgentStep for AgentConfig<WithTools, NoSchema>

Source§

impl<T: DeserializeOwned> AgentStep for AgentConfig<NoTools, WithSchema<T>>

Implementors§