Home / Class/ TestCommandGraphDisallowed Class — langchain Architecture

TestCommandGraphDisallowed Class — langchain Architecture

Architecture documentation for the TestCommandGraphDisallowed class in test_wrap_model_call_state_update.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  4750c4b0_13f7_74c3_9560_c6bec7226ba5["TestCommandGraphDisallowed"]
  949c7cf4_56fe_f3b4_cd89_9631a7e9cb1e["AgentMiddleware"]
  4750c4b0_13f7_74c3_9560_c6bec7226ba5 -->|extends| 949c7cf4_56fe_f3b4_cd89_9631a7e9cb1e
  08361e76_a995_1e57_f200_e292474e2f00["test_wrap_model_call_state_update.py"]
  4750c4b0_13f7_74c3_9560_c6bec7226ba5 -->|defined in| 08361e76_a995_1e57_f200_e292474e2f00
  871e5126_c3e7_9421_9036_a6c954911ba8["test_command_graph_raises_not_implemented()"]
  4750c4b0_13f7_74c3_9560_c6bec7226ba5 -->|method| 871e5126_c3e7_9421_9036_a6c954911ba8
  978057bc_90cb_f2b7_7aa2_764f7bb38153["test_async_command_graph_raises_not_implemented()"]
  4750c4b0_13f7_74c3_9560_c6bec7226ba5 -->|method| 978057bc_90cb_f2b7_7aa2_764f7bb38153

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call_state_update.py lines 874–917

class TestCommandGraphDisallowed:
    """Test that Command graph raises NotImplementedError in wrap_model_call."""

    def test_command_graph_raises_not_implemented(self) -> None:
        """Command with graph in wrap_model_call raises NotImplementedError."""

        class GraphMiddleware(AgentMiddleware):
            def wrap_model_call(
                self,
                request: ModelRequest,
                handler: Callable[[ModelRequest], ModelResponse],
            ) -> ExtendedModelResponse:
                response = handler(request)
                return ExtendedModelResponse(
                    model_response=response,
                    command=Command(graph=Command.PARENT, update={"messages": []}),
                )

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

        with pytest.raises(NotImplementedError, match="Command graph is not yet supported"):
            agent.invoke({"messages": [HumanMessage(content="Hi")]})

    async def test_async_command_graph_raises_not_implemented(self) -> None:
        """Async: Command with graph in wrap_model_call raises NotImplementedError."""

        class AsyncGraphMiddleware(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(graph=Command.PARENT, update={"messages": []}),
                )

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

        with pytest.raises(NotImplementedError, match="Command graph is not yet supported"):
            await agent.ainvoke({"messages": [HumanMessage(content="Hi")]})

Extends

Frequently Asked Questions

What is the TestCommandGraphDisallowed class?
TestCommandGraphDisallowed is a class in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call_state_update.py.
Where is TestCommandGraphDisallowed defined?
TestCommandGraphDisallowed is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call_state_update.py at line 874.
What does TestCommandGraphDisallowed extend?
TestCommandGraphDisallowed extends AgentMiddleware.

Analyze Your Own Codebase

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

Try Supermodel Free