base/event/compact.rs
1//! 压缩首尾两帧(`CompactStarted` / `CompactEnded`)上的两个取值:为什么压、为什么没压成。
2
3use serde::{Deserialize, Serialize};
4
5/// What set a compaction off (`AgentEvent::CompactStarted`).
6#[non_exhaustive]
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
8#[serde(rename_all = "snake_case")]
9pub enum CompactCause {
10 /// The context crossed the compaction threshold.
11 Threshold,
12 /// `/compact` or `session.compact`.
13 Manual,
14 /// The provider refused a request for its size; it is sent again after.
15 Overflow,
16}
17
18/// Why a compaction left the history as it was (`AgentEvent::CompactEnded`).
19#[non_exhaustive]
20#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
21#[serde(rename_all = "snake_case")]
22pub enum CompactOutcome {
23 /// A `PreCompact` hook declined it.
24 Declined,
25 NothingToCompact,
26 /// The compactor or the summary failed.
27 Failed,
28 /// The turn was interrupted while it ran.
29 Cancelled,
30}