Skip to main content

awaken_runtime/policies/
state.rs

1use serde::{Deserialize, Serialize};
2
3/// Persistent stats used by stop-condition policies across phase boundaries.
4#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
5pub struct StopConditionStatsState {
6    pub(super) step_count: u32,
7    pub(super) total_input_tokens: u64,
8    pub(super) total_output_tokens: u64,
9    pub(super) start_time_ms: u64,
10    pub(super) consecutive_errors: u32,
11}
12
13pub struct StopConditionStatsKey;
14
15impl crate::state::StateKey for StopConditionStatsKey {
16    const KEY: &'static str = "__runtime.stop_condition_stats";
17    type Value = StopConditionStatsState;
18    type Update = StopConditionStatsState;
19
20    fn apply(value: &mut Self::Value, update: Self::Update) {
21        *value = update;
22    }
23}