Home / Function/ test_parallel_write_todos_calls_rejected_async() — langchain Function Reference

test_parallel_write_todos_calls_rejected_async() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  fd3d9ab4_dc04_139f_d450_56b7f27edf51["test_parallel_write_todos_calls_rejected_async()"]
  d2f3bc2a_72aa_59d0_8558_330793eda010["test_todo.py"]
  fd3d9ab4_dc04_139f_d450_56b7f27edf51 -->|defined in| d2f3bc2a_72aa_59d0_8558_330793eda010
  51077994_451d_5d5c_62d8_c5d5b714096b["_fake_runtime()"]
  fd3d9ab4_dc04_139f_d450_56b7f27edf51 -->|calls| 51077994_451d_5d5c_62d8_c5d5b714096b
  style fd3d9ab4_dc04_139f_d450_56b7f27edf51 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_todo.py lines 652–702

async def test_parallel_write_todos_calls_rejected_async() -> None:
    """Test async version - parallel write_todos calls are rejected with error messages."""
    middleware = TodoListMiddleware()

    # Create an AI message with two write_todos tool calls
    ai_message = AIMessage(
        content="I'll update the todos",
        tool_calls=[
            {
                "name": "write_todos",
                "args": {"todos": [{"content": "Task 1", "status": "pending"}]},
                "id": "call_1",
                "type": "tool_call",
            },
            {
                "name": "write_todos",
                "args": {"todos": [{"content": "Task 2", "status": "pending"}]},
                "id": "call_2",
                "type": "tool_call",
            },
        ],
    )

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

    # Call aafter_model hook
    result = await middleware.aafter_model(state, _fake_runtime())

    # Should return error messages
    assert result == {
        "messages": [
            ToolMessage(
                content=(
                    "Error: The `write_todos` tool should never be called multiple times "
                    "in parallel. Please call it only once per model invocation to update "
                    "the todo list."
                ),
                tool_call_id="call_1",
                status="error",
            ),
            ToolMessage(
                content=(
                    "Error: The `write_todos` tool should never be called multiple times "
                    "in parallel. Please call it only once per model invocation to update "
                    "the todo list."
                ),
                tool_call_id="call_2",
                status="error",
            ),
        ]
    }

Domain

Subdomains

Frequently Asked Questions

What does test_parallel_write_todos_calls_rejected_async() do?
test_parallel_write_todos_calls_rejected_async() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_todo.py.
Where is test_parallel_write_todos_calls_rejected_async() defined?
test_parallel_write_todos_calls_rejected_async() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_todo.py at line 652.
What does test_parallel_write_todos_calls_rejected_async() call?
test_parallel_write_todos_calls_rejected_async() calls 1 function(s): _fake_runtime.

Analyze Your Own Codebase

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

Try Supermodel Free