fix(rebase): unify agent config and remove duplicate fields

This commit is contained in:
Chummy 2026-02-17 00:56:06 +08:00
parent 413ecfd143
commit e005b6d9e4
2 changed files with 7 additions and 26 deletions

View file

@ -80,10 +80,6 @@ pub struct Config {
#[serde(default)] #[serde(default)]
pub peripherals: PeripheralsConfig, pub peripherals: PeripheralsConfig,
/// Agent context limits — use compact for smaller models (e.g. 13B with 4k8k context).
#[serde(default)]
pub agent: AgentConfig,
/// Delegate agent configurations for multi-agent workflows. /// Delegate agent configurations for multi-agent workflows.
#[serde(default)] #[serde(default)]
pub agents: HashMap<String, DelegateAgentConfig>, pub agents: HashMap<String, DelegateAgentConfig>,
@ -93,23 +89,6 @@ pub struct Config {
pub hardware: HardwareConfig, pub hardware: HardwareConfig,
} }
// ── Agent (context limits for smaller models) ────────────────────
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentConfig {
/// When true: bootstrap_max_chars=6000, rag_chunk_limit=2. Use for 13B or smaller models.
#[serde(default)]
pub compact_context: bool,
}
impl Default for AgentConfig {
fn default() -> Self {
Self {
compact_context: false,
}
}
}
// ── Delegate Agents ────────────────────────────────────────────── // ── Delegate Agents ──────────────────────────────────────────────
/// Configuration for a delegate sub-agent used by the `delegate` tool. /// Configuration for a delegate sub-agent used by the `delegate` tool.
@ -214,6 +193,9 @@ impl Default for HardwareConfig {
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentConfig { pub struct AgentConfig {
/// When true: bootstrap_max_chars=6000, rag_chunk_limit=2. Use for 13B or smaller models.
#[serde(default)]
pub compact_context: bool,
#[serde(default = "default_agent_max_tool_iterations")] #[serde(default = "default_agent_max_tool_iterations")]
pub max_tool_iterations: usize, pub max_tool_iterations: usize,
#[serde(default = "default_agent_max_history_messages")] #[serde(default = "default_agent_max_history_messages")]
@ -239,6 +221,7 @@ fn default_agent_tool_dispatcher() -> String {
impl Default for AgentConfig { impl Default for AgentConfig {
fn default() -> Self { fn default() -> Self {
Self { Self {
compact_context: false,
max_tool_iterations: default_agent_max_tool_iterations(), max_tool_iterations: default_agent_max_tool_iterations(),
max_history_messages: default_agent_max_history_messages(), max_history_messages: default_agent_max_history_messages(),
parallel_tools: false, parallel_tools: false,
@ -1559,7 +1542,6 @@ impl Default for Config {
identity: IdentityConfig::default(), identity: IdentityConfig::default(),
cost: CostConfig::default(), cost: CostConfig::default(),
peripherals: PeripheralsConfig::default(), peripherals: PeripheralsConfig::default(),
agent: AgentConfig::default(),
agents: HashMap::new(), agents: HashMap::new(),
hardware: HardwareConfig::default(), hardware: HardwareConfig::default(),
} }
@ -1916,7 +1898,6 @@ mod tests {
identity: IdentityConfig::default(), identity: IdentityConfig::default(),
cost: CostConfig::default(), cost: CostConfig::default(),
peripherals: PeripheralsConfig::default(), peripherals: PeripheralsConfig::default(),
agent: AgentConfig::default(),
agents: HashMap::new(), agents: HashMap::new(),
hardware: HardwareConfig::default(), hardware: HardwareConfig::default(),
}; };
@ -1965,6 +1946,7 @@ default_temperature = 0.7
#[test] #[test]
fn agent_config_defaults() { fn agent_config_defaults() {
let cfg = AgentConfig::default(); let cfg = AgentConfig::default();
assert!(!cfg.compact_context);
assert_eq!(cfg.max_tool_iterations, 10); assert_eq!(cfg.max_tool_iterations, 10);
assert_eq!(cfg.max_history_messages, 50); assert_eq!(cfg.max_history_messages, 50);
assert!(!cfg.parallel_tools); assert!(!cfg.parallel_tools);
@ -1976,12 +1958,14 @@ default_temperature = 0.7
let raw = r#" let raw = r#"
default_temperature = 0.7 default_temperature = 0.7
[agent] [agent]
compact_context = true
max_tool_iterations = 20 max_tool_iterations = 20
max_history_messages = 80 max_history_messages = 80
parallel_tools = true parallel_tools = true
tool_dispatcher = "xml" tool_dispatcher = "xml"
"#; "#;
let parsed: Config = toml::from_str(raw).unwrap(); let parsed: Config = toml::from_str(raw).unwrap();
assert!(parsed.agent.compact_context);
assert_eq!(parsed.agent.max_tool_iterations, 20); assert_eq!(parsed.agent.max_tool_iterations, 20);
assert_eq!(parsed.agent.max_history_messages, 80); assert_eq!(parsed.agent.max_history_messages, 80);
assert!(parsed.agent.parallel_tools); assert!(parsed.agent.parallel_tools);
@ -2021,7 +2005,6 @@ tool_dispatcher = "xml"
identity: IdentityConfig::default(), identity: IdentityConfig::default(),
cost: CostConfig::default(), cost: CostConfig::default(),
peripherals: PeripheralsConfig::default(), peripherals: PeripheralsConfig::default(),
agent: AgentConfig::default(),
agents: HashMap::new(), agents: HashMap::new(),
hardware: HardwareConfig::default(), hardware: HardwareConfig::default(),
}; };

View file

@ -128,7 +128,6 @@ pub fn run_wizard() -> Result<Config> {
identity: crate::config::IdentityConfig::default(), identity: crate::config::IdentityConfig::default(),
cost: crate::config::CostConfig::default(), cost: crate::config::CostConfig::default(),
peripherals: crate::config::PeripheralsConfig::default(), peripherals: crate::config::PeripheralsConfig::default(),
agent: crate::config::AgentConfig::default(),
agents: std::collections::HashMap::new(), agents: std::collections::HashMap::new(),
hardware: hardware_config, hardware: hardware_config,
}; };
@ -333,7 +332,6 @@ pub fn run_quick_setup(
identity: crate::config::IdentityConfig::default(), identity: crate::config::IdentityConfig::default(),
cost: crate::config::CostConfig::default(), cost: crate::config::CostConfig::default(),
peripherals: crate::config::PeripheralsConfig::default(), peripherals: crate::config::PeripheralsConfig::default(),
agent: crate::config::AgentConfig::default(),
agents: std::collections::HashMap::new(), agents: std::collections::HashMap::new(),
hardware: crate::config::HardwareConfig::default(), hardware: crate::config::HardwareConfig::default(),
}; };