From d169d792885d07ba674d8f2c1bcc7be7f08d556b Mon Sep 17 00:00:00 2001 From: xianghuijin Date: Thu, 20 Mar 2025 21:49:38 +0800 Subject: [PATCH] Update documentation for tool_choice auto-reset feature --- docs/agents.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/agents.md b/docs/agents.md index 1c31473..c9c39ae 100644 --- a/docs/agents.md +++ b/docs/agents.md @@ -142,4 +142,6 @@ Supplying a list of tools doesn't always mean the LLM will use a tool. You can f !!! note - If requiring tool use, you should consider setting [`Agent.tool_use_behavior`] to stop the Agent from running when a tool output is produced. Otherwise, the Agent might run in an infinite loop, where the LLM produces a tool call , and the tool result is sent to the LLM, and this infinite loops because the LLM is always forced to use a tool. + To prevent infinite loops, the framework automatically resets `tool_choice` to "auto" after a tool call when it's set to "required" or a specific function name. This allows the model to decide whether to make additional tool calls in subsequent turns. + + If you want the Agent to completely stop after a tool call (rather than continuing with auto mode), you can set [`Agent.tool_use_behavior="stop_on_first_tool"`] which will directly use the tool output as the final response without further LLM processing.