pub enum AgentState {
Idle,
Gathering {
scope_id: ScopeId,
},
Planning {
scope_id: ScopeId,
},
Executing {
scope_id: ScopeId,
tool_call_id: String,
},
Waiting {
for_event_type: String,
},
Delegating {
to: AgentId,
delegation_id: DelegationId,
},
Complete {
scope_id: ScopeId,
},
Failed {
scope_id: ScopeId,
error: String,
},
}Expand description
Agent state derived from event history (NOT stored in DB)
Variants§
Implementations§
Source§impl AgentState
impl AgentState
Sourcepub fn from_events(events: &[Event<Value>]) -> Self
pub fn from_events(events: &[Event<Value>]) -> Self
Derive agent state from event history by scanning in chronological order. Handles SCOPE_CREATED/SCOPE_CLOSED, DELEGATION_*, and AGENT_STATUS_CHANGED.
AGENT_STATUS_CHANGED events carry a "status" field in their payload.
Recognised values: "executing", "waiting", "failed", "idle".
This prevents silent state divergence when an agent crashes mid-execution
and an explicit status change event is emitted.
Sourcepub fn can_transition_to(&self, target: &AgentState) -> bool
pub fn can_transition_to(&self, target: &AgentState) -> bool
Check if a transition from current state to target state is valid. Valid transitions per the state machine:
- Idle -> Gathering, Delegating
- Gathering -> Planning, Failed
- Planning -> Executing, Failed
- Executing -> Waiting, Complete, Failed
- Waiting -> Executing, Failed
- Delegating -> Idle, Failed
- Complete -> Idle
- Failed -> Idle
Sourcepub fn valid_transitions(&self) -> Vec<AgentState>
pub fn valid_transitions(&self) -> Vec<AgentState>
Return a vector of states reachable from the current state. Uses placeholder data where necessary (scope_id preserved when available).
Trait Implementations§
Source§impl Clone for AgentState
impl Clone for AgentState
Source§fn clone(&self) -> AgentState
fn clone(&self) -> AgentState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AgentState
impl Debug for AgentState
Source§impl<'de> Deserialize<'de> for AgentState
impl<'de> Deserialize<'de> for AgentState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 PartialEq for AgentState
impl PartialEq for AgentState
Source§impl Serialize for AgentState
impl Serialize for AgentState
impl Eq for AgentState
impl StructuralPartialEq for AgentState
Auto Trait Implementations§
impl Freeze for AgentState
impl RefUnwindSafe for AgentState
impl Send for AgentState
impl Sync for AgentState
impl Unpin for AgentState
impl UnwindSafe for AgentState
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.