[Python] How to access state from LangGraph inside a tool in a react agent or OpenAI Tool...

Discussão em 'Python' iniciado por Stack, Abril 10, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using LangGraph along with a react agent in LangChain to create an agent that can execute tools (Tools).

    I need to access the state from LangGraph inside a tool, or at least be able to pass variables like user_id to the agent so that tools can use them.

    agent_executor = create_openai_tools_agent(
    tools=tools,
    llm=llm,
    )

    @tool
    def get_goals(user_id: int):
    """
    Returns the users goals
    Args:
    state: estado actual de la conversacion

    Returns:

    """

    ** HERE IS WHERE I NEED THE user_id **

    logging.info(f"Getting goals for user with id: {user_id}")

    return ""


    res = agent_executor.invoke({
    "input": "I would like to know my goals",
    })

    Continue reading...

Compartilhe esta Página