langgraph.errors.GraphRecursionError ReAct agent keeps calling the save_memory tool repeatedly! #576

Closed
opened 2026-02-20 17:40:47 -05:00 by yindo · 0 comments
Owner

Originally created by @khteh on GitHub (Apr 10, 2025).

Checked other resources

  • This is a bug, not a usage question. For questions, please use GitHub Discussions.
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

The tool in question:

@tool
async def save_memory(memory: str, *, config: Annotated[RunnableConfig, InjectedToolArg], store: Annotated[BaseStore, InjectedStore()]) -> str:
    """
    Save the given memory for the current user.
    This should only be used after you have exhausted all other tools to accomplish your task. After saving the memory for the current user, you should return to the user with your answer.
    """
    # This is a **tool** the model can use to save memories to storage
    config = ensure_config(config)
    user_id = config.get("configurable", {}).get("user_id")
    namespace = ("memories", user_id)
    store.put(namespace, f"memory_{len(await store.asearch(namespace))}", {"data": memory})
    return f"Saved memory: {memory}"

The ReAct agent:

    _prompt = ChatPromptTemplate.from_messages([
                ("system", "You are a helpful AI assistant named Bob."),
                ("placeholder", "{messages}"),
                ("human", "Remember, always provide accurate answer!"),
        ])
        self._tools = [self._vectorStore.retriever_tool, ground_search, save_memory]
        self._agent = create_react_agent(self._llm, self._tools, store = in_memory_store, checkpointer = MemorySaver(), 
                               config_schema = Configuration, state_schema = CustomAgentState, name = self._name, prompt = self._prompt)

Application invoking the ReAct agent:

    async def ChatAgent(self, config: RunnableConfig, messages: List[tuple]): #messages: List[str]):
        logging.info(f"\n=== {self.ChatAgent.__name__} ===")
        async for event in self._agent.with_config({"user_id": uuid7str()}).astream(
            #{"messages": [{"role": "user", "content": messages}]}, This works with gemini-2.0-flash
           {"messages": messages}, # This works with Ollama llama3.3
            stream_mode="values", # Use this to stream all values in the state after each step.
            config=config, # This is needed by Checkpointer
        ):
            event["messages"][-1].pretty_print()

async def main():
    config = RunnableConfig(run_name="RAG ReAct Agent", thread_id=datetime.now())
    rag = RAGAgent(config)
    await rag.CreateGraph()
    input_message = [("human", "What is the standard method for Task Decomposition?"), ("human", "Once you get the answer, look up common extensions of that method.")]
    await rag.ChatAgent(config, input_message)

Error Message and Stack Trace (if applicable)

The console output:

================================ Human Message =================================

Once you get the answer, look up common extensions of that method.
================================== Ai Message ==================================
Name: RAG ReAct Agent
Tool Calls:
  Retrieve information related to a query (88674e09-6a8c-47d3-87e8-3eb26a12402c)
 Call ID: 88674e09-6a8c-47d3-87e8-3eb26a12402c
  Args:
    query: standard method for Task Decomposition
================================= Tool Message =================================
Name: Retrieve information related to a query

Fig. 1. Overview of a LLM-powered autonomous agent system.
Component One: Planning#
A complicated task usually involves many steps. An agent needs to know what they are and plan ahead.
Task Decomposition#
Chain of thought (CoT; Wei et al. 2022) has become a standard prompting technique for enhancing model performance on complex tasks. The model is instructed to “think step by step” to utilize more test-time computation to decompose hard tasks into smaller and simpler steps. CoT transforms big tasks into multiple manageable tasks and shed lights into an interpretation of the model’s thinking process.

Tree of Thoughts (Yao et al. 2023) extends CoT by exploring multiple reasoning possibilities at each step. It first decomposes the problem into multiple thought steps and generates multiple thoughts per step, creating a tree structure. The search process can be BFS (breadth-first search) or DFS (depth-first search) with each state evaluated by a classifier (via a prompt) or majority vote.
Task decomposition can be done (1) by LLM with simple prompting like "Steps for XYZ.\n1.", "What are the subgoals for achieving XYZ?", (2) by using task-specific instructions; e.g. "Write a story outline." for writing a novel, or (3) with human inputs.

