ai_agent/services/compact/
time_based_mc_config.rs1#[derive(Debug, Clone)]
9pub struct TimeBasedMCConfig {
10 pub enabled: bool,
12 pub gap_threshold_minutes: u64,
14 pub keep_recent: usize,
16}
17
18impl Default for TimeBasedMCConfig {
19 fn default() -> Self {
20 Self {
21 enabled: true,
22 gap_threshold_minutes: 60,
23 keep_recent: 5,
24 }
25 }
26}
27
28pub fn get_time_based_mc_config() -> TimeBasedMCConfig {
31 let mut config = TimeBasedMCConfig::default();
32
33 if let Ok(val) = std::env::var("AI_MC_GAP_THRESHOLD_MINUTES") {
35 if let Ok(parsed) = val.parse::<u64>() {
36 if parsed > 0 {
37 config.gap_threshold_minutes = parsed;
38 }
39 }
40 }
41
42 if let Ok(val) = std::env::var("AI_MC_KEEP_RECENT") {
44 if let Ok(parsed) = val.parse::<usize>() {
45 if parsed > 0 {
46 config.keep_recent = parsed;
47 }
48 }
49 }
50
51 config
52}
53
54#[cfg(test)]
55mod tests {
56 use super::*;
57
58 #[test]
59 fn test_default_config() {
60 let config = TimeBasedMCConfig::default();
61 assert!(config.enabled);
62 assert_eq!(config.gap_threshold_minutes, 60);
63 assert_eq!(config.keep_recent, 5);
64 }
65
66 #[test]
67 fn test_get_time_based_mc_config() {
68 let config = get_time_based_mc_config();
69 assert!(config.enabled);
70 assert!(config.gap_threshold_minutes > 0);
71 assert!(config.keep_recent > 0);
72 }
73}