Tool execution issues or React agent issues? #621

Closed
opened 2026-02-20 17:41:00 -05:00 by yindo · 2 comments
Owner

Originally created by @imliinyi on GitHub (May 14, 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

class TestNode(BaseNode):
    def __init__(self, llm: ChatOpenAI, system_prompt: str):
        self.tools = python_repl_tool
        self.test_agent = create_react_agent(
            llm,
            tools=[self.tools],
            prompt=system_prompt
        )

    def node(self, state: CodeMessageState) -> Command[Literal["code_generate_node", "check_node", END]]:
        """处理测试节点逻辑"""
        code = state.code
        print("=====TEST NODE RUN=====")
        result = self.test_agent.invoke(state)
        goto = self.get_next_node(result["messages"][-1])
        result["messages"][-1] = HumanMessage(
            content=result["messages"][-1].content,
            name="tester"
        )
        return Command(
            update={
                "messages": result["messages"],
                "code": code,
            },
            goto=goto
        )

Error Message and Stack Trace (if applicable)

=====TEST NODE RUN=====
Python REPL can execute arbitrary code. Use with caution.

=====TEST NODE RUN=====
=====END=====

Description

When I execute this node once, it can always run the python_depl_tool tool, but when I run it in bulk, there is a high probability that it will not use the python_depl_tool tool. That's why?The second time, he did not use the python_depl_tool tool

System Info

langchain_core: 0.3.59
langchain: 0.3.25
langchain_community: 0.3.23
langsmith: 0.3.24
langchain_experimental: 0.3.4
langchain_openai: 0.3.16
langchain_text_splitters: 0.3.8
langgraph_sdk: 0.1.61

Originally created by @imliinyi on GitHub (May 14, 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 ```python class TestNode(BaseNode): def __init__(self, llm: ChatOpenAI, system_prompt: str): self.tools = python_repl_tool self.test_agent = create_react_agent( llm, tools=[self.tools], prompt=system_prompt ) def node(self, state: CodeMessageState) -> Command[Literal["code_generate_node", "check_node", END]]: """处理测试节点逻辑""" code = state.code print("=====TEST NODE RUN=====") result = self.test_agent.invoke(state) goto = self.get_next_node(result["messages"][-1]) result["messages"][-1] = HumanMessage( content=result["messages"][-1].content, name="tester" ) return Command( update={ "messages": result["messages"], "code": code, }, goto=goto ) ``` ### Error Message and Stack Trace (if applicable) ```shell =====TEST NODE RUN===== Python REPL can execute arbitrary code. Use with caution. =====TEST NODE RUN===== =====END===== ``` ### Description When I execute this node once, it can always run the python_depl_tool tool, but when I run it in bulk, there is a high probability that it will not use the python_depl_tool tool. That's why?The second time, he did not use the python_depl_tool tool ### System Info > langchain_core: 0.3.59 > langchain: 0.3.25 > langchain_community: 0.3.23 > langsmith: 0.3.24 > langchain_experimental: 0.3.4 > langchain_openai: 0.3.16 > langchain_text_splitters: 0.3.8 > langgraph_sdk: 0.1.61
yindo added the question label 2026-02-20 17:41:00 -05:00
yindo closed this issue 2026-02-20 17:41:00 -05:00
Author
Owner

@vbarda commented on GitHub (May 14, 2025):

This is most likely an issue with the LLM you're using. LangGraph's prebuilt create_react_agent doesn't have any specific logic for determining whether to use a tool - it's up to the underlying LLM to determine this. Please provide more details if you still think there is some issue specifically w/ LangGraph, otherwise will close the issue

@vbarda commented on GitHub (May 14, 2025): This is most likely an issue with the LLM you're using. LangGraph's prebuilt `create_react_agent` doesn't have any specific logic for determining whether to use a tool - it's up to the underlying LLM to determine this. Please provide more details if you still think there is some issue specifically w/ LangGraph, otherwise will close the issue
Author
Owner

@imliinyi commented on GitHub (May 15, 2025):

This is most likely an issue with the LLM you're using. LangGraph's prebuilt create_react_agent doesn't have any specific logic for determining whether to use a tool - it's up to the underlying LLM to determine this. Please provide more details if you still think there is some issue specifically w/ LangGraph, otherwise will close the issue

Got It

@imliinyi commented on GitHub (May 15, 2025): > This is most likely an issue with the LLM you're using. LangGraph's prebuilt `create_react_agent` doesn't have any specific logic for determining whether to use a tool - it's up to the underlying LLM to determine this. Please provide more details if you still think there is some issue specifically w/ LangGraph, otherwise will close the issue Got It
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#621