pub trait OutputProcessor: Send + Sync {
type Context;
type Output;
// Required method
fn process(
&self,
output: &Self::Output,
ctx: &mut Self::Context,
) -> impl Future<Output = Result<Signal, EngineError>> + Send;
}Expand description
Output processor — handles Thinker output and decides flow control.
After a Thinker produces output, each OutputProcessor in the chain processes it and returns Continue or Stop.
§Chain semantics
Processors are consulted in registration order and share a single
immutable reference to the thinker’s output (no per-processor clone).
The first processor that returns Signal::Stop terminates the loop;
subsequent processors in the chain are not invoked for that turn.
Recommended registration order for side-effect + termination processors:
- Safety / policy gates (may Stop early)
- Side-effect processors (tool execution, message recording)
- Loop guards (doom-loop detection)
- Round limits (max turns)
§Example
use xz_agent_core::traits::processor::OutputProcessor;
use xz_agent_core::error::EngineError;
use xz_agent_core::types::signal::Signal;
struct StopOnHello;
impl OutputProcessor for StopOnHello {
type Context = String;
type Output = String;
async fn process(&self, output: &Self::Output, ctx: &mut Self::Context) -> Result<Signal, EngineError> {
if output == "stop" {
Ok(Signal::Stop)
} else {
ctx.push_str(output);
Ok(Signal::Continue)
}
}
}Required Associated Types§
Required Methods§
Sourcefn process(
&self,
output: &Self::Output,
ctx: &mut Self::Context,
) -> impl Future<Output = Result<Signal, EngineError>> + Send
fn process( &self, output: &Self::Output, ctx: &mut Self::Context, ) -> impl Future<Output = Result<Signal, EngineError>> + Send
Process the Thinker’s output.
Receives a shared reference so the full processor chain can inspect
the same output without requiring Clone.
Returns Continue to proceed or Stop to terminate the engine loop.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".