Home / Function/ test_command_structured_response_conflicts_with_model_response() — langchain Function Reference

test_command_structured_response_conflicts_with_model_response() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  b9c9a03c_fc16_a250_4e3b_00804123b967["test_command_structured_response_conflicts_with_model_response()"]
  32ccf275_216c_0c5f_4a10_07f3bc9d69a5["TestBasicCommand"]
  b9c9a03c_fc16_a250_4e3b_00804123b967 -->|defined in| 32ccf275_216c_0c5f_4a10_07f3bc9d69a5
  style b9c9a03c_fc16_a250_4e3b_00804123b967 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 84–113

    def test_command_structured_response_conflicts_with_model_response(self) -> None:
        """Command and model response both setting structured_response raises."""

        class OverrideMiddleware(AgentMiddleware):
            def wrap_model_call(
                self,
                request: ModelRequest,
                handler: Callable[[ModelRequest], ModelResponse],
            ) -> ExtendedModelResponse:
                response = handler(request)
                response_with_structured = ModelResponse(
                    result=response.result,
                    structured_response={"from": "model"},
                )
                return ExtendedModelResponse(
                    model_response=response_with_structured,
                    command=Command(
                        update={
                            "structured_response": {"from": "command"},
                        }
                    ),
                )

        model = GenericFakeChatModel(messages=iter([AIMessage(content="Model msg")]))
        agent = create_agent(model=model, middleware=[OverrideMiddleware()])

        # Two Commands both setting structured_response (a LastValue channel)
        # in the same step raises InvalidUpdateError
        with pytest.raises(InvalidUpdateError):
            agent.invoke({"messages": [HumanMessage("Hi")]})

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free