#[non_exhaustive]pub enum StopReason {
Show 13 variants
Converged,
CriteriaMet {
criteria: Vec<String>,
},
UserCancelled,
HumanInterventionRequired {
criteria: Vec<String>,
approval_refs: Vec<String>,
},
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: String,
reason: String,
},
Error {
message: String,
category: ErrorCategory,
},
AgentRefused {
agent_id: String,
reason: String,
},
HitlGatePending {
gate_id: String,
proposal_id: String,
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
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.
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
CycleBudgetExhausted
Maximum execution cycles exceeded. May indicate non-converging problem or need for larger budget.
FactBudgetExhausted
Maximum facts in context exceeded. Prevents unbounded context growth.
TokenBudgetExhausted
Maximum LLM tokens exceeded. Cost control for LLM-based operations.
TimeBudgetExhausted
Maximum wall-clock time exceeded. Prevents indefinite execution.
Fields
InvariantViolated
An invariant was violated. Includes the class (Structural/Semantic/Acceptance) and invariant name.
Fields
class: InvariantClassWhich class of invariant
PromotionRejected
Promotion gate rejected a proposal. Proposal failed validation and could not be promoted.
Error
Unrecoverable error during execution. Something went wrong that couldn’t be handled.
Fields
category: ErrorCategoryError category for programmatic handling
AgentRefused
An agent refused to continue. Suggestor explicitly declined to produce output.
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.
Implementations§
Source§impl StopReason
impl StopReason
Sourcepub fn converged() -> StopReason
pub fn converged() -> StopReason
Create a Converged stop reason.
Sourcepub fn criteria_met(criteria: Vec<String>) -> StopReason
pub fn criteria_met(criteria: Vec<String>) -> StopReason
Create a CriteriaMet stop reason.
Sourcepub fn user_cancelled() -> StopReason
pub fn user_cancelled() -> StopReason
Create a UserCancelled stop reason.
Sourcepub fn human_intervention_required(
criteria: Vec<String>,
approval_refs: Vec<String>,
) -> StopReason
pub fn human_intervention_required( criteria: Vec<String>, approval_refs: Vec<String>, ) -> StopReason
Create a HumanInterventionRequired stop reason.
Sourcepub fn cycle_budget_exhausted(cycles_executed: u32, limit: u32) -> StopReason
pub fn cycle_budget_exhausted(cycles_executed: u32, limit: u32) -> StopReason
Create a CycleBudgetExhausted stop reason.
Sourcepub fn fact_budget_exhausted(facts_count: u32, limit: u32) -> StopReason
pub fn fact_budget_exhausted(facts_count: u32, limit: u32) -> StopReason
Create a FactBudgetExhausted stop reason.
Sourcepub fn token_budget_exhausted(tokens_consumed: u64, limit: u64) -> StopReason
pub fn token_budget_exhausted(tokens_consumed: u64, limit: u64) -> StopReason
Create a TokenBudgetExhausted stop reason.
Sourcepub fn time_budget_exhausted(duration_ms: u64, limit_ms: u64) -> StopReason
pub fn time_budget_exhausted(duration_ms: u64, limit_ms: u64) -> StopReason
Create a TimeBudgetExhausted stop reason.
Sourcepub fn invariant_violated(
class: InvariantClass,
name: impl Into<String>,
reason: impl Into<String>,
) -> StopReason
pub fn invariant_violated( class: InvariantClass, name: impl Into<String>, reason: impl Into<String>, ) -> StopReason
Create an InvariantViolated stop reason.
Sourcepub fn promotion_rejected(
proposal_id: impl Into<String>,
reason: impl Into<String>,
) -> StopReason
pub fn promotion_rejected( proposal_id: impl Into<String>, reason: impl Into<String>, ) -> StopReason
Create a PromotionRejected stop reason.
Sourcepub fn error(message: impl Into<String>, category: ErrorCategory) -> StopReason
pub fn error(message: impl Into<String>, category: ErrorCategory) -> StopReason
Create an Error stop reason.
Sourcepub fn agent_refused(
agent_id: impl Into<String>,
reason: impl Into<String>,
) -> StopReason
pub fn agent_refused( agent_id: impl Into<String>, reason: impl Into<String>, ) -> StopReason
Create an AgentRefused stop reason.
Sourcepub fn hitl_gate_pending(
gate_id: impl Into<String>,
proposal_id: impl Into<String>,
summary: impl Into<String>,
agent_id: impl Into<String>,
cycle: u32,
) -> StopReason
pub fn hitl_gate_pending( gate_id: impl Into<String>, proposal_id: impl Into<String>, summary: impl Into<String>, agent_id: impl Into<String>, cycle: u32, ) -> StopReason
Create a HitlGatePending stop reason.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Returns true if this is a successful termination.
Sourcepub fn is_budget_exhausted(&self) -> bool
pub fn is_budget_exhausted(&self) -> bool
Returns true if this is a budget exhaustion.
Sourcepub fn is_validation_failure(&self) -> bool
pub fn is_validation_failure(&self) -> bool
Returns true if this is a validation failure.
Sourcepub fn is_hitl_pending(&self) -> bool
pub fn is_hitl_pending(&self) -> bool
Returns true if convergence is paused at a HITL gate.
Sourcepub fn is_human_intervention_required(&self) -> bool
pub fn is_human_intervention_required(&self) -> bool
Returns true if completion is blocked on human intervention.
Trait Implementations§
Source§impl Clone for StopReason
impl Clone for StopReason
Source§fn clone(&self) -> StopReason
fn clone(&self) -> StopReason
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StopReason
impl Debug for StopReason
Source§impl<'de> Deserialize<'de> for StopReason
impl<'de> Deserialize<'de> for StopReason
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<StopReason, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<StopReason, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for StopReason
impl Display for StopReason
Source§impl PartialEq for StopReason
impl PartialEq for StopReason
Source§impl Serialize for StopReason
impl Serialize for StopReason
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for StopReason
impl StructuralPartialEq for StopReason
Auto Trait Implementations§
impl Freeze for StopReason
impl RefUnwindSafe for StopReason
impl Send for StopReason
impl Sync for StopReason
impl Unpin for StopReason
impl UnsafeUnpin for StopReason
impl UnwindSafe for StopReason
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.