test_human_in_the_loop_middleware_disallowed_action() — langchain Function Reference
Architecture documentation for the test_human_in_the_loop_middleware_disallowed_action() function in test_human_in_the_loop.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD f3c60780_1c16_2089_8385_6dc7adbf717f["test_human_in_the_loop_middleware_disallowed_action()"] b9ab5ab1_a37b_d0e1_974a_34ca8a76a788["test_human_in_the_loop.py"] f3c60780_1c16_2089_8385_6dc7adbf717f -->|defined in| b9ab5ab1_a37b_d0e1_974a_34ca8a76a788 style f3c60780_1c16_2089_8385_6dc7adbf717f 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 325–367
def test_human_in_the_loop_middleware_disallowed_action() -> None:
"""Test HumanInTheLoopMiddleware with action not allowed by tool config."""
# edit is not allowed by tool config
middleware = HumanInTheLoopMiddleware(
interrupt_on={"test_tool": {"allowed_decisions": ["approve", "reject"]}}
)
ai_message = AIMessage(
content="I'll help you",
tool_calls=[{"name": "test_tool", "args": {"input": "test"}, "id": "1"}],
)
state = AgentState[Any](messages=[HumanMessage(content="Hello"), ai_message])
def mock_disallowed_action(_: Any) -> dict[str, Any]:
return {
"decisions": [
{
"type": "edit",
"edited_action": Action(
name="test_tool",
args={"input": "modified"},
),
}
]
}
with (
patch(
"langchain.agents.middleware.human_in_the_loop.interrupt",
side_effect=mock_disallowed_action,
),
pytest.raises(
ValueError,
match=re.escape(
"Unexpected human decision: {'type': 'edit', 'edited_action': "
"{'name': 'test_tool', 'args': {'input': 'modified'}}}. "
"Decision type 'edit' is not allowed for tool 'test_tool'. "
"Expected one of ['approve', 'reject'] based on the tool's "
"configuration."
),
),
):
middleware.after_model(state, Runtime())
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_human_in_the_loop_middleware_disallowed_action() do?
test_human_in_the_loop_middleware_disallowed_action() 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_disallowed_action() defined?
test_human_in_the_loop_middleware_disallowed_action() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_human_in_the_loop.py at line 325.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free