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:
Dhanji R. Prasanna
2026-01-09 13:28:07 +11:00
parent a72d5a650a
commit 67be0f20c7
11 changed files with 317 additions and 116 deletions

View File

@@ -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,

View File

@@ -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());