-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Calling .invoke() as standalone on a StructuredTool requires a ToolRuntime object #7222
Copy link
Copy link
Labels
Description
Checked other resources
- This is a bug, not a usage question.
- I added a clear and descriptive title that summarizes this issue.
- I used the GitHub search to find a similar question and didn't find it.
- I am sure that this is a bug in LangGraph rather than my code.
- The bug is not resolved by updating to the latest stable version of LangGraph (or the specific integration package).
- This is not related to the langchain-community package.
- I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.
Reproduction Steps / Example Code (Python)
@tool
def tool_test_one(runtime: ToolRuntime):
pass
tool_test_one.invoke({})
@tool
def tool_test_two(runtime: Optional[ToolRuntime]):
pass
tool_test_two.invoke({'runtime': None})Error Message and Stack Trace (if applicable)
I am not allowed to provide the stack trace due to operating on corporate hardware, but the error for the first case stems from Pydantic saying the 'runtime' input is missing. The error for the second case is from Pydantic saying it can't evaluate the Optional[ToolRuntime] type and tool input parameters need to be JSON serializable.Description
My question is what is the proper way to call invoke on a previously created tool function when there is no ToolRuntime since the tool function is being called standalone as part of a unit test via invoke() on the StructuredTool? Does the source code need to be changed to allow Optional[ToolRuntime] as an input to the tool or change the invoke function to not be required to provide a ToolRuntime object?
System Info
I am not allowed to share this due to operating on corporate hardware.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackNo fields configured for Bug.