mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-18 14:44:21 +01:00
feat: add tool repetition monitoring to prevent infinite loops (#2527)
This commit is contained in:
@@ -35,6 +35,8 @@ pub struct SessionBuilderConfig {
|
||||
pub additional_system_prompt: Option<String>,
|
||||
/// Enable debug printing
|
||||
pub debug: bool,
|
||||
/// Maximum number of consecutive identical tool calls allowed
|
||||
pub max_tool_repetitions: Option<u32>,
|
||||
}
|
||||
|
||||
pub async fn build_session(session_config: SessionBuilderConfig) -> Session {
|
||||
@@ -55,6 +57,11 @@ pub async fn build_session(session_config: SessionBuilderConfig) -> Session {
|
||||
let new_provider = create(&provider_name, model_config).unwrap();
|
||||
let _ = agent.update_provider(new_provider).await;
|
||||
|
||||
// Configure tool monitoring if max_tool_repetitions is set
|
||||
if let Some(max_repetitions) = session_config.max_tool_repetitions {
|
||||
agent.configure_tool_monitor(Some(max_repetitions)).await;
|
||||
}
|
||||
|
||||
// Handle session file resolution and resuming
|
||||
let session_file = if session_config.no_session {
|
||||
// Use a temporary path that won't be written to
|
||||
|
||||
Reference in New Issue
Block a user