Home / Function/ test_override_with_copy_pattern() — langchain Function Reference

test_override_with_copy_pattern() — langchain Function Reference

Architecture documentation for the test_override_with_copy_pattern() function in test_overrides.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  bf3eea49_a805_86d7_e025_fec062a4032a["test_override_with_copy_pattern()"]
  fe9405ec_9f76_8e01_a9d8_c9a8313d07fc["TestToolCallRequestOverride"]
  bf3eea49_a805_86d7_e025_fec062a4032a -->|defined in| fe9405ec_9f76_8e01_a9d8_c9a8313d07fc
  style bf3eea49_a805_86d7_e025_fec062a4032a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_overrides.py lines 355–385

    def test_override_with_copy_pattern(self) -> None:
        """Test common pattern of copying and modifying tool_call."""

        @tool
        def test_tool(value: int) -> str:
            """A test tool."""
            return f"Result: {value}"

        original_call = ToolCall(
            name="test_tool",
            args={"value": 5},
            id="call_123",
            type="tool_call",
        )

        original_request = ToolCallRequest(
            tool_call=original_call,
            tool=test_tool,
            state=AgentState(messages=[]),
            runtime=Mock(),
        )

        # Common pattern: copy tool_call and modify args
        modified_call = ToolCall({**original_request.tool_call, "args": {"value": 10}})
        new_request = original_request.override(tool_call=modified_call)

        assert new_request.tool_call["args"]["value"] == 10
        assert new_request.tool_call["id"] == "call_123"
        assert new_request.tool_call["name"] == "test_tool"
        # Original unchanged
        assert original_request.tool_call["args"]["value"] == 5

Domain

Subdomains

Frequently Asked Questions

What does test_override_with_copy_pattern() do?
test_override_with_copy_pattern() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_overrides.py.
Where is test_override_with_copy_pattern() defined?
test_override_with_copy_pattern() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_overrides.py at line 355.

Analyze Your Own Codebase

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

Try Supermodel Free