agix-base 0.5.0

Agix — foundation types, traits, and context
Documentation
//! How the things some events report on ended: a memory extraction, an ask,
//! a host call.

use serde::{Deserialize, Serialize};

/// How a memory extraction ended (`AgentEvent::MemoryExtracted`).
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExtractionOutcome {
    Saved,
    /// The model found nothing worth keeping, or nothing it found was kept.
    Empty,
    Failed,
    /// The session stopped before it finished.
    Abandoned,
}

/// How an ask ended (`AgentEvent::PromptResolved`).
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum PromptResolution {
    /// An answer reached the engine and was taken.
    Answered,
    /// The engine stopped waiting with no answer: the prompt timed out, the
    /// turn asking it was cancelled or ended, or the session is closing.
    Withdrawn,
}

/// Why the engine stopped waiting on an ask with no answer.
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum WithdrawalReason {
    /// Nobody answered within the prompt timeout.
    TimedOut,
    /// The turn asking it was cancelled or ended, or the session is closing.
    Cancelled,
}

/// Why the engine stopped waiting on a host call with no answer.
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HostCallWithdrawal {
    TimedOut,
    Cancelled,
    /// Nobody watched the session when the call was made.
    NoHost,
    /// Everyone watching the session went away before anyone answered.
    HostGone,
}

impl From<WithdrawalReason> for HostCallWithdrawal {
    fn from(reason: WithdrawalReason) -> Self {
        match reason {
            WithdrawalReason::TimedOut => Self::TimedOut,
            WithdrawalReason::Cancelled => Self::Cancelled,
        }
    }
}