Skip to main content

base/event/
ends.rs

1//! How the things some events report on ended: a memory extraction, an ask,
2//! a host call.
3
4use serde::{Deserialize, Serialize};
5
6/// How a memory extraction ended (`AgentEvent::MemoryExtracted`).
7#[non_exhaustive]
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
9#[serde(rename_all = "snake_case")]
10pub enum ExtractionOutcome {
11    Saved,
12    /// The model found nothing worth keeping, or nothing it found was kept.
13    Empty,
14    Failed,
15    /// The session stopped before it finished.
16    Abandoned,
17}
18
19/// How an ask ended (`AgentEvent::PromptResolved`).
20#[non_exhaustive]
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
22#[serde(rename_all = "snake_case")]
23pub enum PromptResolution {
24    /// An answer reached the engine and was taken.
25    Answered,
26    /// The engine stopped waiting with no answer: the prompt timed out, the
27    /// turn asking it was cancelled or ended, or the session is closing.
28    Withdrawn,
29}
30
31/// Why the engine stopped waiting on an ask with no answer.
32#[non_exhaustive]
33#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
34#[serde(rename_all = "snake_case")]
35pub enum WithdrawalReason {
36    /// Nobody answered within the prompt timeout.
37    TimedOut,
38    /// The turn asking it was cancelled or ended, or the session is closing.
39    Cancelled,
40}
41
42/// Why the engine stopped waiting on a host call with no answer.
43#[non_exhaustive]
44#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
45#[serde(rename_all = "snake_case")]
46pub enum HostCallWithdrawal {
47    TimedOut,
48    Cancelled,
49    /// Nobody watched the session when the call was made.
50    NoHost,
51    /// Everyone watching the session went away before anyone answered.
52    HostGone,
53}
54
55impl From<WithdrawalReason> for HostCallWithdrawal {
56    fn from(reason: WithdrawalReason) -> Self {
57        match reason {
58            WithdrawalReason::TimedOut => Self::TimedOut,
59            WithdrawalReason::Cancelled => Self::Cancelled,
60        }
61    }
62}