fix(agent): use config-driven limits in run_tool_call_loop and trim_history
run_tool_call_loop used a hardcoded MAX_TOOL_ITERATIONS (10) and trim_history/auto_compact_history used a hardcoded MAX_HISTORY_MESSAGES (50), ignoring the user-configurable agent.max_tool_iterations and agent.max_history_messages values in config.toml. Meanwhile, agent.rs correctly reads from config — creating an inconsistency where CLI single-shot mode respected config but the channel runtime and interactive CLI loop silently ignored it. Changes: - Rename constants to DEFAULT_* to clarify they are fallback defaults - Add max_tool_iterations parameter to run_tool_call_loop - Add max_history parameter to trim_history and auto_compact_history - Thread config.agent.max_tool_iterations through ChannelRuntimeContext - Both CLI code paths now pass config values to run_tool_call_loop Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1c074d5204
commit
63602a262f
2 changed files with 53 additions and 30 deletions
|
|
@ -71,6 +71,7 @@ struct ChannelRuntimeContext {
|
|||
model: Arc<String>,
|
||||
temperature: f64,
|
||||
auto_save_memory: bool,
|
||||
max_tool_iterations: usize,
|
||||
}
|
||||
|
||||
fn conversation_memory_key(msg: &traits::ChannelMessage) -> String {
|
||||
|
|
@ -219,6 +220,7 @@ async fn process_channel_message(ctx: Arc<ChannelRuntimeContext>, msg: traits::C
|
|||
true, // silent — channels don't write to stdout
|
||||
None,
|
||||
msg.channel.as_str(),
|
||||
ctx.max_tool_iterations,
|
||||
),
|
||||
)
|
||||
.await;
|
||||
|
|
@ -1271,6 +1273,7 @@ pub async fn start_channels(config: Config) -> Result<()> {
|
|||
model: Arc::new(model.clone()),
|
||||
temperature,
|
||||
auto_save_memory: config.memory.auto_save,
|
||||
max_tool_iterations: config.agent.max_tool_iterations,
|
||||
});
|
||||
|
||||
run_message_dispatch_loop(rx, runtime_ctx, max_in_flight_messages).await;
|
||||
|
|
@ -1495,6 +1498,7 @@ mod tests {
|
|||
model: Arc::new("test-model".to_string()),
|
||||
temperature: 0.0,
|
||||
auto_save_memory: false,
|
||||
max_tool_iterations: 10,
|
||||
});
|
||||
|
||||
process_channel_message(
|
||||
|
|
@ -1536,6 +1540,7 @@ mod tests {
|
|||
model: Arc::new("test-model".to_string()),
|
||||
temperature: 0.0,
|
||||
auto_save_memory: false,
|
||||
max_tool_iterations: 10,
|
||||
});
|
||||
|
||||
process_channel_message(
|
||||
|
|
@ -1631,6 +1636,7 @@ mod tests {
|
|||
model: Arc::new("test-model".to_string()),
|
||||
temperature: 0.0,
|
||||
auto_save_memory: false,
|
||||
max_tool_iterations: 10,
|
||||
});
|
||||
|
||||
let (tx, rx) = tokio::sync::mpsc::channel::<traits::ChannelMessage>(4);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue