test_two_handlers_with_commands() — langchain Function Reference
Architecture documentation for the test_two_handlers_with_commands() function in test_composition.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD a71fe78b_b173_b78f_9635_f0879410586c["test_two_handlers_with_commands()"] f1e766c6_5a64_9e6c_f2a8_d41c64f6f142["TestChainModelCallHandlers"] a71fe78b_b173_b78f_9635_f0879410586c -->|defined in| f1e766c6_5a64_9e6c_f2a8_d41c64f6f142 3988450e_19ed_2280_0a85_e9520f7f556b["create_test_request()"] a71fe78b_b173_b78f_9635_f0879410586c -->|calls| 3988450e_19ed_2280_0a85_e9520f7f556b 1cdbb163_cfa8_588a_643a_640bbf32247f["create_mock_base_handler()"] a71fe78b_b173_b78f_9635_f0879410586c -->|calls| 1cdbb163_cfa8_588a_643a_640bbf32247f style a71fe78b_b173_b78f_9635_f0879410586c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_composition.py lines 96–126
def test_two_handlers_with_commands(self) -> None:
"""Test that commands from inner and outer are collected correctly."""
def outer(
request: ModelRequest, handler: Callable[[ModelRequest], ModelResponse]
) -> ExtendedModelResponse:
response = handler(request)
return ExtendedModelResponse(
model_response=response,
command=Command(update={"outer_key": "outer_val"}),
)
def inner(
request: ModelRequest, handler: Callable[[ModelRequest], ModelResponse]
) -> ExtendedModelResponse:
response = handler(request)
return ExtendedModelResponse(
model_response=response,
command=Command(update={"inner_key": "inner_val"}),
)
composed = _chain_model_call_handlers([outer, inner])
assert composed is not None
result = composed(create_test_request(), create_mock_base_handler())
assert isinstance(result, _ComposedExtendedModelResponse)
# Commands are collected: inner first, then outer
assert len(result.commands) == 2
assert result.commands[0].update == {"inner_key": "inner_val"}
assert result.commands[1].update == {"outer_key": "outer_val"}
Domain
Subdomains
Source
Frequently Asked Questions
What does test_two_handlers_with_commands() do?
test_two_handlers_with_commands() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_composition.py.
Where is test_two_handlers_with_commands() defined?
test_two_handlers_with_commands() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_composition.py at line 96.
What does test_two_handlers_with_commands() call?
test_two_handlers_with_commands() calls 2 function(s): create_mock_base_handler, create_test_request.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free