BothSyncAsyncMiddleware Class — langchain Architecture
Architecture documentation for the BothSyncAsyncMiddleware class in test_sync_async_wrappers.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 12c255c9_9bfa_8c4e_6f28_718fcd84aaa3["BothSyncAsyncMiddleware"] 949c7cf4_56fe_f3b4_cd89_9631a7e9cb1e["AgentMiddleware"] 12c255c9_9bfa_8c4e_6f28_718fcd84aaa3 -->|extends| 949c7cf4_56fe_f3b4_cd89_9631a7e9cb1e cf6b674b_7780_33c8_7bab_ae3fff37b276["test_sync_async_wrappers.py"] 12c255c9_9bfa_8c4e_6f28_718fcd84aaa3 -->|defined in| cf6b674b_7780_33c8_7bab_ae3fff37b276 b32ae1d3_dc67_5e65_9233_c87c7775379d["wrap_tool_call()"] 12c255c9_9bfa_8c4e_6f28_718fcd84aaa3 -->|method| b32ae1d3_dc67_5e65_9233_c87c7775379d 83212f91_58cd_0efb_7c70_b1044be4f13c["awrap_tool_call()"] 12c255c9_9bfa_8c4e_6f28_718fcd84aaa3 -->|method| 83212f91_58cd_0efb_7c70_b1044be4f13c
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_sync_async_wrappers.py lines 179–194
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)
Extends
Source
Frequently Asked Questions
What is the BothSyncAsyncMiddleware class?
BothSyncAsyncMiddleware is a class in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_sync_async_wrappers.py.
Where is BothSyncAsyncMiddleware defined?
BothSyncAsyncMiddleware is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_sync_async_wrappers.py at line 179.
What does BothSyncAsyncMiddleware extend?
BothSyncAsyncMiddleware extends AgentMiddleware.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free