From faacbc1570d5870d043d8305416c0e0817e8c6d4 Mon Sep 17 00:00:00 2001 From: Mohammad Mohtashim <45242107+keenborder786@users.noreply.github.com> Date: Tue, 9 Sep 2025 20:07:07 +0500 Subject: [PATCH] docs(prebuilt): remaining_steps explanation added in `create_react_agent` (#5847) - **Description:** A better explanation of `remaining_steps` to clarify what it does. - **Issue:** #5548 --- libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py b/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py index 8256bbc44..13d2ec6a4 100644 --- a/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py +++ b/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py @@ -390,6 +390,14 @@ def create_react_agent( state_schema: An optional state schema that defines graph state. Must have `messages` and `remaining_steps` keys. Defaults to `AgentState` that defines those two keys. + !!! Note + `remaining_steps` is used to limit the number of steps the react agent can take. + Calculated roughly as `recursion_limit` - `total_steps_taken`. + If `remaining_steps` is less than 2 and tool calls are present in the response, + the react agent will return a final AI Message with + the content "Sorry, need more steps to process this request.". + No `GraphRecusionError` will be raised in this case. + context_schema: An optional schema for runtime context. checkpointer: An optional checkpoint saver object. This is used for persisting the state of the graph (e.g., as chat memory) for a single thread (e.g., a single conversation).