From e4d114668c461bd2407cde6a154d0c67287c0ed5 Mon Sep 17 00:00:00 2001 From: TomuHirata Date: Fri, 3 Oct 2025 14:30:05 +0900 Subject: [PATCH] Document max_iters of ReAct --- docs/docs/learn/programming/tools.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/docs/learn/programming/tools.md b/docs/docs/learn/programming/tools.md index 2492ac56b8..3fa2f2a0b5 100644 --- a/docs/docs/learn/programming/tools.md +++ b/docs/docs/learn/programming/tools.md @@ -58,10 +58,17 @@ print("Tool calls made:", result.trajectory) react_agent = dspy.ReAct( signature="question -> answer", # Input/output specification tools=[tool1, tool2, tool3], # List of available tools - max_iters=10 # Maximum number of tool call iterations + max_iters=5 # Maximum number of reasoning-acting iterations (default: 10) ) ``` +**`max_iters`**: Controls the maximum number of reasoning and acting cycles the agent can perform. In each iteration, the model: +1. Reasons about the current state and what to do next +2. Decides whether to call a tool or provide a final answer +3. If calling a tool, executes it and observes the result + +The agent stops when it either reaches `max_iters` or decides it has enough information to answer. Higher values allow more tool calls but increase latency and cost. + ## Approach 2: Manual Tool Handling For more control over the tool calling process, you can manually handle tools using DSPy's tool types.