Skip to main content

aether_core/events/
context_event.rs

1use super::CompactionId;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5use llm::{ContextUsage, MessageId};
6
7/// Terminal result of a context compaction operation.
8#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
9#[serde(tag = "status", rename_all = "snake_case")]
10pub enum CompactionOutcome {
11    Completed,
12    Failed { error: String },
13    Cancelled,
14}
15
16/// Context lifecycle events.
17///
18/// Compaction IDs are required in persisted and headless events. Logs without
19/// these IDs are not migrated or assigned identities during deserialization.
20#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
21#[serde(tag = "type", rename_all = "snake_case")]
22pub enum ContextEvent {
23    /// Context compaction has been triggered.
24    CompactionStarted { compaction_id: CompactionId, message_count: usize },
25    /// Context compaction reached a terminal state.
26    CompactionEnded { compaction_id: CompactionId, outcome: CompactionOutcome },
27    /// Context was compacted to reduce token usage.
28    CompactionResult { compaction_id: CompactionId, message_id: MessageId, summary: String, messages_removed: usize },
29    /// Context usage update for UI display.
30    UsageUpdated { usage: ContextUsage },
31    /// The agent context was cleared and reset to its blank state.
32    Cleared,
33}