test_model_retry_multiple_middleware_composition() — langchain Function Reference
Architecture documentation for the test_model_retry_multiple_middleware_composition() function in test_model_retry.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 40a93007_4c6e_711f_a5db_9b161eac06e3["test_model_retry_multiple_middleware_composition()"] 6a114635_155a_5b86_2f48_fb8ca99f7545["test_model_retry.py"] 40a93007_4c6e_711f_a5db_9b161eac06e3 -->|defined in| 6a114635_155a_5b86_2f48_fb8ca99f7545 style 40a93007_4c6e_711f_a5db_9b161eac06e3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_model_retry.py lines 662–698
def test_model_retry_multiple_middleware_composition() -> None:
"""Test ModelRetryMiddleware composes correctly with other middleware."""
call_log = []
# Custom middleware that logs calls
@wrap_model_call
def logging_middleware(
request: ModelRequest,
handler: Callable[[ModelRequest], ModelResponse],
) -> ModelCallResult:
call_log.append("before_model")
response = handler(request)
call_log.append("after_model")
return response
model = FakeToolCallingModel()
retry = ModelRetryMiddleware(max_retries=2, initial_delay=0.01, jitter=False)
agent = create_agent(
model=model,
tools=[],
middleware=[logging_middleware, retry],
checkpointer=InMemorySaver(),
)
result = agent.invoke(
{"messages": [HumanMessage("Hello")]},
{"configurable": {"thread_id": "test"}},
)
# Both middleware should be called
assert call_log == ["before_model", "after_model"]
ai_messages = [m for m in result["messages"] if isinstance(m, AIMessage)]
assert len(ai_messages) >= 1
assert "Hello" in ai_messages[-1].content
Domain
Subdomains
Source
Frequently Asked Questions
What does test_model_retry_multiple_middleware_composition() do?
test_model_retry_multiple_middleware_composition() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_model_retry.py.
Where is test_model_retry_multiple_middleware_composition() defined?
test_model_retry_multiple_middleware_composition() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_model_retry.py at line 662.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free