Fig. 11. Illustration of how HuggingGPT works. (Image source: Shen et al. 2023)
The system comprises of 4 stages:
(1) Task planning: LLM works as the brain and parses the user requests into multiple tasks. There are four attributes associated with each task: task type, ID, dependencies, and arguments. They use few-shot examples to guide LLM to do task parsing and planning.
Instruction:

Fig. 6. Illustration of how Algorithm Distillation (AD) works. (Image source: Laskin et al. 2023).
The paper hypothesizes that any algorithm that generates a set of learning histories can be distilled into a neural network by performing behavioral cloning over actions. The history data is generated by a set of source policies, each trained for a specific task. At the training stage, during each RL run, a random task is sampled and a subsequence of multi-episode history is used for training, such that the learned policy is task-agnostic.
In reality, the model has limited context window length, so episodes should be short enough to construct multi-episode history. Multi-episodic contexts of 2-4 episodes are necessary to learn a near-optimal in-context RL algorithm. The emergence of in-context RL requires long enough context.
================================== Ai Message ==================================
Name: RAG ReAct Agent
Tool Calls:
  save_memory (c81987b3-9884-4ccd-b4e6-a101bd764235)
 Call ID: c81987b3-9884-4ccd-b4e6-a101bd764235
  Args:
    memory: Always provide an accurate answer
================================= Tool Message =================================
Name: save_memory

Saved memory: Always provide an accurate answer
================================== Ai Message ==================================
Name: RAG ReAct Agent
Tool Calls:
  save_memory (a81f12e9-15fe-4088-bf28-6fc99c6c3ff7)
 Call ID: a81f12e9-15fe-4088-bf28-6fc99c6c3ff7
  Args:
    memory: Always provide an accurate answer
================================= Tool Message =================================
Name: save_memory

Saved memory: Always provide an accurate answer
================================== Ai Message ==================================
Name: RAG ReAct Agent
Tool Calls:
  save_memory (58c99b54-1afa-47ef-8938-d78f72f75835)
 Call ID: 58c99b54-1afa-47ef-8938-d78f72f75835
  Args:
    memory: Always provide an accurate answer
================================= Tool Message =================================
Name: save_memory

Saved memory: Always provide an accurate answer
================================== Ai Message ==================================
Name: RAG ReAct Agent
Tool Calls:
  save_memory (0913b79e-a834-4730-b199-580fd0aa6abe)
 Call ID: 0913b79e-a834-4730-b199-580fd0aa6abe
  Args:
    memory: Always provide an accurate answer
================================= Tool Message =================================
Name: save_memory

Saved memory: Always provide an accurate answer
================================== Ai Message ==================================
Name: RAG ReAct Agent
Tool Calls:
  save_memory (61c44153-38c4-49ce-9974-18c56ad9e2e5)
 Call ID: 61c44153-38c4-49ce-9974-18c56ad9e2e5
  Args:
    memory: Always provide an accurate answer
================================= Tool Message =================================
Name: save_memory

Saved memory: Always provide an accurate answer
================================== Ai Message ==================================
Name: RAG ReAct Agent
Tool Calls:
  save_memory (bb004ff6-6052-4462-92d7-6a14d4738d32)
 Call ID: bb004ff6-6052-4462-92d7-6a14d4738d32
  Args:
    memory: Always provide an accurate answer
================================= Tool Message =================================
Name: save_memory

Saved memory: Always provide an accurate answer
================================== Ai Message ==================================
Name: RAG ReAct Agent
Tool Calls:
  save_memory (e759e92f-e7aa-400b-b186-bfdceeeb8257)
 Call ID: e759e92f-e7aa-400b-b186-bfdceeeb8257
  Args:
    memory: Always provide an accurate answer
================================= Tool Message =================================
Name: save_memory

