Home / Class/ TestCommandGotoDisallowed Class — langchain Architecture

TestCommandGotoDisallowed Class — langchain Architecture

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

Entity Profile

Dependency Diagram

graph TD
  0811c9dc_363c_1da5_36f1_ed144a859bff["TestCommandGotoDisallowed"]
  949c7cf4_56fe_f3b4_cd89_9631a7e9cb1e["AgentMiddleware"]
  0811c9dc_363c_1da5_36f1_ed144a859bff -->|extends| 949c7cf4_56fe_f3b4_cd89_9631a7e9cb1e
  08361e76_a995_1e57_f200_e292474e2f00["test_wrap_model_call_state_update.py"]
  0811c9dc_363c_1da5_36f1_ed144a859bff -->|defined in| 08361e76_a995_1e57_f200_e292474e2f00
  5ac7c843_de0c_91d3_2caf_bb84b25e5c15["test_command_goto_raises_not_implemented()"]
  0811c9dc_363c_1da5_36f1_ed144a859bff -->|method| 5ac7c843_de0c_91d3_2caf_bb84b25e5c15
  57646d14_7858_b2d8_19bc_a8c0b48b57df["test_async_command_goto_raises_not_implemented()"]
  0811c9dc_363c_1da5_36f1_ed144a859bff -->|method| 57646d14_7858_b2d8_19bc_a8c0b48b57df

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call_state_update.py lines 782–825

class TestCommandGotoDisallowed:
    """Test that Command goto raises NotImplementedError in wrap_model_call."""

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

        class GotoMiddleware(AgentMiddleware):
            def wrap_model_call(
                self,
                request: ModelRequest,
                handler: Callable[[ModelRequest], ModelResponse],
            ) -> ExtendedModelResponse:
                response = handler(request)
                return ExtendedModelResponse(
                    model_response=response,
                    command=Command(goto="__end__"),
                )

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

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

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

        class AsyncGotoMiddleware(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(goto="tools"),
                )

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

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

Extends

Frequently Asked Questions

What is the TestCommandGotoDisallowed class?
TestCommandGotoDisallowed 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 TestCommandGotoDisallowed defined?
TestCommandGotoDisallowed is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call_state_update.py at line 782.
What does TestCommandGotoDisallowed extend?
TestCommandGotoDisallowed extends AgentMiddleware.

Analyze Your Own Codebase

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

Try Supermodel Free