Action

Trait Action 

Source
pub trait Action: Send + 'static {
    // Required methods
    fn label(&self) -> &'static str;
    fn apply(self: Box<Self>, step: &mut StepContext<'_>);

    // Provided method
    fn validate(&self, _phase: Phase) -> Result<(), String> { ... }
}
Expand description

Unified action trait for all phase effects.

Actions are emitted by AgentBehavior hooks and tool effects, then applied to StepContext by the runtime after validation. Extension plugins and tools can define their own actions by implementing this trait.

Required Methods§

Source

fn label(&self) -> &'static str

Human-readable label for diagnostics.

Source

fn apply(self: Box<Self>, step: &mut StepContext<'_>)

Apply this action to the mutable step context.

Consumes self (boxed) so that actions can move data into the step context without cloning.

Provided Methods§

Source

fn validate(&self, _phase: Phase) -> Result<(), String>

Check whether this action is valid in the given phase.

Returns Ok(()) if allowed, or Err(reason) describing the violation. The default implementation accepts all phases.

Implementors§