Home / Function/ test_async_decorator_command() — langchain Function Reference

test_async_decorator_command() — langchain Function Reference

Architecture documentation for the test_async_decorator_command() function in test_wrap_model_call_state_update.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  21fdde48_92a6_42c1_8af2_dfde67e600e1["test_async_decorator_command()"]
  62fed73a_37ab_9497_9ced_d00470614047["TestAsyncExtendedModelResponse"]
  21fdde48_92a6_42c1_8af2_dfde67e600e1 -->|defined in| 62fed73a_37ab_9497_9ced_d00470614047
  style 21fdde48_92a6_42c1_8af2_dfde67e600e1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call_state_update.py lines 281–309

    async def test_async_decorator_command(self) -> None:
        """@wrap_model_call async decorator returns ExtendedModelResponse with command."""

        @wrap_model_call
        async def command_middleware(
            request: ModelRequest,
            handler: Callable[[ModelRequest], Awaitable[ModelResponse]],
        ) -> ExtendedModelResponse:
            response = await handler(request)
            return ExtendedModelResponse(
                model_response=response,
                command=Command(
                    update={
                        "messages": [
                            HumanMessage(content="Decorator msg", id="dec"),
                        ]
                    }
                ),
            )

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

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

        messages = result["messages"]
        assert len(messages) == 3
        assert messages[1].content == "Async response"
        assert messages[2].content == "Decorator msg"

Domain

Subdomains

Frequently Asked Questions

What does test_async_decorator_command() do?
test_async_decorator_command() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call_state_update.py.
Where is test_async_decorator_command() defined?
test_async_decorator_command() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call_state_update.py at line 281.

Analyze Your Own Codebase

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

Try Supermodel Free