Home / Function/ test_async_memory_middleware_merges_system_message() — langchain Function Reference

test_async_memory_middleware_merges_system_message() — langchain Function Reference

Architecture documentation for the test_async_memory_middleware_merges_system_message() function in test_anthropic_tools.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  3034a6a3_df9f_e3ac_5766_7f19305d5fb0["test_async_memory_middleware_merges_system_message()"]
  ba56b04d_d9f3_fb70_3b66_9b0ee09cb319["TestSystemMessageHandling"]
  3034a6a3_df9f_e3ac_5766_7f19305d5fb0 -->|defined in| ba56b04d_d9f3_fb70_3b66_9b0ee09cb319
  style 3034a6a3_df9f_e3ac_5766_7f19305d5fb0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/tests/unit_tests/middleware/test_anthropic_tools.py lines 385–417

    async def test_async_memory_middleware_merges_system_message(self) -> None:
        """Test async memory middleware merges with existing system message."""
        from langchain.agents.middleware.types import ModelRequest

        middleware = StateClaudeMemoryMiddleware()

        existing_message = SystemMessage("You are a helpful assistant.")
        request = ModelRequest(
            model=MagicMock(),
            messages=[],
            system_message=existing_message,
            tool_choice=None,
            tools=[],
            response_format=None,
            state={"messages": []},
            runtime=MagicMock(),
        )

        captured_request = None

        async def handler(req: ModelRequest) -> MagicMock:
            nonlocal captured_request
            captured_request = req
            return MagicMock()

        await middleware.awrap_model_call(request, handler)

        # System message should be merged
        assert captured_request is not None
        assert captured_request.system_message is not None
        assert isinstance(captured_request.system_message, SystemMessage)
        assert "You are a helpful assistant." in captured_request.system_message.text
        assert "MEMORY PROTOCOL" in captured_request.system_message.text

Domain

Subdomains

Frequently Asked Questions

What does test_async_memory_middleware_merges_system_message() do?
test_async_memory_middleware_merges_system_message() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/unit_tests/middleware/test_anthropic_tools.py.
Where is test_async_memory_middleware_merges_system_message() defined?
test_async_memory_middleware_merges_system_message() is defined in libs/partners/anthropic/tests/unit_tests/middleware/test_anthropic_tools.py at line 385.

Analyze Your Own Codebase

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

Try Supermodel Free