Home / Function/ test_decorator_sync_only_works_both_paths() — langchain Function Reference

test_decorator_sync_only_works_both_paths() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  970c0868_f0ff_7c7b_290f_d01cd81b3b7c["test_decorator_sync_only_works_both_paths()"]
  dcfb9efa_1e8c_d646_a0b4_9a9d7afddd2c["TestSyncAsyncMiddlewareComposition"]
  970c0868_f0ff_7c7b_290f_d01cd81b3b7c -->|defined in| dcfb9efa_1e8c_d646_a0b4_9a9d7afddd2c
  style 970c0868_f0ff_7c7b_290f_d01cd81b3b7c 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 361–394

    def test_decorator_sync_only_works_both_paths(self) -> None:
        """Decorator-created sync-only middleware works on both paths."""
        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(),
        )

        # Sync path
        call_log.clear()
        result = agent.invoke(
            {"messages": [HumanMessage("Search")]},
            {"configurable": {"thread_id": "test1"}},
        )
        assert "decorator_sync" in call_log
        assert len([m for m in result["messages"] if isinstance(m, ToolMessage)]) == 1

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free