diff --git a/config.example.yaml b/config.example.yaml index 754d63e..58512f4 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -79,7 +79,7 @@ enabled_mcp_servers: null # Which MCP servers to enable by default (e.g. # ---- Session ---- # See the [Session documentation](./docs/SESSIONS.md) for more information save_session: null # Controls the persistence of the session. If true, auto save; if false, don't auto-save save; if null, ask the user what to do -compress_threshold: 4000 # Compress the session when the token count reaches or exceeds this threshold +compression_threshold: 4000 # Compress the session when the token count reaches or exceeds this threshold summarize_prompt: > # The text prompt used for creating a concise summary of session message 'Summarize the discussion briefly in 200 words or less to use as a prompt for future context.' summary_prompt: > # The text prompt used for including the summary of the entire session as context to the model diff --git a/src/config/mod.rs b/src/config/mod.rs index ea21dfa..8365cfb 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -144,7 +144,7 @@ pub struct Config { pub agent_session: Option, pub save_session: Option, - pub compress_threshold: usize, + pub compression_threshold: usize, pub summarize_prompt: Option, pub summary_prompt: Option, @@ -230,7 +230,7 @@ impl Default for Config { agent_session: None, save_session: None, - compress_threshold: 4000, + compression_threshold: 4000, summarize_prompt: None, summary_prompt: None, @@ -710,7 +710,10 @@ impl Config { .unwrap_or_else(|| "null".into()), ), ("save_session", format_option_value(&self.save_session)), - ("compress_threshold", self.compress_threshold.to_string()), + ( + "compression_threshold", + self.compression_threshold.to_string(), + ), ( "rag_reranker_model", format_option_value(&rag_reranker_model), @@ -829,9 +832,9 @@ impl Config { let value = parse_value(value)?; config.write().set_save_session(value); } - "compress_threshold" => { + "compression_threshold" => { let value = parse_value(value)?; - config.write().set_compress_threshold(value); + config.write().set_compression_threshold(value); } "rag_reranker_model" => { let value = parse_value(value)?; @@ -1000,11 +1003,11 @@ impl Config { } } - pub fn set_compress_threshold(&mut self, value: Option) { + pub fn set_compression_threshold(&mut self, value: Option) { if let Some(session) = self.session.as_mut() { - session.set_compress_threshold(value); + session.set_compression_threshold(value); } else { - self.compress_threshold = value.unwrap_or_default(); + self.compression_threshold = value.unwrap_or_default(); } } @@ -1513,18 +1516,18 @@ impl Config { } pub fn maybe_compress_session(config: GlobalConfig) { - let mut need_compress = false; + let mut needs_compression = false; { let mut config = config.write(); - let compress_threshold = config.compress_threshold; + let compression_threshold = config.compression_threshold; if let Some(session) = config.session.as_mut() { - if session.need_compress(compress_threshold) { + if session.needs_compression(compression_threshold) { session.set_compressing(true); - need_compress = true; + needs_compression = true; } } }; - if !need_compress { + if !needs_compression { return; } let color = if config.read().light_theme() { @@ -2200,7 +2203,7 @@ impl Config { "enabled_tools", "enabled_mcp_servers", "save_session", - "compress_threshold", + "compression_threshold", "rag_reranker_model", "rag_top_k", "max_output_tokens", @@ -2773,8 +2776,8 @@ impl Config { if let Some(v) = read_env_bool(&get_env_name("save_session")) { self.save_session = v; } - if let Some(Some(v)) = read_env_value::(&get_env_name("compress_threshold")) { - self.compress_threshold = v; + if let Some(Some(v)) = read_env_value::(&get_env_name("compression_threshold")) { + self.compression_threshold = v; } if let Some(v) = read_env_value::(&get_env_name("summarize_prompt")) { self.summarize_prompt = v; diff --git a/src/config/session.rs b/src/config/session.rs index dd88542..ec53999 100644 --- a/src/config/session.rs +++ b/src/config/session.rs @@ -31,7 +31,7 @@ pub struct Session { #[serde(skip_serializing_if = "Option::is_none")] save_session: Option, #[serde(skip_serializing_if = "Option::is_none")] - compress_threshold: Option, + compression_threshold: Option, #[serde(skip_serializing_if = "Option::is_none")] role_name: Option, @@ -216,8 +216,8 @@ impl Session { items.push(("save_session", save_session.to_string())); } - if let Some(compress_threshold) = self.compress_threshold { - items.push(("compress_threshold", compress_threshold.to_string())); + if let Some(compression_threshold) = self.compression_threshold { + items.push(("compression_threshold", compression_threshold.to_string())); } if let Some(max_input_tokens) = self.model().max_input_tokens() { @@ -320,18 +320,20 @@ impl Session { self.save_session_this_time = true; } - pub fn set_compress_threshold(&mut self, value: Option) { - if self.compress_threshold != value { - self.compress_threshold = value; + pub fn set_compression_threshold(&mut self, value: Option) { + if self.compression_threshold != value { + self.compression_threshold = value; self.dirty = true; } } - pub fn need_compress(&self, global_compress_threshold: usize) -> bool { + pub fn needs_compression(&self, global_compression_threshold: usize) -> bool { if self.compressing { return false; } - let threshold = self.compress_threshold.unwrap_or(global_compress_threshold); + let threshold = self + .compression_threshold + .unwrap_or(global_compression_threshold); if threshold < 1 { return false; }