__init__() — langchain Function Reference
Architecture documentation for the __init__() function in human_in_the_loop.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 4590d195_e88c_0828_70fa_70775b1c6825["__init__()"] b706912e_28f0_afbf_eb10_723aa3e74c52["HumanInTheLoopMiddleware"] 4590d195_e88c_0828_70fa_70775b1c6825 -->|defined in| b706912e_28f0_afbf_eb10_723aa3e74c52 style 4590d195_e88c_0828_70fa_70775b1c6825 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py lines 170–208
def __init__(
self,
interrupt_on: dict[str, bool | InterruptOnConfig],
*,
description_prefix: str = "Tool execution requires approval",
) -> None:
"""Initialize the human in the loop middleware.
Args:
interrupt_on: Mapping of tool name to allowed actions.
If a tool doesn't have an entry, it's auto-approved by default.
* `True` indicates all decisions are allowed: approve, edit, and reject.
* `False` indicates that the tool is auto-approved.
* `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.
description_prefix: The prefix to use when constructing action requests.
This is used to provide context about the tool call and the action being
requested.
Not used if a tool has a `description` in its `InterruptOnConfig`.
"""
super().__init__()
resolved_configs: dict[str, InterruptOnConfig] = {}
for tool_name, tool_config in interrupt_on.items():
if isinstance(tool_config, bool):
if tool_config is True:
resolved_configs[tool_name] = InterruptOnConfig(
allowed_decisions=["approve", "edit", "reject"]
)
elif tool_config.get("allowed_decisions"):
resolved_configs[tool_name] = tool_config
self.interrupt_on = resolved_configs
self.description_prefix = description_prefix
Domain
Subdomains
Source
Frequently Asked Questions
What does __init__() do?
__init__() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py.
Where is __init__() defined?
__init__() is defined in libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py at line 170.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free