From 700d42075544f6c47a2651410a7419c6c8b89636 Mon Sep 17 00:00:00 2001 From: Nick Hollon Date: Tue, 12 May 2026 15:46:34 -0700 Subject: [PATCH] docs(langchain): document `interrupt_when` on HITL middleware --- .../langchain/agents/middleware/human_in_the_loop.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py b/libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py index edf7807b6ce..91f801570ce 100644 --- a/libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py +++ b/libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py @@ -232,8 +232,15 @@ class HumanInTheLoopMiddleware(AgentMiddleware[StateT, ContextT, ResponseT]): * `InterruptOnConfig` indicates the specific decisions allowed for this tool. - The `InterruptOnConfig` can include a `description` field (`str` or - `Callable`) for custom formatting of the interrupt description. + The `InterruptOnConfig` can include: + - a `description` field (`str` or `Callable`) for custom formatting + of the interrupt description, and + - an `interrupt_when` predicate `(ToolCall, ToolRuntime) -> bool`. + When set, only calls for which the predicate returns `True` + interrupt. Calls returning `False` are auto-approved exactly as + if the tool were not listed in `interrupt_on`. Predicates must be + synchronous and deterministic (LangGraph interrupt replay re-runs + them on resume). description_prefix: The prefix to use when constructing action requests. This is used to provide context about the tool call and the action being