Skip to content

The agent engineering platform.

fix(langchain): correct `InterruptOnConfig` documentation (#40140)

Champions Zhangc3acb40e28ae
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 c5973be035..ebdfb2ddbc 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
@@ -166,7 +166,7 @@ class InterruptOnConfig(TypedDict):
Example:
```python
# Static string description
- config = ToolConfig(
+ config = InterruptOnConfig(
allowed_decisions=["approve", "reject"],
description="Please review this tool execution"
)
@@ -196,12 +196,14 @@ class InterruptOnConfig(TypedDict):
"""Optional predicate controlling whether to interrupt for a given tool call.
Receives a `ToolCallRequest` and returns `True` to interrupt or `False` to
- auto-approve. Works in both `"batch"` and `"per_call"` modes.
-
- In `"batch"` mode the request is constructed with `tool=None` and
- `runtime` set to the node-level `Runtime` (not a `ToolRuntime`), so
- `request.runtime.tool_call_id` and `request.runtime.tools` are not available.
- In `"per_call"` mode the full `ToolCallRequest` from `wrap_tool_call` is passed.
+ auto-approve. The predicate is called during `after_model` before the tool
+ call is added to the batched human-in-the-loop request.
+
+ The request is constructed with `tool=None` and a new `ToolRuntime`. The
+ `ToolRuntime` copies `context`, `store`, `stream_writer`, `execution_info`,
+ and `server_info` from the node-level `Runtime`, while `tool_call_id` is
+ populated from the current tool call. The `tools` argument is not supplied,
+ so it uses its default empty list.
Example:
```python
diff --git a/libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_human_in_the_loop.py b/libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_human_in_the_loop.py
index d940ef507d..522153adcc 100644
--- a/libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_human_in_the_loop.py
+++ b/libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_human_in_the_loop.py
@@ -1124,6 +1124,7 @@ def test_when_predicate_receives_correct_args() -> None:
assert req.state is state
assert isinstance(req.runtime, ToolRuntime)
assert req.runtime.tool_call_id == "tc-1"
+ assert req.runtime.tools == []
assert req.runtime.state is state
assert req.runtime.context is runtime.context
assert req.runtime.store is runtime.store