Home / Function/ test_human_in_the_loop_middleware_mixed_auto_approved_and_interrupt() — langchain Function Reference

test_human_in_the_loop_middleware_mixed_auto_approved_and_interrupt() — langchain Function Reference

Architecture documentation for the test_human_in_the_loop_middleware_mixed_auto_approved_and_interrupt() function in test_human_in_the_loop.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  fb920384_edba_3e02_9aa4_6370ff510af3["test_human_in_the_loop_middleware_mixed_auto_approved_and_interrupt()"]
  b9ab5ab1_a37b_d0e1_974a_34ca8a76a788["test_human_in_the_loop.py"]
  fb920384_edba_3e02_9aa4_6370ff510af3 -->|defined in| b9ab5ab1_a37b_d0e1_974a_34ca8a76a788
  style fb920384_edba_3e02_9aa4_6370ff510af3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_human_in_the_loop.py lines 370–398

def test_human_in_the_loop_middleware_mixed_auto_approved_and_interrupt() -> None:
    """Test HumanInTheLoopMiddleware with mix of auto-approved and interrupt tools."""
    middleware = HumanInTheLoopMiddleware(
        interrupt_on={"interrupt_tool": {"allowed_decisions": ["approve", "edit", "reject"]}}
    )

    ai_message = AIMessage(
        content="I'll help you",
        tool_calls=[
            {"name": "auto_tool", "args": {"input": "auto"}, "id": "1"},
            {"name": "interrupt_tool", "args": {"input": "interrupt"}, "id": "2"},
        ],
    )
    state = AgentState[Any](messages=[HumanMessage(content="Hello"), ai_message])

    def mock_accept(_: Any) -> dict[str, Any]:
        return {"decisions": [{"type": "approve"}]}

    with patch("langchain.agents.middleware.human_in_the_loop.interrupt", side_effect=mock_accept):
        result = middleware.after_model(state, Runtime())
        assert result is not None
        assert "messages" in result
        assert len(result["messages"]) == 1

        updated_ai_message = result["messages"][0]
        # Should have both tools: auto-approved first, then interrupt tool
        assert len(updated_ai_message.tool_calls) == 2
        assert updated_ai_message.tool_calls[0]["name"] == "auto_tool"
        assert updated_ai_message.tool_calls[1]["name"] == "interrupt_tool"

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free