From ef0b93dc28f50a33dd036e016d8bb912cfccdd22 Mon Sep 17 00:00:00 2001 From: Owen Qwen Date: Sun, 21 Jun 2026 10:08:17 -0500 Subject: [PATCH] Removing max tool calls per turn --- PLAN.md | 6 +++--- src/agent.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/PLAN.md b/PLAN.md index 7a05648..a85e561 100644 --- a/PLAN.md +++ b/PLAN.md @@ -333,9 +333,9 @@ The agent loop should follow this flow: 4. Send context, system prompt, and allowed tools to the provider. 5. Stream assistant text blocks line by line to the UI and append the final assistant message when complete. 6. If the assistant emits tool calls, stream the tool call name and arguments to the UI, append the assistant tool-call message, execute each tool, stream each tool result under its call, append each result, and call the model again. -7. Continue until a final assistant message is produced or a max tool-iteration limit is reached. +7. Continue until a final assistant message is produced. -Use a conservative max tool-iteration limit, such as 8 per user turn, to prevent runaway loops. +Do not impose a fixed max tool-call or tool-iteration limit per user turn. If runaway behavior becomes a concern, address it with user cancellation or provider-level controls rather than an arbitrary per-turn cap. The agent should emit internal UI events rather than writing directly to the terminal. Example events: @@ -504,7 +504,7 @@ Implement `ls`, `read`, `grep`, `write`, and `edit` with strong validation and t ### Milestone 3: Provider and agent loop -Implement the provider abstraction, general OpenAI-compatible streaming provider with Fireworks defaults, message conversion, tool-call loop, max tool-iteration guard, context limiting, and system prompt generation. +Implement the provider abstraction, general OpenAI-compatible streaming provider with Fireworks defaults, message conversion, unbounded tool-call loop, context limiting, and system prompt generation. ### Milestone 4: Terminal UI diff --git a/src/agent.rs b/src/agent.rs index 569ce24..acb00f8 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -66,7 +66,7 @@ pub async fn run_turn( model_result_limit: settings.config.model_tool_result_limit, }; - for _ in 0..8 { + loop { let allowed = tools::available_tool_names(settings.mode); let system = prompt::build_effective_system_prompt( &conversation.base_system_prompt(),