Saved memory: Always provide an accurate answer
================================== Ai Message ==================================
Name: RAG ReAct Agent
Tool Calls:
  save_memory (bc7353a7-b4fd-4287-9dfb-9b67695d7b17)
 Call ID: bc7353a7-b4fd-4287-9dfb-9b67695d7b17
  Args:
    memory: Always provide an accurate answer
================================= Tool Message =================================
Name: save_memory

Saved memory: Always provide an accurate answer
================================== Ai Message ==================================
Name: RAG ReAct Agent
Tool Calls:
  save_memory (0e631708-ed77-422d-8d91-075e14712850)
 Call ID: 0e631708-ed77-422d-8d91-075e14712850
  Args:
    memory: Always provide an accurate answer
================================= Tool Message =================================
Name: save_memory

Saved memory: Always provide an accurate answer
================================== Ai Message ==================================
Name: RAG ReAct Agent
Tool Calls:
  save_memory (60e6a66f-00e3-48b5-bc5b-28c725e6eb65)
 Call ID: 60e6a66f-00e3-48b5-bc5b-28c725e6eb65
  Args:
    memory: Always provide an accurate answer
================================= Tool Message =================================
Name: save_memory

Saved memory: Always provide an accurate answer
================================== Ai Message ==================================
Name: RAG ReAct Agent
Tool Calls:
  save_memory (84eccb2d-d7e1-4714-bdcc-05fb40643dfc)
 Call ID: 84eccb2d-d7e1-4714-bdcc-05fb40643dfc
  Args:
    memory: Always provide an accurate answer
================================= Tool Message =================================
Name: save_memory

Saved memory: Always provide an accurate answer
================================== Ai Message ==================================

