human_in_the_loop.py — langchain Source File
Architecture documentation for human_in_the_loop.py, a python file in the langchain codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 23036d87_b616_3e6b_013c_17cd312d2a62["human_in_the_loop.py"] feec1ec4_6917_867b_d228_b134d0ff8099["typing"] 23036d87_b616_3e6b_013c_17cd312d2a62 --> feec1ec4_6917_867b_d228_b134d0ff8099 9444498b_8066_55c7_b3a2_1d90c4162a32["langchain_core.messages"] 23036d87_b616_3e6b_013c_17cd312d2a62 --> 9444498b_8066_55c7_b3a2_1d90c4162a32 e07f6d54_afcc_052d_d33f_8ccdcc46f752["langgraph.runtime"] 23036d87_b616_3e6b_013c_17cd312d2a62 --> e07f6d54_afcc_052d_d33f_8ccdcc46f752 726d73c8_7999_511a_c1ec_4524fb1cc31a["langgraph.types"] 23036d87_b616_3e6b_013c_17cd312d2a62 --> 726d73c8_7999_511a_c1ec_4524fb1cc31a f85fae70_1011_eaec_151c_4083140ae9e5["typing_extensions"] 23036d87_b616_3e6b_013c_17cd312d2a62 --> f85fae70_1011_eaec_151c_4083140ae9e5 a681398d_ed44_c914_1a44_5d174223b069["langchain.agents.middleware.types"] 23036d87_b616_3e6b_013c_17cd312d2a62 --> a681398d_ed44_c914_1a44_5d174223b069 style 23036d87_b616_3e6b_013c_17cd312d2a62 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Human in the loop middleware."""
from typing import Any, Literal, Protocol
from langchain_core.messages import AIMessage, ToolCall, ToolMessage
from langgraph.runtime import Runtime
from langgraph.types import interrupt
from typing_extensions import NotRequired, TypedDict
from langchain.agents.middleware.types import (
AgentMiddleware,
AgentState,
ContextT,
ResponseT,
StateT,
)
class Action(TypedDict):
"""Represents an action with a name and args."""
name: str
"""The type or name of action being requested (e.g., `'add_numbers'`)."""
args: dict[str, Any]
"""Key-value pairs of args needed for the action (e.g., `{"a": 1, "b": 2}`)."""
class ActionRequest(TypedDict):
"""Represents an action request with a name, args, and description."""
name: str
"""The name of the action being requested."""
args: dict[str, Any]
"""Key-value pairs of args needed for the action (e.g., `{"a": 1, "b": 2}`)."""
description: NotRequired[str]
"""The description of the action to be reviewed."""
DecisionType = Literal["approve", "edit", "reject"]
class ReviewConfig(TypedDict):
"""Policy for reviewing a HITL request."""
action_name: str
"""Name of the action associated with this review configuration."""
allowed_decisions: list[DecisionType]
"""The decisions that are allowed for this request."""
args_schema: NotRequired[dict[str, Any]]
"""JSON schema for the args associated with the action, if edits are allowed."""
class HITLRequest(TypedDict):
"""Request for human feedback on a sequence of actions requested by a model."""
// ... (328 more lines)
Domain
Subdomains
Classes
Dependencies
- langchain.agents.middleware.types
- langchain_core.messages
- langgraph.runtime
- langgraph.types
- typing
- typing_extensions
Source
Frequently Asked Questions
What does human_in_the_loop.py do?
human_in_the_loop.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, Runnables subdomain.
What does human_in_the_loop.py depend on?
human_in_the_loop.py imports 6 module(s): langchain.agents.middleware.types, langchain_core.messages, langgraph.runtime, langgraph.types, typing, typing_extensions.
Where is human_in_the_loop.py in the architecture?
human_in_the_loop.py is located at libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py (domain: LangChainCore, subdomain: Runnables, directory: libs/langchain_v1/langchain/agents/middleware).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free