fix(langgraph): forward *args/**kwargs through node wrappers to preserve config kwarg#1316
Open
IgnazioDS wants to merge 1 commit intoAgentOps-AI:mainfrom
Open
fix(langgraph): forward *args/**kwargs through node wrappers to preserve config kwarg#1316IgnazioDS wants to merge 1 commit intoAgentOps-AI:mainfrom
IgnazioDS wants to merge 1 commit intoAgentOps-AI:mainfrom
Conversation
…rve config kwarg LangGraph node functions may accept a second argument: config: RunnableConfig. The node wrappers in _wrap_add_node used fixed (state,) signatures, which caused LangGraph to call the wrapped function with config= and receive: TypeError: agent_node() got an unexpected keyword argument 'config' Fix: change both wrapped_node_async and wrapped_node_sync to use *args, **kwargs so any additional arguments passed by the LangGraph runtime are transparently forwarded to the original node function. Fixes AgentOps-AI#1295
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
LangGraph node functions may accept a second argument
config: RunnableConfig:When AgentOps instruments the graph via
_wrap_add_node, bothwrapped_node_asyncandwrapped_node_syncuse a hard-coded(state)signature:LangGraph calls the node with
config=...as a keyword argument, but the wrapper doesn't accept it, raising:Fix
Change both
wrapped_node_asyncandwrapped_node_syncto(*args, **kwargs)and forward them to the original function:This is transparent — nodes that only accept
statecontinue to work exactly as before. Nodes that also acceptconfig(or any future LangGraph-injected arguments) now work correctly.Fixes #1295
Test plan
def agent_node(state, config: RunnableConfig)no longer raisesTypeErrorwhen AgentOps is activedef agent_node(state)nodes continue to work normally