Home / Function/ test_todo_middleware_custom_system_prompt() — langchain Function Reference

test_todo_middleware_custom_system_prompt() — langchain Function Reference

Architecture documentation for the test_todo_middleware_custom_system_prompt() function in test_todo.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  afac043d_2f64_c5ac_cd91_1bfbbdf894d1["test_todo_middleware_custom_system_prompt()"]
  d2f3bc2a_72aa_59d0_8558_330793eda010["test_todo.py"]
  afac043d_2f64_c5ac_cd91_1bfbbdf894d1 -->|defined in| d2f3bc2a_72aa_59d0_8558_330793eda010
  style afac043d_2f64_c5ac_cd91_1bfbbdf894d1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_todo.py lines 196–229

def test_todo_middleware_custom_system_prompt() -> None:
    """Test that TodoListMiddleware can be initialized with custom system prompt."""
    custom_system_prompt = "Custom todo system prompt for testing"
    middleware = TodoListMiddleware(system_prompt=custom_system_prompt)
    model = FakeToolCallingModel()

    state: PlanningState = {"messages": [HumanMessage(content="Hello")]}

    request = ModelRequest(
        model=model,
        system_prompt="Original prompt",
        messages=[HumanMessage(content="Hello")],
        tool_choice=None,
        tools=[],
        response_format=None,
        model_settings={},
        state=state,
        runtime=cast("Runtime", object()),
    )

    captured_request = None

    def mock_handler(req: ModelRequest) -> ModelResponse:
        nonlocal captured_request
        captured_request = req
        return ModelResponse(result=[AIMessage(content="mock response")])

    # Call wrap_model_call to trigger the middleware logic
    middleware.wrap_model_call(request, mock_handler)
    # Check that the modified request passed to handler has the expected prompt
    assert captured_request is not None
    assert captured_request.system_prompt == f"Original prompt\n\n{custom_system_prompt}"
    # Original request should be unchanged
    assert request.system_prompt == "Original prompt"

Domain

Subdomains

Frequently Asked Questions

What does test_todo_middleware_custom_system_prompt() do?
test_todo_middleware_custom_system_prompt() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_todo.py.
Where is test_todo_middleware_custom_system_prompt() defined?
test_todo_middleware_custom_system_prompt() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_todo.py at line 196.

Analyze Your Own Codebase

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

Try Supermodel Free