test_both_sync_and_async_middleware_uses_appropriate_path() — langchain Function Reference
Architecture documentation for the test_both_sync_and_async_middleware_uses_appropriate_path() function in test_sync_async_wrappers.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 085ea1fc_65a5_c911_c88a_3d6da9d30edd["test_both_sync_and_async_middleware_uses_appropriate_path()"] dcfb9efa_1e8c_d646_a0b4_9a9d7afddd2c["TestSyncAsyncMiddlewareComposition"] 085ea1fc_65a5_c911_c88a_3d6da9d30edd -->|defined in| dcfb9efa_1e8c_d646_a0b4_9a9d7afddd2c b32ae1d3_dc67_5e65_9233_c87c7775379d["wrap_tool_call()"] 085ea1fc_65a5_c911_c88a_3d6da9d30edd -->|calls| b32ae1d3_dc67_5e65_9233_c87c7775379d 83212f91_58cd_0efb_7c70_b1044be4f13c["awrap_tool_call()"] 085ea1fc_65a5_c911_c88a_3d6da9d30edd -->|calls| 83212f91_58cd_0efb_7c70_b1044be4f13c style 085ea1fc_65a5_c911_c88a_3d6da9d30edd fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_sync_async_wrappers.py lines 175–217
def test_both_sync_and_async_middleware_uses_appropriate_path(self) -> None:
"""Middleware with both sync and async uses correct implementation per path."""
call_log = []
class BothSyncAsyncMiddleware(AgentMiddleware):
def wrap_tool_call(
self,
request: ToolCallRequest,
handler: Callable[[ToolCallRequest], ToolMessage | Command[Any]],
) -> ToolMessage | Command[Any]:
call_log.append("sync_called")
return handler(request)
async def awrap_tool_call(
self,
request: ToolCallRequest,
handler: Callable[[ToolCallRequest], Awaitable[ToolMessage | Command[Any]]],
) -> ToolMessage | Command[Any]:
call_log.append("async_called")
return await handler(request)
model = FakeToolCallingModel(
tool_calls=[
[ToolCall(name="search", args={"query": "test"}, id="1")],
[],
]
)
agent = create_agent(
model=model,
tools=[search],
middleware=[BothSyncAsyncMiddleware()],
checkpointer=InMemorySaver(),
)
# Sync path
call_log.clear()
agent.invoke(
{"messages": [HumanMessage("Search")]},
{"configurable": {"thread_id": "test1"}},
)
assert "sync_called" in call_log
assert "async_called" not in call_log
Domain
Subdomains
Source
Frequently Asked Questions
What does test_both_sync_and_async_middleware_uses_appropriate_path() do?
test_both_sync_and_async_middleware_uses_appropriate_path() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_sync_async_wrappers.py.
Where is test_both_sync_and_async_middleware_uses_appropriate_path() defined?
test_both_sync_and_async_middleware_uses_appropriate_path() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_sync_async_wrappers.py at line 175.
What does test_both_sync_and_async_middleware_uses_appropriate_path() call?
test_both_sync_and_async_middleware_uses_appropriate_path() calls 2 function(s): awrap_tool_call, wrap_tool_call.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free