Home / Function/ test_decorator_with_async_agent() — langchain Function Reference

test_decorator_with_async_agent() — langchain Function Reference

Architecture documentation for the test_decorator_with_async_agent() function in test_wrap_model_call.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  103117dd_d442_12c9_71a5_e5d722f90eff["test_decorator_with_async_agent()"]
  75e76fa8_8e23_8ada_b149_8fa3fd341b70["TestAsyncWrapModelCall"]
  103117dd_d442_12c9_71a5_e5d722f90eff -->|defined in| 75e76fa8_8e23_8ada_b149_8fa3fd341b70
  style 103117dd_d442_12c9_71a5_e5d722f90eff 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 1443–1463

    async def test_decorator_with_async_agent(self) -> None:
        """Test that decorated middleware works with async agent invocation."""
        call_log = []

        @wrap_model_call
        async def logging_middleware(
            request: ModelRequest,
            handler: Callable[[ModelRequest], Awaitable[ModelResponse]],
        ) -> ModelCallResult:
            call_log.append("before")
            result = await handler(request)
            call_log.append("after")
            return result

        model = GenericFakeChatModel(messages=iter([AIMessage(content="Async response")]))
        agent = create_agent(model=model, middleware=[logging_middleware])

        result = await agent.ainvoke({"messages": [HumanMessage("Test")]})

        assert call_log == ["before", "after"]
        assert result["messages"][1].content == "Async response"

Domain

Subdomains

Frequently Asked Questions

What does test_decorator_with_async_agent() do?
test_decorator_with_async_agent() 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_decorator_with_async_agent() defined?
test_decorator_with_async_agent() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py at line 1443.

Analyze Your Own Codebase

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

Try Supermodel Free