Home / Function/ test_decorator_sync_only_raises_on_async_path() — langchain Function Reference

test_decorator_sync_only_raises_on_async_path() — langchain Function Reference

Architecture documentation for the test_decorator_sync_only_raises_on_async_path() function in test_sync_async_wrappers.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  675978b5_386b_8104_3bec_cf42667592eb["test_decorator_sync_only_raises_on_async_path()"]
  dcfb9efa_1e8c_d646_a0b4_9a9d7afddd2c["TestSyncAsyncMiddlewareComposition"]
  675978b5_386b_8104_3bec_cf42667592eb -->|defined in| dcfb9efa_1e8c_d646_a0b4_9a9d7afddd2c
  style 675978b5_386b_8104_3bec_cf42667592eb 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 396–427

    async def test_decorator_sync_only_raises_on_async_path(self) -> None:
        """Decorator-created sync-only middleware raises on async path."""
        call_log = []

        @wrap_tool_call
        def my_wrapper(
            request: ToolCallRequest,
            handler: Callable[[ToolCallRequest], ToolMessage | Command[Any]],
        ) -> ToolMessage | Command[Any]:
            call_log.append("decorator_sync")
            return handler(request)

        model = FakeToolCallingModel(
            tool_calls=[
                [ToolCall(name="search", args={"query": "test"}, id="1")],
                [],
            ]
        )

        agent = create_agent(
            model=model,
            tools=[search],
            middleware=[my_wrapper],
            checkpointer=InMemorySaver(),
        )

        # Should raise NotImplementedError because sync-only decorator doesn't support async path
        with pytest.raises(NotImplementedError):
            await agent.ainvoke(
                {"messages": [HumanMessage("Search")]},
                {"configurable": {"thread_id": "test2"}},
            )

Domain

Subdomains

Frequently Asked Questions

What does test_decorator_sync_only_raises_on_async_path() do?
test_decorator_sync_only_raises_on_async_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_decorator_sync_only_raises_on_async_path() defined?
test_decorator_sync_only_raises_on_async_path() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_sync_async_wrappers.py at line 396.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free