Skip to main content

AgentEvent

Trait AgentEvent 

Source
pub trait AgentEvent:
    Any
    + Send
    + Sync
    + Debug {
    // Provided method
    fn name(&self) -> &'static str { ... }
}
Expand description

Application-level event abstraction.

Each Agent implementation defines its own event types (tool lifecycle / plan steps / retrieval / sub-agents, etc.); the framework doesn’t anticipate variants. Events are pushed through EventChannel for external subscription. Consumers downcast known types precisely via as_any (see impl dyn AgentEvent below) and fall back to name for unknown types.

Event payloads are uniformly Arc<dyn AgentEvent>: Arc covers the clone requirement of broadcast channels, the trait itself needs no Clone, and event types are zero-boilerplate.

Provided Methods§

Source

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

Event name: lets subscribers at least display a name for unknown types. Default = the type’s full path; override for a short name (e.g. "tool.started").

Implementations§

Source§

impl dyn AgentEvent

Source

pub fn as_any(&self) -> &dyn Any

Typed access: event.as_any().downcast_ref::<ToolStarted>().

Declared as an inherent method rather than a trait default method: &dyn AgentEvent&dyn Any is a trait-object upcast (Rust 1.86+, with Any as a supertrait), which can’t be expressed directly in a trait default method.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§