test_invoke_matches_output_schema() — langchain Function Reference
Architecture documentation for the test_invoke_matches_output_schema() function in tools.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 3e3f1864_07c4_0f8d_1000_5f8d43596bdf["test_invoke_matches_output_schema()"] 1d8fc9eb_6e1b_e6b2_25c1_496643fddc53["ToolsIntegrationTests"] 3e3f1864_07c4_0f8d_1000_5f8d43596bdf -->|defined in| 1d8fc9eb_6e1b_e6b2_25c1_496643fddc53 style 3e3f1864_07c4_0f8d_1000_5f8d43596bdf fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/standard-tests/langchain_tests/integration_tests/tools.py lines 12–43
def test_invoke_matches_output_schema(self, tool: BaseTool) -> None:
"""Test invoke matches output schema.
If invoked with a `ToolCall`, the tool should return a valid `ToolMessage`
content.
If you have followed the [custom tool guide](https://docs.langchain.com/oss/python/contributing/implement-langchain#tools),
this test should always pass because `ToolCall` inputs are handled by the
`langchain_core.tools.BaseTool` class.
If you have not followed this guide, you should ensure that your tool's
`invoke` method returns a valid ToolMessage content when it receives
a `dict` representing a `ToolCall` as input (as opposed to distinct args).
"""
tool_call = ToolCall(
name=tool.name,
args=self.tool_invoke_params_example,
id="123",
type="tool_call",
)
result = tool.invoke(tool_call)
tool_message = result
if tool.response_format == "content_and_artifact":
# artifact can be anything, except none
assert tool_message.artifact is not None
# check content is a valid ToolMessage content
assert isinstance(tool_message.content, str | list)
if isinstance(tool_message.content, list):
# content blocks must be str or dict
assert all(isinstance(c, str | dict) for c in tool_message.content)
Domain
Subdomains
Source
Frequently Asked Questions
What does test_invoke_matches_output_schema() do?
test_invoke_matches_output_schema() is a function in the langchain codebase, defined in libs/standard-tests/langchain_tests/integration_tests/tools.py.
Where is test_invoke_matches_output_schema() defined?
test_invoke_matches_output_schema() is defined in libs/standard-tests/langchain_tests/integration_tests/tools.py at line 12.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free