fix: remove allow_multiple_tool_calls config and simplify tool execution flow
This fixes a bug where the agent would stop responding abruptly without calling final_output. The root cause was the allow_multiple_tool_calls config option (default: false) which caused the agent to break out of the streaming loop mid-stream after executing the first tool, losing any subsequent content. Changes: - Remove allow_multiple_tool_calls config option entirely - Always process all tool calls without breaking mid-stream - Simplify system prompt generation (no longer needs boolean param) - Let the stream complete fully before continuing to next iteration - Change find_last_tool_call_start to find_first_tool_call_start - Remove parser.reset() call on duplicate detection Benefits: - Simpler logic with less conditional branching - No lost content after tool calls - Consistent behavior for all users - Reduced config complexity
This commit is contained in:
@@ -94,7 +94,6 @@ pub struct AgentConfig {
|
||||
pub max_context_length: Option<u32>,
|
||||
pub fallback_default_max_tokens: usize,
|
||||
pub enable_streaming: bool,
|
||||
pub allow_multiple_tool_calls: bool,
|
||||
pub timeout_seconds: u64,
|
||||
pub auto_compact: bool,
|
||||
pub max_retry_attempts: u32,
|
||||
@@ -191,7 +190,6 @@ impl Default for Config {
|
||||
max_context_length: None,
|
||||
fallback_default_max_tokens: 8192,
|
||||
enable_streaming: true,
|
||||
allow_multiple_tool_calls: false,
|
||||
timeout_seconds: 60,
|
||||
auto_compact: true,
|
||||
max_retry_attempts: 3,
|
||||
|
||||
@@ -48,7 +48,6 @@ fallback_default_max_tokens = 8192
|
||||
enable_streaming = true
|
||||
timeout_seconds = 60
|
||||
auto_compact = true
|
||||
allow_multiple_tool_calls = false
|
||||
max_retry_attempts = 3
|
||||
autonomous_max_retry_attempts = 6
|
||||
{}"#, test_config_footer());
|
||||
@@ -93,7 +92,6 @@ fallback_default_max_tokens = 8192
|
||||
enable_streaming = true
|
||||
timeout_seconds = 60
|
||||
auto_compact = true
|
||||
allow_multiple_tool_calls = false
|
||||
max_retry_attempts = 3
|
||||
autonomous_max_retry_attempts = 6
|
||||
{}"#, test_config_footer());
|
||||
@@ -138,7 +136,6 @@ fallback_default_max_tokens = 8192
|
||||
enable_streaming = true
|
||||
timeout_seconds = 60
|
||||
auto_compact = true
|
||||
allow_multiple_tool_calls = false
|
||||
max_retry_attempts = 3
|
||||
autonomous_max_retry_attempts = 6
|
||||
{}"#, test_config_footer());
|
||||
@@ -176,7 +173,6 @@ fallback_default_max_tokens = 8192
|
||||
enable_streaming = true
|
||||
timeout_seconds = 60
|
||||
auto_compact = true
|
||||
allow_multiple_tool_calls = false
|
||||
max_retry_attempts = 3
|
||||
autonomous_max_retry_attempts = 6
|
||||
{}"#, test_config_footer());
|
||||
@@ -218,7 +214,6 @@ fallback_default_max_tokens = 8192
|
||||
enable_streaming = true
|
||||
timeout_seconds = 60
|
||||
auto_compact = true
|
||||
allow_multiple_tool_calls = false
|
||||
max_retry_attempts = 3
|
||||
autonomous_max_retry_attempts = 6
|
||||
{}"#, test_config_footer());
|
||||
@@ -257,7 +252,6 @@ fallback_default_max_tokens = 8192
|
||||
enable_streaming = true
|
||||
timeout_seconds = 60
|
||||
auto_compact = true
|
||||
allow_multiple_tool_calls = false
|
||||
max_retry_attempts = 3
|
||||
autonomous_max_retry_attempts = 6
|
||||
{}"#, test_config_footer());
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
#[cfg(test)]
|
||||
mod test_multiple_tool_calls {
|
||||
use g3_config::{AgentConfig, Config};
|
||||
|
||||
#[test]
|
||||
fn test_config_has_multiple_tool_calls_field() {
|
||||
let config = Config::default();
|
||||
|
||||
// Test that the field exists and defaults to false
|
||||
assert_eq!(config.agent.allow_multiple_tool_calls, false);
|
||||
|
||||
// Test that we can create a config with the field set to true
|
||||
let mut custom_config = Config::default();
|
||||
custom_config.agent.allow_multiple_tool_calls = true;
|
||||
assert_eq!(custom_config.agent.allow_multiple_tool_calls, true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_agent_config_serialization() {
|
||||
let agent_config = AgentConfig {
|
||||
max_context_length: Some(100000),
|
||||
fallback_default_max_tokens: 8192,
|
||||
enable_streaming: true,
|
||||
allow_multiple_tool_calls: true,
|
||||
timeout_seconds: 60,
|
||||
auto_compact: true,
|
||||
max_retry_attempts: 3,
|
||||
autonomous_max_retry_attempts: 6,
|
||||
check_todo_staleness: true,
|
||||
};
|
||||
|
||||
// Test serialization
|
||||
let json = serde_json::to_string(&agent_config).unwrap();
|
||||
assert!(json.contains("\"allow_multiple_tool_calls\":true"));
|
||||
|
||||
// Test deserialization
|
||||
let deserialized: AgentConfig = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(deserialized.allow_multiple_tool_calls, true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user