test_async_model_with_middleware() — langchain Function Reference
Architecture documentation for the test_async_model_with_middleware() function in test_wrap_model_call.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 2e11e37c_8880_df9b_8469_c973104f6b4a["test_async_model_with_middleware()"] 75e76fa8_8e23_8ada_b149_8fa3fd341b70["TestAsyncWrapModelCall"] 2e11e37c_8880_df9b_8469_c973104f6b4a -->|defined in| 75e76fa8_8e23_8ada_b149_8fa3fd341b70 8b14d6df_29e1_d984_6a2a_6e2bb0e2e4b2["awrap_model_call()"] 2e11e37c_8880_df9b_8469_c973104f6b4a -->|calls| 8b14d6df_29e1_d984_6a2a_6e2bb0e2e4b2 style 2e11e37c_8880_df9b_8469_c973104f6b4a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py lines 1382–1403
async def test_async_model_with_middleware(self) -> None:
"""Test that wrap_model_call works with async model execution."""
log = []
class LoggingMiddleware(AgentMiddleware):
async def awrap_model_call(
self,
request: ModelRequest,
handler: Callable[[ModelRequest], Awaitable[ModelResponse]],
) -> ModelCallResult:
log.append("before")
result = await handler(request)
log.append("after")
return result
model = GenericFakeChatModel(messages=iter([AIMessage(content="Async response")]))
agent = create_agent(model=model, middleware=[LoggingMiddleware()])
result = await agent.ainvoke({"messages": [HumanMessage("Test")]})
assert log == ["before", "after"]
assert result["messages"][1].content == "Async response"
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does test_async_model_with_middleware() do?
test_async_model_with_middleware() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py.
Where is test_async_model_with_middleware() defined?
test_async_model_with_middleware() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py at line 1382.
What does test_async_model_with_middleware() call?
test_async_model_with_middleware() calls 1 function(s): awrap_model_call.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free