langchain-ai/langchain

```RunnableConfig``` not passed into tools when using ```AgentExecutor```

Closed this issue · 5 comments

Example Code

When running tools through an AgentExecutor, the RunnableConfig is not being propagated to the tool — both when using .with_config() and when passing config directly to .invoke() / .ainvoke().

Inside the tool, config is always empty or None.

from langchain_core.runnables import RunnableConfig
from langchain.agents import AgentExecutor
from langchain_core.tools import tool

# Example tool
@tool
def list_projects_detailed(project: str, config: RunnableConfig):
    print("Config inside tool:", config)  # always None
    return {"projects": []}

# Agent execution
async def run_agent(user_query: str, user_id: str):
    config = {"user_id": user_id}

    agent_executor = AgentExecutor(
        agent=agent,
        tools=[list_projects_detailed],
        verbose=True,
        handle_parsing_errors=True,
    )

    # Case 1: `with_config`
    agent_executor = agent_executor.with_config(config=config)
    response = await agent_executor.ainvoke({"input": user_query})
    print("response (with_config):", response)

    # Case 2: passing config directly
    response2 = await agent_executor.ainvoke({"input": user_query}, config=config)
    print("response (ainvoke with config):", response2)

Error Message and Stack Trace (if applicable)

No response

Description

  • Tools should receive the RunnableConfig with user_id inside their config parameter.

  • In both cases, config is None inside the tool.

System Info

Environment

  • LangChain version: 0.3.27
  • langchain-core version: 0.3.75
  • Python version: 3.12
  • Backend: OpenAI
  • OS: (Ubuntu 22.04)

I also checked [discussion #28694](https://github.com/langchain-ai/langchain/discussions/28694), which seems related. It looks like RunnableConfig is not being passed into tools from AgentExecutor.

I have created a PR #33117 . There are linting issues for now. Can u check the code ?

I have opened a PR fix for this issue

Any repo maintainer please review it

@sbusso

I have opened a PR fix for this issue

Any repo maintainer please review it

@sbusso

@aroun-coumar no, thanks

@sbusso Do you mean you are not repo maintainer, Sorry about that.

Closing as stale, no longer actively maintaining AgentExecutor