pub enum SessionStatus {
Created,
Running,
Cancelled,
Finished,
Failed,
DeadlineExceeded,
TurnCapExceeded,
}Expand description
Lifecycle status of a Session.
Why: a small, closed set of states the registry can transition between
and that a client can match on reliably (the wire string is stable —
#[serde(rename_all = "snake_case")] — independent of Rust variant
naming).
What: Created -> Running happens immediately on session.create in
M1 (there is no queue to sit in ahead of real task execution, which
lands with task.* in #2056). Cancelled/Finished/Failed/
DeadlineExceeded/TurnCapExceeded are the five terminal-per-call
states; session.cancel is the only one #2054 can drive directly
(Finished/Failed/DeadlineExceeded/TurnCapExceeded are set by
task::executor::run_and_record when the PM’s AgentLoop resolves).
DeadlineExceeded (#2207) is distinct from Failed: it means the run’s
configured wall-clock budget elapsed before the PM reached a terminal
state, NOT that the loop or LLM call errored — a run that hit this
status may have made real, useful progress. TurnCapExceeded (#3888) is
likewise distinct from Failed: it means this ONE task.run call
exhausted its AgentLoopConfig::max_turns budget, not that the session
itself failed — per epic #2343’s infinite-sessions goal, the PM
transcript is fully persisted and the session is resumable exactly like
Finished (see SessionRegistry::begin_execution’s resume condition).
Test: model::tests::session_status_serialises_snake_case.
Variants§
Created
Running
Cancelled
Finished
Failed
DeadlineExceeded
TurnCapExceeded
This call’s turn budget was exhausted — see the enum doc above (#3888).
Implementations§
Source§impl SessionStatus
impl SessionStatus
Sourcepub fn as_str(&self) -> &'static str
pub fn as_str(&self) -> &'static str
Return the stable wire string for this status (matches the serde
rename_all = "snake_case" representation).
Why: crate::events::Event::SessionStatusChanged’s status field is
a plain String, not a SessionStatus, so registry code needs the
wire string without round-tripping through serde_json.
What: a &'static str per variant.
Test: model::tests::as_str_matches_serde_rename.
Sourcepub fn is_terminal(&self) -> bool
pub fn is_terminal(&self) -> bool
Returns true when this status is terminal FOR THIS CALL (the
current task.run invocation will never transition again without a
fresh begin_execution).
Why: session.cancel and any future completion handler need to
reject transitions out of a terminal-per-call state (e.g. cancelling
an already-finished session is a no-op, not a silent overwrite). This
is deliberately WIDER than “can never resume” — see Self::is_resumable
for the narrower “dead forever” gate (#3888).
What: true for Cancelled/Finished/Failed/DeadlineExceeded/
TurnCapExceeded; false otherwise.
Test: model::tests::is_terminal_covers_terminal_states.
Sourcepub fn is_resumable(&self) -> bool
pub fn is_resumable(&self) -> bool
Returns true when a session at this status may accept another
task.run via SessionRegistry::begin_execution — the single
authoritative “still resumable” gate (#2344 Finished + #3888
TurnCapExceeded): both mean only THIS CALL ended, not the session,
and pm_transcript is fully persisted either way, so the next call
continues the same conversation. Cancelled/Failed/
DeadlineExceeded are the genuinely dead-forever states.
Test: model::tests::is_resumable_matches_finished_and_turn_cap_exceeded.
Trait Implementations§
Source§impl Clone for SessionStatus
impl Clone for SessionStatus
Source§fn clone(&self) -> SessionStatus
fn clone(&self) -> SessionStatus
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SessionStatus
Source§impl Debug for SessionStatus
impl Debug for SessionStatus
Source§impl<'de> Deserialize<'de> for SessionStatus
impl<'de> Deserialize<'de> for SessionStatus
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>,
impl Eq for SessionStatus
Source§impl PartialEq for SessionStatus
impl PartialEq for SessionStatus
Source§impl Serialize for SessionStatus
impl Serialize for SessionStatus
impl StructuralPartialEq for SessionStatus
Auto Trait Implementations§
impl Freeze for SessionStatus
impl RefUnwindSafe for SessionStatus
impl Send for SessionStatus
impl Sync for SessionStatus
impl Unpin for SessionStatus
impl UnsafeUnpin for SessionStatus
impl UnwindSafe for SessionStatus
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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