Home / Function/ test_middleware_with_content_blocks() — langchain Function Reference

test_middleware_with_content_blocks() — langchain Function Reference

Architecture documentation for the test_middleware_with_content_blocks() function in test_system_message.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  1c0c4369_46e0_d9e8_89b6_79351f4854c0["test_middleware_with_content_blocks()"]
  71806697_b367_06d3_c3dc_8764efaf8550["TestDynamicSystemPromptMiddleware"]
  1c0c4369_46e0_d9e8_89b6_79351f4854c0 -->|defined in| 71806697_b367_06d3_c3dc_8764efaf8550
  56f7d1ae_98db_01a6_dc7e_786fe86dd0c4["_make_request()"]
  1c0c4369_46e0_d9e8_89b6_79351f4854c0 -->|calls| 56f7d1ae_98db_01a6_dc7e_786fe86dd0c4
  style 1c0c4369_46e0_d9e8_89b6_79351f4854c0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/test_system_message.py lines 835–857

    def test_middleware_with_content_blocks(self) -> None:
        """Test middleware creating SystemMessage with content blocks."""

        def content_blocks_middleware(request: ModelRequest) -> SystemMessage:
            """Create SystemMessage with content blocks including cache control."""
            return SystemMessage(
                content=[
                    {"type": "text", "text": "Base instructions"},
                    {
                        "type": "text",
                        "text": "Cached instructions",
                        "cache_control": {"type": "ephemeral"},
                    },
                ]
            )

        request = _make_request()
        new_system_message = content_blocks_middleware(request)

        assert isinstance(new_system_message.content_blocks, list)
        assert len(new_system_message.content_blocks) == 2
        assert new_system_message.content_blocks[0].get("text") == "Base instructions"
        assert new_system_message.content_blocks[1].get("cache_control") == {"type": "ephemeral"}

Domain

Subdomains

Frequently Asked Questions

What does test_middleware_with_content_blocks() do?
test_middleware_with_content_blocks() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/test_system_message.py.
Where is test_middleware_with_content_blocks() defined?
test_middleware_with_content_blocks() is defined in libs/langchain_v1/tests/unit_tests/agents/test_system_message.py at line 835.
What does test_middleware_with_content_blocks() call?
test_middleware_with_content_blocks() calls 1 function(s): _make_request.

Analyze Your Own Codebase

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

Try Supermodel Free