Skip to main content

StopReason

Enum StopReason 

Source
#[non_exhaustive]
pub enum StopReason {
Show 13 variants Converged, CriteriaMet { criteria: Vec<CriterionId>, }, UserCancelled, HumanInterventionRequired { criteria: Vec<CriterionId>, approval_refs: Vec<ApprovalPointId>, }, CycleBudgetExhausted { cycles_executed: u32, limit: u32, }, FactBudgetExhausted { facts_count: u32, limit: u32, }, TokenBudgetExhausted { tokens_consumed: u64, limit: u64, }, TimeBudgetExhausted { duration_ms: u64, limit_ms: u64, }, InvariantViolated { class: InvariantClass, name: String, reason: String, }, PromotionRejected { proposal_id: ProposalId, reason: String, }, Error { message: String, category: ErrorCategory, }, AgentRefused { agent_id: String, reason: String, }, HitlGatePending { gate_id: GateId, proposal_id: ProposalId, summary: String, agent_id: String, cycle: u32, },
}
Expand description

Why execution stopped. Exhaustive enumeration for audit trails.

Every engine run terminates with a StopReason. This enables:

  • Audit: Know exactly why execution ended
  • Recovery: Different reasons may have different retry strategies
  • Monitoring: Track termination patterns

§Non-Exhaustive

Marked #[non_exhaustive] to allow adding new reasons without breaking existing match statements.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Converged

Convergence reached - context stabilized (fixed point). This is the ideal outcome.

§

CriteriaMet

Intent criteria satisfied before convergence. All success conditions met, no need to continue.

Fields

§criteria: Vec<CriterionId>

Which criteria were satisfied

§

UserCancelled

User requested stop via cancellation. Graceful termination, not an error.

§

HumanInterventionRequired

Agents converged, but completion is blocked on human intervention. Unlike HitlGatePending, the engine did not pause mid-merge; the application-level criteria evaluation determined that a human must act before the truth can be considered complete.

Fields

§criteria: Vec<CriterionId>

Which required criteria are blocked.

§approval_refs: Vec<ApprovalPointId>

Optional approval/workflow references surfaced by the evaluator.

§

CycleBudgetExhausted

Maximum execution cycles exceeded. May indicate non-converging problem or need for larger budget.

Fields

§cycles_executed: u32

How many cycles were executed

§limit: u32

What the limit was

§

FactBudgetExhausted

Maximum facts in context exceeded. Prevents unbounded context growth.

Fields

§facts_count: u32

How many facts were in context

§limit: u32

What the limit was

§

TokenBudgetExhausted

Maximum LLM tokens exceeded. Cost control for LLM-based operations.

Fields

§tokens_consumed: u64

How many tokens were consumed

§limit: u64

What the limit was

§

TimeBudgetExhausted

Maximum wall-clock time exceeded. Prevents indefinite execution.

Fields

§duration_ms: u64

How long execution ran (milliseconds)

§limit_ms: u64

What the limit was (milliseconds)

§

InvariantViolated

An invariant was violated. Includes the class (Structural/Semantic/Acceptance) and invariant name.

Fields

§class: InvariantClass

Which class of invariant

§name: String

Name of the invariant

§reason: String

Description of the violation

§

PromotionRejected

Promotion gate rejected a proposal. Proposal failed validation and could not be promoted.

Fields

§proposal_id: ProposalId

ID of the rejected proposal

§reason: String

Why it was rejected

§

Error

Unrecoverable error during execution. Something went wrong that couldn’t be handled.

Fields

§message: String

Error message

§category: ErrorCategory

Error category for programmatic handling

§

AgentRefused

An agent refused to continue. Suggestor explicitly declined to produce output.

Fields

§agent_id: String

ID of the refusing agent

§reason: String

Why it refused

§

HitlGatePending

Convergence paused at a human-in-the-loop gate. A proposal requires human approval before convergence can continue. The hosting application should notify the human and call Engine::resume() with the decision.

Fields

§gate_id: GateId

Unique ID for this gate (used to resume)

§proposal_id: ProposalId

ID of the proposal awaiting approval

§summary: String

Human-readable summary of the proposal

§agent_id: String

Which agent made the proposal

§cycle: u32

Cycle at which convergence was paused

Implementations§

Source§

impl StopReason

Source

pub fn converged() -> StopReason

Create a Converged stop reason.

Source

pub fn criteria_met(criteria: Vec<CriterionId>) -> StopReason

Create a CriteriaMet stop reason.

Source

pub fn user_cancelled() -> StopReason

Create a UserCancelled stop reason.

Source

pub fn human_intervention_required( criteria: Vec<CriterionId>, approval_refs: Vec<ApprovalPointId>, ) -> StopReason

Create a HumanInterventionRequired stop reason.

Source

pub fn cycle_budget_exhausted(cycles_executed: u32, limit: u32) -> StopReason

Create a CycleBudgetExhausted stop reason.

Source

pub fn fact_budget_exhausted(facts_count: u32, limit: u32) -> StopReason

Create a FactBudgetExhausted stop reason.

Source

pub fn token_budget_exhausted(tokens_consumed: u64, limit: u64) -> StopReason

Create a TokenBudgetExhausted stop reason.

Source

pub fn time_budget_exhausted(duration_ms: u64, limit_ms: u64) -> StopReason

Create a TimeBudgetExhausted stop reason.

Source

pub fn invariant_violated( class: InvariantClass, name: impl Into<String>, reason: impl Into<String>, ) -> StopReason

Create an InvariantViolated stop reason.

Source

pub fn promotion_rejected( proposal_id: impl Into<ProposalId>, reason: impl Into<String>, ) -> StopReason

Create a PromotionRejected stop reason.

Source

pub fn error(message: impl Into<String>, category: ErrorCategory) -> StopReason

Create an Error stop reason.

Source

pub fn agent_refused( agent_id: impl Into<String>, reason: impl Into<String>, ) -> StopReason

Create an AgentRefused stop reason.

Source

pub fn hitl_gate_pending( gate_id: impl Into<GateId>, proposal_id: impl Into<ProposalId>, summary: impl Into<String>, agent_id: impl Into<String>, cycle: u32, ) -> StopReason

Create a HitlGatePending stop reason.

Source

pub fn is_success(&self) -> bool

Returns true if this is a successful termination.

Source

pub fn is_budget_exhausted(&self) -> bool

Returns true if this is a budget exhaustion.

Source

pub fn is_validation_failure(&self) -> bool

Returns true if this is a validation failure.

Source

pub fn is_error(&self) -> bool

Returns true if this is an error condition.

Source

pub fn is_hitl_pending(&self) -> bool

Returns true if convergence is paused at a HITL gate.

Source

pub fn is_human_intervention_required(&self) -> bool

Returns true if completion is blocked on human intervention.

Trait Implementations§

Source§

impl Clone for StopReason

Source§

fn clone(&self) -> StopReason

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for StopReason

Source§

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

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

impl<'de> Deserialize<'de> for StopReason

Source§

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

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

impl Display for StopReason

Source§

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

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

impl PartialEq for StopReason

Source§

fn eq(&self, other: &StopReason) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for StopReason

Source§

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

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for StopReason

Source§

impl StructuralPartialEq for StopReason

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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