aether_core/events/
turn_event.rs1use llm::{ContentBlock, StopReason, TokenUsage};
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
7#[serde(tag = "status", rename_all = "snake_case")]
8pub enum TurnOutcome {
9 Completed,
10 Cancelled,
11 Failed { error: String },
12}
13
14#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
16#[serde(tag = "status", rename_all = "snake_case")]
17pub enum LlmCallOutcome {
18 Completed { stop_reason: Option<StopReason>, usage: Option<TokenUsage> },
19 Failed { error: String, will_retry: bool },
20 Cancelled,
21}
22
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
25#[serde(rename_all = "snake_case")]
26pub enum LlmCallPurpose {
27 Chat,
28 Compaction,
29}
30
31#[derive(Debug, Clone, Copy, PartialEq, Eq)]
33pub struct RetryInfo {
34 pub attempt: u32,
35 pub max_attempts: u32,
36 pub delay_ms: u64,
37}
38
39#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
48#[serde(tag = "type", rename_all = "snake_case")]
49pub enum TurnEvent {
50 Started {
53 #[serde(default, skip_serializing_if = "Vec::is_empty")]
54 content: Vec<ContentBlock>,
55 },
56 RetryScheduled { purpose: LlmCallPurpose, attempt: u32, max_attempts: u32, delay_ms: u64 },
58 LlmCallStarted {
60 purpose: LlmCallPurpose,
61 provider: Option<String>,
62 model: Option<String>,
63 display_name: String,
64 attempt: u32,
66 max_attempts: u32,
67 },
68 LlmCallEnded { purpose: LlmCallPurpose, outcome: LlmCallOutcome },
70 AutoContinue { attempt: u32, max_attempts: u32 },
73 Ended { outcome: TurnOutcome },
75}
76
77impl TurnEvent {
78 pub fn retry_info(&self) -> Option<RetryInfo> {
79 match self {
80 Self::RetryScheduled { attempt, max_attempts, delay_ms, .. } => {
81 Some(RetryInfo { attempt: *attempt, max_attempts: *max_attempts, delay_ms: *delay_ms })
82 }
83 _ => None,
84 }
85 }
86}