Langgraph RunnableConfig is not getting passed to callable
Passing Config to LangGraph Tool Discrepancies
How to view RunnableConfig state in LangGraph traces?
Issue with from langchain_core.runnables import RunnableConfig
Videos
[Solved]: config type in tool must be of type RunnableConfig only. Not RunnableConfig | None, not Optional[RunnableConfig]. Maybe langchain team can modify their _get_runnable_config_param function to do additional checks for flexibility to cater for this (reasoning in comments)
Issue
All my tools are created using BaseTool.
LangGraph documentation says I can invoke the graph with a configurable and it will be accessible in the tool's _run method's config Runnable. However, the value seems to be None.
I created an additional tool using the @tool decorator and added it to the tools array for the graph, and noticed that the config was actually accessible there, with the specified values.
I even log the config in the different node runnables throughout the graph and see that it is present. So not sure why it isn't showing up in the _run for the base tool.
On a phone, but it was something like this:
@tool
def my_tool(param1: int, config: RunnableConfig):
print("Config is", config, type(config))
# I get "Config is" {...really large dict...}, <dict>
tools=[my_tool]class MyTool(BaseTool):
...
def _run(
param1: int,
param2: string,
config: RunnableConfig
):
print("Config is", config, type(config))
# I get "Config is" None, <NoneType>
tools=[MyTool()] #no worries, it is properly instatiated and sent to the graph.I use langgraph 0.1.17 (I forgot the correct number, but it's the last one before 0.2 due to breaking changes) but I doubt it's that, since BaseTool is from langchain_community, of which I have the latest version.
Edit: I call my graph using graph.astream_events. Not sure if that causes the difference, but including that knowledge here regardless. My BaseTool does not have a matching _arun method to go with all the async functions though, but I'm not sure that is why it does not show the config.