TestToolCallRequestOverride Class — langchain Architecture
Architecture documentation for the TestToolCallRequestOverride class in test_overrides.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD fe9405ec_9f76_8e01_a9d8_c9a8313d07fc["TestToolCallRequestOverride"] ee49be32_a4ff_96ee_e234_5e8fd8a9500d["test_overrides.py"] fe9405ec_9f76_8e01_a9d8_c9a8313d07fc -->|defined in| ee49be32_a4ff_96ee_e234_5e8fd8a9500d 8eea0c71_9fe8_58cf_3847_30e6704386b1["test_override_tool_call()"] fe9405ec_9f76_8e01_a9d8_c9a8313d07fc -->|method| 8eea0c71_9fe8_58cf_3847_30e6704386b1 3e93ffef_e8cc_f834_3f87_0d185a4cf1b7["test_override_state()"] fe9405ec_9f76_8e01_a9d8_c9a8313d07fc -->|method| 3e93ffef_e8cc_f834_3f87_0d185a4cf1b7 1aa16ba4_6b43_66f6_50ac_245652ee6c4a["test_override_multiple_attributes()"] fe9405ec_9f76_8e01_a9d8_c9a8313d07fc -->|method| 1aa16ba4_6b43_66f6_50ac_245652ee6c4a bf3eea49_a805_86d7_e025_fec062a4032a["test_override_with_copy_pattern()"] fe9405ec_9f76_8e01_a9d8_c9a8313d07fc -->|method| bf3eea49_a805_86d7_e025_fec062a4032a f7c7d58e_00b2_ff3a_7d7c_75db373d9868["test_override_preserves_identity()"] fe9405ec_9f76_8e01_a9d8_c9a8313d07fc -->|method| f7c7d58e_00b2_ff3a_7d7c_75db373d9868 fc418b4a_1329_e0ad_827b_6ea3fd4c0169["test_override_chaining()"] fe9405ec_9f76_8e01_a9d8_c9a8313d07fc -->|method| fc418b4a_1329_e0ad_827b_6ea3fd4c0169
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_overrides.py lines 256–442
class TestToolCallRequestOverride:
"""Test the ToolCallRequest.override() method."""
def test_override_tool_call(self) -> None:
"""Test overriding tool_call dict."""
@tool
def test_tool(x: int) -> str:
"""A test tool."""
return f"Result: {x}"
original_call = ToolCall(name="test_tool", args={"x": 5}, id="1", type="tool_call")
modified_call = ToolCall(name="test_tool", args={"x": 10}, id="1", type="tool_call")
original_request = ToolCallRequest(
tool_call=original_call,
tool=test_tool,
state={"messages": []},
runtime=Mock(),
)
new_request = original_request.override(tool_call=modified_call)
# New request should have modified tool_call
assert new_request.tool_call["args"]["x"] == 10
# Original should be unchanged
assert original_request.tool_call["args"]["x"] == 5
# Other attributes should be the same
assert new_request.tool is original_request.tool
assert new_request.state is original_request.state
def test_override_state(self) -> None:
"""Test overriding state."""
@tool
def test_tool(x: int) -> str:
"""A test tool."""
return f"Result: {x}"
tool_call = ToolCall(name="test_tool", args={"x": 5}, id="1", type="tool_call")
original_state = {"messages": [HumanMessage("Hi")]}
new_state = {"messages": [HumanMessage("Hi"), AIMessage("Hello")]}
original_request = ToolCallRequest(
tool_call=tool_call,
tool=test_tool,
state=original_state,
runtime=Mock(),
)
new_request = original_request.override(state=new_state)
assert len(new_request.state["messages"]) == 2
assert len(original_request.state["messages"]) == 1
def test_override_multiple_attributes(self) -> None:
"""Test overriding multiple attributes at once."""
@tool
def test_tool(x: int) -> str:
"""A test tool."""
return f"Result: {x}"
@tool
def another_tool(y: str) -> str:
"""Another test tool."""
return f"Output: {y}"
original_call = ToolCall(name="test_tool", args={"x": 5}, id="1", type="tool_call")
modified_call = ToolCall(
name="another_tool",
args={"y": "hello"},
id="2",
type="tool_call",
)
original_request = ToolCallRequest(
tool_call=original_call,
tool=test_tool,
state={"count": 1},
runtime=Mock(),
Source
Frequently Asked Questions
What is the TestToolCallRequestOverride class?
TestToolCallRequestOverride is a class in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_overrides.py.
Where is TestToolCallRequestOverride defined?
TestToolCallRequestOverride is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_overrides.py at line 256.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free