aether_core/events/
turn_event.rs1use llm::{ContentBlock, LlmCallPurpose, ModelIdentity, 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)]
25pub struct RetryInfo {
26 pub attempt: u32,
27 pub max_attempts: u32,
28 pub delay_ms: u64,
29}
30
31#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
40#[serde(tag = "type", rename_all = "snake_case")]
41pub enum TurnEvent {
42 Started {
45 #[serde(default, skip_serializing_if = "Vec::is_empty")]
46 content: Vec<ContentBlock>,
47 },
48 RetryScheduled { purpose: LlmCallPurpose, attempt: u32, max_attempts: u32, delay_ms: u64 },
50 LlmCallStarted {
52 purpose: LlmCallPurpose,
53 model: ModelIdentity,
54 display_name: String,
55 attempt: u32,
57 max_attempts: u32,
58 },
59 LlmCallEnded { purpose: LlmCallPurpose, outcome: LlmCallOutcome },
61 AutoContinue { attempt: u32, max_attempts: u32 },
64 Ended { outcome: TurnOutcome },
66}
67
68impl TurnEvent {
69 pub fn retry_info(&self) -> Option<RetryInfo> {
70 match self {
71 Self::RetryScheduled { attempt, max_attempts, delay_ms, .. } => {
72 Some(RetryInfo { attempt: *attempt, max_attempts: *max_attempts, delay_ms: *delay_ms })
73 }
74 _ => None,
75 }
76 }
77}