Home / Function/ test_tool_invoke_does_not_mutate_inputs() — langchain Function Reference

test_tool_invoke_does_not_mutate_inputs() — langchain Function Reference

Architecture documentation for the test_tool_invoke_does_not_mutate_inputs() function in test_tools.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  993065ad_407c_6490_9866_2fe5faeed94e["test_tool_invoke_does_not_mutate_inputs()"]
  8e7836ae_e72c_f670_72a5_4ca6d46e3555["test_tools.py"]
  993065ad_407c_6490_9866_2fe5faeed94e -->|defined in| 8e7836ae_e72c_f670_72a5_4ca6d46e3555
  style 993065ad_407c_6490_9866_2fe5faeed94e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/test_tools.py lines 2903–2939

def test_tool_invoke_does_not_mutate_inputs() -> None:
    """Verify that the inputs are not mutated when invoking a tool synchronously."""

    def sync_no_op(foo: int) -> str:
        return "good"

    async def async_no_op(foo: int) -> str:
        return "good"

    tool = StructuredTool(
        name="sample_tool",
        description="",
        args_schema={
            "type": "object",
            "required": ["foo"],
            "properties": {
                "seconds": {"type": "number", "description": "How big is foo"}
            },
        },
        coroutine=async_no_op,
        func=sync_no_op,
    )

    tool_call: ToolCall = {
        "name": "sample_tool",
        "args": {"foo": 2},
        "id": "call_0_82c17db8-95df-452f-a4c2-03f809022134",
        "type": "tool_call",
    }

    assert tool.invoke(tool_call["args"]) == "good"
    assert tool_call == {
        "name": "sample_tool",
        "args": {"foo": 2},
        "id": "call_0_82c17db8-95df-452f-a4c2-03f809022134",
        "type": "tool_call",
    }

Domain

Subdomains

Frequently Asked Questions

What does test_tool_invoke_does_not_mutate_inputs() do?
test_tool_invoke_does_not_mutate_inputs() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/test_tools.py.
Where is test_tool_invoke_does_not_mutate_inputs() defined?
test_tool_invoke_does_not_mutate_inputs() is defined in libs/core/tests/unit_tests/test_tools.py at line 2903.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free