Skip to main content

AgentDecorator

Trait AgentDecorator 

Source
pub trait AgentDecorator: Send + Sync {
    // Required method
    fn decorate<'a>(&self, builder: AgentBuilder<'a>) -> AgentBuilder<'a>;
}
Expand description

Pluggable transform applied to every agent a supervisor spawns.

Implementations receive an AgentBuilder (already bound to the supervisor’s Oxicode instance and seeded with the spawn config) and return a (possibly modified) builder. The supervisor then calls .build() on the returned builder.

This is the integration point for cross-cutting concerns that should apply to every supervisor-spawned agent — observability, capability enforcement, middleware injection, etc.

§Example

use std::sync::Arc;
use oxicode_sdk::{
    observability::{AgentDecorator, ObservabilityDecorator, AuditLog, Tracer},
    OxicodeBuilder,
};

let decorator = ObservabilityDecorator::new()
    .with_audit(Arc::new(AuditLog::new(256)))
    .with_tracer(Arc::new(Tracer::new()));

let (oxicode, supervisor) = OxicodeBuilder::new()
    .with_builtins()
    .supervisor()
    .with_agent_decorator(Arc::new(decorator))
    .build()
    .unwrap();

Required Methods§

Source

fn decorate<'a>(&self, builder: AgentBuilder<'a>) -> AgentBuilder<'a>

Apply this decorator’s transforms to the builder. The implementor may chain audit_log, tracer, authorizer, cost_tracker, capabilities, middleware, etc., then return the builder for the caller to .build().

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§