Sorry, need more steps to process this request.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/Python/rag-agent/src/rag_agent/RAGAgent.py", line 173, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/src/rag_agent/RAGAgent.py", line 170, in main
    await rag.ChatAgent(config, input_message)
  File "/usr/src/Python/rag-agent/src/rag_agent/RAGAgent.py", line 141, in ChatAgent
    async for event in self._agent.with_config({"user_id": uuid7str()}).astream(
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/langgraph/pregel/__init__.py", line 2648, in astream
    raise GraphRecursionError(msg)
langgraph.errors.GraphRecursionError: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.
For troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT

Description

I have a RAG ReAct agent which uses 3 tools, one to retrieve information to answer user question from Chroma vector DB, one to use GoogleSearch and the third one is to save the user memory.

The first problem I face is that it keeps calling the save_memory tool after it has retrieved the required information from Chroma vector DB to answer user's question until it hits the recursion limit.

The second problem I face is that the ReAct agent skips the first "Human Message" and goes straight to the second one in the list.

System Info

System Information
------------------
> OS:  Linux
> OS Version:  #21-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 19 16:50:40 UTC 2025
> Python Version:  3.12.7 (main, Feb  4 2025, 14:46:03) [GCC 14.2.0]

Package Information
-------------------
> langchain_core: 0.3.51
> langchain: 0.3.23
> langchain_community: 0.3.21
> langsmith: 0.3.27
> langchain_chroma: 0.2.2
> langchain_cli: 0.0.36
> langchain_google_genai: 2.1.2
> langchain_google_vertexai: 2.0.9
> langchain_neo4j: 0.4.0
> langchain_nomic: 0.1.4
> langchain_ollama: 0.3.1
> langchain_openai: 0.3.12
> langchain_text_splitters: 0.3.8
> langgraph_sdk: 0.1.61
> langserve: 0.3.1

Other Dependencies
------------------
> aiohttp<4.0.0,>=3.8.3: Installed. No version info available.
> anthropic[vertexai]: Installed. No version info available.
> async-timeout<5.0.0,>=4.0.0;: Installed. No version info available.
> chromadb!=0.5.10,!=0.5.11,!=0.5.12,!=0.5.4,!=0.5.5,!=0.5.7,!=0.5.9,<0.7.0,>=0.4.0: Installed. No version info available.
> dataclasses-json<0.7,>=0.5.7: Installed. No version info available.
> fastapi: 0.115.9
> filetype: 1.2.0
> gitpython<4,>=3: Installed. No version info available.
> google-ai-generativelanguage: 0.6.17
> google-cloud-aiplatform: 1.71.1
> google-cloud-storage: 2.19.0
> gritql<1.0.0,>=0.2.0: Installed. No version info available.
> httpx: 0.27.2
> httpx-sse: 0.4.0
> httpx-sse<1.0.0,>=0.4.0: Installed. No version info available.
> jsonpatch<2.0,>=1.33: Installed. No version info available.
> langchain-anthropic;: Installed. No version info available.
> langchain-aws;: Installed. No version info available.
> langchain-azure-ai;: Installed. No version info available.
> langchain-cohere;: Installed. No version info available.
> langchain-community;: Installed. No version info available.
> langchain-core!=0.3.0,!=0.3.1,!=0.3.10,!=0.3.11,!=0.3.12,!=0.3.13,!=0.3.14,!=0.3.2,!=0.3.3,!=0.3.4,!=0.3.5,!=0.3.6,!=0.3.7,!=0.3.8,!=0.3.9,<0.4.0,>=0.2.43: Installed. No version info available.
> langchain-core<1.0.0,>=0.3.49: Installed. No version info available.
> langchain-core<1.0.0,>=0.3.51: Installed. No version info available.
> langchain-deepseek;: Installed. No version info available.
> langchain-fireworks;: Installed. No version info available.
> langchain-google-genai;: Installed. No version info available.
> langchain-google-vertexai;: Installed. No version info available.
> langchain-groq;: Installed. No version info available.
> langchain-huggingface;: Installed. No version info available.
> langchain-mistralai: Installed. No version info available.
> langchain-mistralai;: Installed. No version info available.
> langchain-ollama;: Installed. No version info available.
> langchain-openai;: Installed. No version info available.
> langchain-perplexity;: Installed. No version info available.
> langchain-text-splitters<1.0.0,>=0.3.8: Installed. No version info available.
> langchain-together;: Installed. No version info available.
> langchain-xai;: Installed. No version info available.
> langchain<1.0.0,>=0.3.23: Installed. No version info available.
> langserve[all]>=0.0.51: Installed. No version info available.
> langsmith-pyo3: Installed. No version info available.
> langsmith<0.4,>=0.1.125: Installed. No version info available.
> langsmith<0.4,>=0.1.17: Installed. No version info available.
> neo4j: 5.28.1
> neo4j-graphrag: 1.6.1
> nomic: 3.4.1
> numpy<2.0.0,>=1.22.4;: Installed. No version info available.
> numpy<2.0.0,>=1.26.2;: Installed. No version info available.
> numpy<3,>=1.26.2: Installed. No version info available.
> ollama<1,>=0.4.4: Installed. No version info available.
> openai-agents: Installed. No version info available.
> openai<2.0.0,>=1.68.2: Installed. No version info available.
> opentelemetry-api: 1.31.1
> opentelemetry-exporter-otlp-proto-http: Installed. No version info available.
> opentelemetry-sdk: 1.31.1
> orjson: 3.10.16
> packaging: 24.2
> packaging<25,>=23.2: Installed. No version info available.
> pillow: 10.4.0
> pydantic: 2.9.2
> pydantic-settings<3.0.0,>=2.4.0: Installed. No version info available.
> pydantic<3.0.0,>=2.5.2;: Installed. No version info available.
> pydantic<3.0.0,>=2.7.4: Installed. No version info available.
> pydantic<3.0.0,>=2.7.4;: Installed. No version info available.
> pytest: 8.3.5
> PyYAML>=5.3: Installed. No version info available.
> requests: 2.32.3
> requests-toolbelt: 1.0.0
> requests<3,>=2: Installed. No version info available.
> rich: 14.0.0
> SQLAlchemy<3,>=1.4: Installed. No version info available.
> sse-starlette: 1.8.2
> tenacity!=8.4.0,<10,>=8.1.0: Installed. No version info available.
> tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available.
> tiktoken<1,>=0.7: Installed. No version info available.
> tomlkit>=0.12: Installed. No version info available.
> typer[all]<1.0.0,>=0.9.0: Installed. No version info available.
> typing-extensions>=4.7: Installed. No version info available.
> uvicorn<1.0,>=0.23: Installed. No version info available.
> zstandard: 0.23.0
Originally created by @khteh on GitHub (Apr 10, 2025). ### Checked other resources - [x] This is a bug, not a usage question. For questions, please use GitHub Discussions. - [x] I added a clear and detailed title that summarizes the issue. - [x] I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example). - [x] I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue. ### Example Code The tool in question: ```python @tool async def save_memory(memory: str, *, config: Annotated[RunnableConfig, InjectedToolArg], store: Annotated[BaseStore, InjectedStore()]) -> str: """ Save the given memory for the current user. This should only be used after you have exhausted all other tools to accomplish your task. After saving the memory for the current user, you should return to the user with your answer. """ # This is a **tool** the model can use to save memories to storage config = ensure_config(config) user_id = config.get("configurable", {}).get("user_id") namespace = ("memories", user_id) store.put(namespace, f"memory_{len(await store.asearch(namespace))}", {"data": memory}) return f"Saved memory: {memory}" ``` The ReAct agent: ``` _prompt = ChatPromptTemplate.from_messages([ ("system", "You are a helpful AI assistant named Bob."), ("placeholder", "{messages}"), ("human", "Remember, always provide accurate answer!"), ]) self._tools = [self._vectorStore.retriever_tool, ground_search, save_memory] self._agent = create_react_agent(self._llm, self._tools, store = in_memory_store, checkpointer = MemorySaver(), config_schema = Configuration, state_schema = CustomAgentState, name = self._name, prompt = self._prompt) ``` Application invoking the ReAct agent: ``` async def ChatAgent(self, config: RunnableConfig, messages: List[tuple]): #messages: List[str]): logging.info(f"\n=== {self.ChatAgent.__name__} ===") async for event in self._agent.with_config({"user_id": uuid7str()}).astream( #{"messages": [{"role": "user", "content": messages}]}, This works with gemini-2.0-flash {"messages": messages}, # This works with Ollama llama3.3 stream_mode="values", # Use this to stream all values in the state after each step. config=config, # This is needed by Checkpointer ): event["messages"][-1].pretty_print() async def main(): config = RunnableConfig(run_name="RAG ReAct Agent", thread_id=datetime.now()) rag = RAGAgent(config) await rag.CreateGraph() input_message = [("human", "What is the standard method for Task Decomposition?"), ("human", "Once you get the answer, look up common extensions of that method.")] await rag.ChatAgent(config, input_message) ``` ### Error Message and Stack Trace (if applicable) The console output: ```shell ================================ Human Message ================================= Once you get the answer, look up common extensions of that method. ================================== Ai Message ================================== Name: RAG ReAct Agent Tool Calls: Retrieve information related to a query (88674e09-6a8c-47d3-87e8-3eb26a12402c) Call ID: 88674e09-6a8c-47d3-87e8-3eb26a12402c Args: query: standard method for Task Decomposition ================================= Tool Message ================================= Name: Retrieve information related to a query Fig. 1. Overview of a LLM-powered autonomous agent system. Component One: Planning# A complicated task usually involves many steps. An agent needs to know what they are and plan ahead. Task Decomposition# Chain of thought (CoT; Wei et al. 2022) has become a standard prompting technique for enhancing model performance on complex tasks. The model is instructed to “think step by step” to utilize more test-time computation to decompose hard tasks into smaller and simpler steps. CoT transforms big tasks into multiple manageable tasks and shed lights into an interpretation of the model’s thinking process. Tree of Thoughts (Yao et al. 2023) extends CoT by exploring multiple reasoning possibilities at each step. It first decomposes the problem into multiple thought steps and generates multiple thoughts per step, creating a tree structure. The search process can be BFS (breadth-first search) or DFS (depth-first search) with each state evaluated by a classifier (via a prompt) or majority vote. Task decomposition can be done (1) by LLM with simple prompting like "Steps for XYZ.\n1.", "What are the subgoals for achieving XYZ?", (2) by using task-specific instructions; e.g. "Write a story outline." for writing a novel, or (3) with human inputs. Fig. 11. Illustration of how HuggingGPT works. (Image source: Shen et al. 2023) The system comprises of 4 stages: (1) Task planning: LLM works as the brain and parses the user requests into multiple tasks. There are four attributes associated with each task: task type, ID, dependencies, and arguments. They use few-shot examples to guide LLM to do task parsing and planning. Instruction: Fig. 6. Illustration of how Algorithm Distillation (AD) works. (Image source: Laskin et al. 2023). The paper hypothesizes that any algorithm that generates a set of learning histories can be distilled into a neural network by performing behavioral cloning over actions. The history data is generated by a set of source policies, each trained for a specific task. At the training stage, during each RL run, a random task is sampled and a subsequence of multi-episode history is used for training, such that the learned policy is task-agnostic. In reality, the model has limited context window length, so episodes should be short enough to construct multi-episode history. Multi-episodic contexts of 2-4 episodes are necessary to learn a near-optimal in-context RL algorithm. The emergence of in-context RL requires long enough context. ================================== Ai Message ================================== Name: RAG ReAct Agent Tool Calls: save_memory (c81987b3-9884-4ccd-b4e6-a101bd764235) Call ID: c81987b3-9884-4ccd-b4e6-a101bd764235 Args: memory: Always provide an accurate answer ================================= Tool Message ================================= Name: save_memory Saved memory: Always provide an accurate answer ================================== Ai Message ================================== Name: RAG ReAct Agent Tool Calls: save_memory (a81f12e9-15fe-4088-bf28-6fc99c6c3ff7) Call ID: a81f12e9-15fe-4088-bf28-6fc99c6c3ff7 Args: memory: Always provide an accurate answer ================================= Tool Message ================================= Name: save_memory Saved memory: Always provide an accurate answer ================================== Ai Message ================================== Name: RAG ReAct Agent Tool Calls: save_memory (58c99b54-1afa-47ef-8938-d78f72f75835) Call ID: 58c99b54-1afa-47ef-8938-d78f72f75835 Args: memory: Always provide an accurate answer ================================= Tool Message ================================= Name: save_memory Saved memory: Always provide an accurate answer ================================== Ai Message ================================== Name: RAG ReAct Agent Tool Calls: save_memory (0913b79e-a834-4730-b199-580fd0aa6abe) Call ID: 0913b79e-a834-4730-b199-580fd0aa6abe Args: memory: Always provide an accurate answer ================================= Tool Message ================================= Name: save_memory Saved memory: Always provide an accurate answer ================================== Ai Message ================================== Name: RAG ReAct Agent Tool Calls: save_memory (61c44153-38c4-49ce-9974-18c56ad9e2e5) Call ID: 61c44153-38c4-49ce-9974-18c56ad9e2e5 Args: memory: Always provide an accurate answer ================================= Tool Message ================================= Name: save_memory Saved memory: Always provide an accurate answer ================================== Ai Message ================================== Name: RAG ReAct Agent Tool Calls: save_memory (bb004ff6-6052-4462-92d7-6a14d4738d32) Call ID: bb004ff6-6052-4462-92d7-6a14d4738d32 Args: memory: Always provide an accurate answer ================================= Tool Message ================================= Name: save_memory Saved memory: Always provide an accurate answer ================================== Ai Message ================================== Name: RAG ReAct Agent Tool Calls: save_memory (e759e92f-e7aa-400b-b186-bfdceeeb8257) Call ID: e759e92f-e7aa-400b-b186-bfdceeeb8257 Args: memory: Always provide an accurate answer ================================= Tool Message ================================= Name: save_memory Saved memory: Always provide an accurate answer ================================== Ai Message ================================== Name: RAG ReAct Agent Tool Calls: save_memory (bc7353a7-b4fd-4287-9dfb-9b67695d7b17) Call ID: bc7353a7-b4fd-4287-9dfb-9b67695d7b17 Args: memory: Always provide an accurate answer ================================= Tool Message ================================= Name: save_memory Saved memory: Always provide an accurate answer ================================== Ai Message ================================== Name: RAG ReAct Agent Tool Calls: save_memory (0e631708-ed77-422d-8d91-075e14712850) Call ID: 0e631708-ed77-422d-8d91-075e14712850 Args: memory: Always provide an accurate answer ================================= Tool Message ================================= Name: save_memory Saved memory: Always provide an accurate answer ================================== Ai Message ================================== Name: RAG ReAct Agent Tool Calls: save_memory (60e6a66f-00e3-48b5-bc5b-28c725e6eb65) Call ID: 60e6a66f-00e3-48b5-bc5b-28c725e6eb65 Args: memory: Always provide an accurate answer ================================= Tool Message ================================= Name: save_memory Saved memory: Always provide an accurate answer ================================== Ai Message ================================== Name: RAG ReAct Agent Tool Calls: save_memory (84eccb2d-d7e1-4714-bdcc-05fb40643dfc) Call ID: 84eccb2d-d7e1-4714-bdcc-05fb40643dfc Args: memory: Always provide an accurate answer ================================= Tool Message ================================= Name: save_memory Saved memory: Always provide an accurate answer ================================== Ai Message ================================== Sorry, need more steps to process this request. Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/Python/rag-agent/src/rag_agent/RAGAgent.py", line 173, in <module> asyncio.run(main()) File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/src/rag_agent/RAGAgent.py", line 170, in main await rag.ChatAgent(config, input_message) File "/usr/src/Python/rag-agent/src/rag_agent/RAGAgent.py", line 141, in ChatAgent async for event in self._agent.with_config({"user_id": uuid7str()}).astream( File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/langgraph/pregel/__init__.py", line 2648, in astream raise GraphRecursionError(msg) langgraph.errors.GraphRecursionError: Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key. For troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/GRAPH_RECURSION_LIMIT ``` ### Description I have a RAG ReAct agent which uses 3 tools, one to retrieve information to answer user question from Chroma vector DB, one to use GoogleSearch and the third one is to save the user memory. The first problem I face is that it keeps calling the `save_memory` tool after it has retrieved the required information from Chroma vector DB to answer user's question until it hits the recursion limit. The second problem I face is that the ReAct agent skips the first "Human Message" and goes straight to the second one in the list. ### System Info ``` System Information ------------------ > OS: Linux > OS Version: #21-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 19 16:50:40 UTC 2025 > Python Version: 3.12.7 (main, Feb 4 2025, 14:46:03) [GCC 14.2.0] Package Information ------------------- > langchain_core: 0.3.51 > langchain: 0.3.23 > langchain_community: 0.3.21 > langsmith: 0.3.27 > langchain_chroma: 0.2.2 > langchain_cli: 0.0.36 > langchain_google_genai: 2.1.2 > langchain_google_vertexai: 2.0.9 > langchain_neo4j: 0.4.0 > langchain_nomic: 0.1.4 > langchain_ollama: 0.3.1 > langchain_openai: 0.3.12 > langchain_text_splitters: 0.3.8 > langgraph_sdk: 0.1.61 > langserve: 0.3.1 Other Dependencies ------------------ > aiohttp<4.0.0,>=3.8.3: Installed. No version info available. > anthropic[vertexai]: Installed. No version info available. > async-timeout<5.0.0,>=4.0.0;: Installed. No version info available. > chromadb!=0.5.10,!=0.5.11,!=0.5.12,!=0.5.4,!=0.5.5,!=0.5.7,!=0.5.9,<0.7.0,>=0.4.0: Installed. No version info available. > dataclasses-json<0.7,>=0.5.7: Installed. No version info available. > fastapi: 0.115.9 > filetype: 1.2.0 > gitpython<4,>=3: Installed. No version info available. > google-ai-generativelanguage: 0.6.17 > google-cloud-aiplatform: 1.71.1 > google-cloud-storage: 2.19.0 > gritql<1.0.0,>=0.2.0: Installed. No version info available. > httpx: 0.27.2 > httpx-sse: 0.4.0 > httpx-sse<1.0.0,>=0.4.0: Installed. No version info available. > jsonpatch<2.0,>=1.33: Installed. No version info available. > langchain-anthropic;: Installed. No version info available. > langchain-aws;: Installed. No version info available. > langchain-azure-ai;: Installed. No version info available. > langchain-cohere;: Installed. No version info available. > langchain-community;: Installed. No version info available. > langchain-core!=0.3.0,!=0.3.1,!=0.3.10,!=0.3.11,!=0.3.12,!=0.3.13,!=0.3.14,!=0.3.2,!=0.3.3,!=0.3.4,!=0.3.5,!=0.3.6,!=0.3.7,!=0.3.8,!=0.3.9,<0.4.0,>=0.2.43: Installed. No version info available. > langchain-core<1.0.0,>=0.3.49: Installed. No version info available. > langchain-core<1.0.0,>=0.3.51: Installed. No version info available. > langchain-deepseek;: Installed. No version info available. > langchain-fireworks;: Installed. No version info available. > langchain-google-genai;: Installed. No version info available. > langchain-google-vertexai;: Installed. No version info available. > langchain-groq;: Installed. No version info available. > langchain-huggingface;: Installed. No version info available. > langchain-mistralai: Installed. No version info available. > langchain-mistralai;: Installed. No version info available. > langchain-ollama;: Installed. No version info available. > langchain-openai;: Installed. No version info available. > langchain-perplexity;: Installed. No version info available. > langchain-text-splitters<1.0.0,>=0.3.8: Installed. No version info available. > langchain-together;: Installed. No version info available. > langchain-xai;: Installed. No version info available. > langchain<1.0.0,>=0.3.23: Installed. No version info available. > langserve[all]>=0.0.51: Installed. No version info available. > langsmith-pyo3: Installed. No version info available. > langsmith<0.4,>=0.1.125: Installed. No version info available. > langsmith<0.4,>=0.1.17: Installed. No version info available. > neo4j: 5.28.1 > neo4j-graphrag: 1.6.1 > nomic: 3.4.1 > numpy<2.0.0,>=1.22.4;: Installed. No version info available. > numpy<2.0.0,>=1.26.2;: Installed. No version info available. > numpy<3,>=1.26.2: Installed. No version info available. > ollama<1,>=0.4.4: Installed. No version info available. > openai-agents: Installed. No version info available. > openai<2.0.0,>=1.68.2: Installed. No version info available. > opentelemetry-api: 1.31.1 > opentelemetry-exporter-otlp-proto-http: Installed. No version info available. > opentelemetry-sdk: 1.31.1 > orjson: 3.10.16 > packaging: 24.2 > packaging<25,>=23.2: Installed. No version info available. > pillow: 10.4.0 > pydantic: 2.9.2 > pydantic-settings<3.0.0,>=2.4.0: Installed. No version info available. > pydantic<3.0.0,>=2.5.2;: Installed. No version info available. > pydantic<3.0.0,>=2.7.4: Installed. No version info available. > pydantic<3.0.0,>=2.7.4;: Installed. No version info available. > pytest: 8.3.5 > PyYAML>=5.3: Installed. No version info available. > requests: 2.32.3 > requests-toolbelt: 1.0.0 > requests<3,>=2: Installed. No version info available. > rich: 14.0.0 > SQLAlchemy<3,>=1.4: Installed. No version info available. > sse-starlette: 1.8.2 > tenacity!=8.4.0,<10,>=8.1.0: Installed. No version info available. > tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available. > tiktoken<1,>=0.7: Installed. No version info available. > tomlkit>=0.12: Installed. No version info available. > typer[all]<1.0.0,>=0.9.0: Installed. No version info available. > typing-extensions>=4.7: Installed. No version info available. > uvicorn<1.0,>=0.23: Installed. No version info available. > zstandard: 0.23.0 ```
yindo closed this issue 2026-02-20 17:40:47 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#576