Home / Function/ test_ai_message_return_unchanged() — langchain Function Reference

test_ai_message_return_unchanged() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  b4fa90a3_123c_c3a9_1c8c_a21800dc32e8["test_ai_message_return_unchanged()"]
  2bf07a68_4a56_38b0_435c_b9917d8b0fd3["TestBackwardsCompatibility"]
  b4fa90a3_123c_c3a9_1c8c_a21800dc32e8 -->|defined in| 2bf07a68_4a56_38b0_435c_b9917d8b0fd3
  style b4fa90a3_123c_c3a9_1c8c_a21800dc32e8 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 220–237

    def test_ai_message_return_unchanged(self) -> None:
        """Existing middleware returning AIMessage works identically."""

        class ShortCircuitMiddleware(AgentMiddleware):
            def wrap_model_call(
                self,
                request: ModelRequest,
                handler: Callable[[ModelRequest], ModelResponse],
            ) -> AIMessage:
                return AIMessage(content="Short-circuited")

        model = GenericFakeChatModel(messages=iter([AIMessage(content="Should not appear")]))
        agent = create_agent(model=model, middleware=[ShortCircuitMiddleware()])

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

        assert len(result["messages"]) == 2
        assert result["messages"][1].content == "Short-circuited"

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free