Home / Function/ test_appends_to_existing_system_prompt() — langchain Function Reference

test_appends_to_existing_system_prompt() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  b1e96abb_f27e_1949_b2e6_5a7a7198fb24["test_appends_to_existing_system_prompt()"]
  d2f3bc2a_72aa_59d0_8558_330793eda010["test_todo.py"]
  b1e96abb_f27e_1949_b2e6_5a7a7198fb24 -->|defined in| d2f3bc2a_72aa_59d0_8558_330793eda010
  985809c4_2504_4ccb_3f22_07707d600f19["_make_request()"]
  b1e96abb_f27e_1949_b2e6_5a7a7198fb24 -->|calls| 985809c4_2504_4ccb_3f22_07707d600f19
  style b1e96abb_f27e_1949_b2e6_5a7a7198fb24 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_todo.py lines 104–126

def test_appends_to_existing_system_prompt() -> None:
    """Test that middleware appends to existing system prompt."""
    existing_prompt = "You are a helpful assistant."
    middleware = TodoListMiddleware()
    request = _make_request(system_prompt=existing_prompt)

    captured_request = None

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

    middleware.wrap_model_call(request, mock_handler)

    # System prompt should contain both in the modified request passed to handler
    assert captured_request is not None
    assert captured_request.system_prompt is not None
    assert existing_prompt in captured_request.system_prompt
    assert "write_todos" in captured_request.system_prompt
    assert captured_request.system_prompt.startswith(existing_prompt)
    # Original request should be unchanged
    assert request.system_prompt == existing_prompt

Domain

Subdomains

Frequently Asked Questions

What does test_appends_to_existing_system_prompt() do?
test_appends_to_existing_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_appends_to_existing_system_prompt() defined?
test_appends_to_existing_system_prompt() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_todo.py at line 104.
What does test_appends_to_existing_system_prompt() call?
test_appends_to_existing_system_prompt() 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