Skip to main content

lean_ctx/core/config/
response_shaping.rs

1//! Configuration for proxy response shaping (#1125).
2
3use serde::{Deserialize, Serialize};
4
5/// Response-shaping configuration (`[response_shaping]`).
6///
7/// The proxy applies the patterns of the selected `mode`. The former
8/// `preamble`, `code_repetition`, `narration` and `confirmation` sub-sections
9/// were never read; they are retired and ignored when an older config loads.
10#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
11#[serde(default)]
12pub struct ResponseShapingConfig {
13    /// Enable proxy response shaping. Defaults to the conservative gentle mode.
14    pub enabled: bool,
15    /// `off`, `gentle`, or `aggressive`.
16    pub mode: String,
17}
18
19impl Default for ResponseShapingConfig {
20    fn default() -> Self {
21        Self {
22            enabled: true,
23            mode: "gentle".into(),
24        }
25    }
26}
27
28#[cfg(test)]
29mod tests {
30    use super::*;
31
32    #[test]
33    fn retired_sub_sections_still_load() {
34        let cfg: ResponseShapingConfig = toml::from_str(
35            r#"
36            enabled = true
37            mode = "aggressive"
38            [preamble]
39            max_pattern_length = 42
40            [code_repetition]
41            enabled = true
42            [narration]
43            max_summary_tokens = 24
44            [confirmation]
45            strip_trailing = false
46            "#,
47        )
48        .expect("response-shaping TOML");
49        assert_eq!(cfg.mode, "aggressive");
50        assert!(cfg.enabled);
51    }
52}