Home / Function/ test_async_inner_command_propagated() — langchain Function Reference

test_async_inner_command_propagated() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  e4a9b953_7f2b_c6fa_b196_05f6e3c3dd78["test_async_inner_command_propagated()"]
  0f39b70e_2926_951e_853d_3344387750a6["TestAsyncComposition"]
  e4a9b953_7f2b_c6fa_b196_05f6e3c3dd78 -->|defined in| 0f39b70e_2926_951e_853d_3344387750a6
  style e4a9b953_7f2b_c6fa_b196_05f6e3c3dd78 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 642–686

    async def test_async_inner_command_propagated(self) -> None:
        """Async: inner middleware's ExtendedModelResponse command is propagated."""

        class OuterMiddleware(AgentMiddleware):
            async def awrap_model_call(
                self,
                request: ModelRequest,
                handler: Callable[[ModelRequest], Awaitable[ModelResponse]],
            ) -> ModelResponse:
                response = await handler(request)
                assert isinstance(response, ModelResponse)
                return response

        class InnerMiddleware(AgentMiddleware):
            async def awrap_model_call(
                self,
                request: ModelRequest,
                handler: Callable[[ModelRequest], Awaitable[ModelResponse]],
            ) -> ExtendedModelResponse:
                response = await handler(request)
                return ExtendedModelResponse(
                    model_response=response,
                    command=Command(
                        update={
                            "messages": [
                                HumanMessage(content="Inner msg", id="inner"),
                            ]
                        }
                    ),
                )

        model = GenericFakeChatModel(messages=iter([AIMessage(content="Hello")]))
        agent = create_agent(
            model=model,
            middleware=[OuterMiddleware(), InnerMiddleware()],
        )

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

        # Model messages + inner command messages (additive)
        messages = result["messages"]
        assert len(messages) == 3
        assert messages[0].content == "Hi"
        assert messages[1].content == "Hello"
        assert messages[2].content == "Inner msg"

Domain

Subdomains

Frequently Asked Questions

What does test_async_inner_command_propagated() do?
test_async_inner_command_propagated() 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_inner_command_propagated() defined?
test_async_inner_command_propagated() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call_state_update.py at line 642.

Analyze Your Own Codebase

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

Try Supermodel Free