Skip to main content

AgentEvent

Enum AgentEvent 

Source
pub enum AgentEvent {
Show 14 variants InvocationStarted { role: AgentRole, agent: String, model: Option<String>, }, InvocationSucceeded { role: AgentRole, agent: String, }, InvocationFailed { role: AgentRole, agent: String, exit_code: i32, error_kind: AgentErrorKind, retriable: bool, }, FallbackTriggered { role: AgentRole, from_agent: String, to_agent: String, }, ModelFallbackTriggered { role: AgentRole, agent: String, from_model: String, to_model: String, }, RetryCycleStarted { role: AgentRole, cycle: u32, }, ChainExhausted { role: AgentRole, }, ChainInitialized { role: AgentRole, agents: Vec<String>, max_cycles: u32, retry_delay_ms: u64, backoff_multiplier: f64, max_backoff_ms: u64, }, RateLimited { role: AgentRole, agent: String, prompt_context: Option<String>, }, AuthFailed { role: AgentRole, agent: String, }, TimedOut { role: AgentRole, agent: String, }, SessionEstablished { role: AgentRole, agent: String, session_id: String, }, XsdValidationFailed { role: AgentRole, artifact: ArtifactType, error: String, retry_count: u32, }, TemplateVariablesInvalid { role: AgentRole, template_name: String, missing_variables: Vec<String>, unresolved_placeholders: Vec<String>, },
}
Expand description

Agent invocation and chain management events.

Events related to agent execution, fallback chains, model switching, rate limiting, and retry cycles. The agent chain provides fault tolerance through multiple fallback levels:

  1. Model level: Try different models for the same agent
  2. Agent level: Switch to a fallback agent
  3. Retry cycle: Start over with exponential backoff

§State Transitions

  • InvocationFailed(retriable=true): Advances to next model
  • InvocationFailed(retriable=false): Typically switches to next agent (policy may vary by kind)
  • RateLimited: Typically immediate agent switch with prompt preservation
  • ChainExhausted: Starts new retry cycle
  • InvocationSucceeded: Clears continuation prompt

Variants§

§

InvocationStarted

Agent invocation started.

Fields

§role: AgentRole

The role this agent is fulfilling.

§agent: String

The agent being invoked.

§model: Option<String>

The model being used, if specified.

§

InvocationSucceeded

Agent invocation succeeded.

Fields

§role: AgentRole

The role this agent fulfilled.

§agent: String

The agent that succeeded.

§

InvocationFailed

Agent invocation failed.

Fields

§role: AgentRole

The role this agent was fulfilling.

§agent: String

The agent that failed.

§exit_code: i32

The exit code from the agent process.

§error_kind: AgentErrorKind

The kind of error that occurred.

§retriable: bool

Whether this error is retriable with the same agent.

§

FallbackTriggered

Fallback triggered to switch to a different agent.

Fields

§role: AgentRole

The role being fulfilled.

§from_agent: String

The agent being switched from.

§to_agent: String

The agent being switched to.

§

ModelFallbackTriggered

Model fallback triggered within the same agent.

Fields

§role: AgentRole

The role being fulfilled.

§agent: String

The agent whose model is changing.

§from_model: String

The model being switched from.

§to_model: String

The model being switched to.

§

RetryCycleStarted

Retry cycle started (all agents exhausted, starting over).

Fields

§role: AgentRole

The role being retried.

§cycle: u32

The cycle number starting.

§

ChainExhausted

Agent chain exhausted (no more agents/models to try).

Fields

§role: AgentRole

The role whose chain is exhausted.

§

ChainInitialized

Agent chain initialized with available agents.

Fields

§role: AgentRole

The role this chain is for.

§agents: Vec<String>

The agents available in this chain.

§max_cycles: u32

Maximum number of retry cycles allowed for this chain.

§retry_delay_ms: u64

Base retry-cycle delay in milliseconds.

§backoff_multiplier: f64

Exponential backoff multiplier.

§max_backoff_ms: u64

Maximum backoff delay in milliseconds.

§

RateLimited

Agent hit rate limit (429).

Effects/executors emit this as a fact event. The reducer decides whether/when to switch agents.

Fields

§role: AgentRole

The role being fulfilled.

§agent: String

The agent that hit the rate limit.

§prompt_context: Option<String>

The prompt that was being executed when rate limit was hit. This allows the next agent to continue the same work.

§

AuthFailed

Agent hit authentication failure (401/403).

Effects/executors emit this as a fact event. The reducer decides whether/when to switch agents.

Fields

§role: AgentRole

The role being fulfilled.

§agent: String

The agent that failed authentication.

§

TimedOut

Agent hit an idle timeout.

Effects/executors emit this as a fact event. The reducer decides whether/when to switch agents. Unlike rate limits, timeouts do not preserve prompt context.

Fields

§role: AgentRole

The role being fulfilled.

§agent: String

The agent that timed out.

§

SessionEstablished

Session established with agent.

Emitted when an agent response includes a session ID that can be used for XSD retry continuation. This enables reusing the same session when retrying due to validation failures.

Fields

§role: AgentRole

The role this agent is fulfilling.

§agent: String

The agent name.

§session_id: String

The session ID returned by the agent.

§

XsdValidationFailed

XSD validation failed for agent output.

Emitted when agent output cannot be parsed or fails XSD validation. Distinct from OutputValidationFailed events in phase-specific enums, this is the canonical XSD retry trigger that the reducer uses to decide whether to retry with the same agent/session or advance the chain.

Fields

§role: AgentRole

The role whose output failed validation.

§artifact: ArtifactType

The artifact type that failed validation.

§error: String

Error message from validation.

§retry_count: u32

Current XSD retry count for this artifact.

§

TemplateVariablesInvalid

Template rendering failed due to missing required variables or unresolved placeholders.

Emitted when a prompt template cannot be rendered because required variables are missing or unresolved placeholders (e.g., {{VAR}}) remain in the output. The reducer decides fallback policy, typically switching to the next agent.

Fields

§role: AgentRole

The role whose template failed to render.

§template_name: String

The name of the template that failed.

§missing_variables: Vec<String>

Variables that were required but not provided.

§unresolved_placeholders: Vec<String>

Placeholder patterns that remain unresolved in the rendered output.

Trait Implementations§

Source§

impl Clone for AgentEvent

Source§

fn clone(&self) -> AgentEvent

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AgentEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AgentEvent

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for AgentEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,