approve), modified before running (edit), rejected with feedback (reject), or responded to directly (respond) for “ask user” style tools.
Interrupt decision types中断决策类型
The middleware defines four built-in ways a human can respond to an interrupt:
The available decision types for each tool depend on the policy you configure in
interrupt_on.
When multiple tool calls are paused at the same time, each action requires a separate decision.
Decisions must be provided in the same order as the actions appear in the interrupt request.
Use reject when the human is denying the requested action. Use respond only when the human is acting as the tool, such as answering an ask_user prompt. Do not use respond to deny side-effecting tools, because its message is treated as a successful tool result.
Configuring interrupts配置中断
To use HITL, add the middleware to the agent’smiddleware list when creating the agent.
You configure it with a mapping of tool actions to the decision types that are allowed for each action. The middleware will interrupt execution when a tool call matches an action in the mapping.
You must configure a checkpointer to persist the graph state across interrupts.
In production, use a persistent checkpointer like
AsyncPostgresSaver or MongoDBSaver. For testing or prototyping, use InMemorySaver.When invoking the agent, pass a config that includes the thread ID to associate execution with a conversation thread.
See the LangGraph interrupts documentation for details.Configuration options配置选项
Configuration options配置选项
dict
requiredrequired
Mapping of tool names to approval configs. Values can be
True (interrupt with default config), False (auto-approve), or an InterruptOnConfig object.string
default:"Tool execution requires approval"
Prefix for action request descriptions
InterruptOnConfig options:list[string]
List of allowed decisions:
'approve', 'edit', 'reject', or 'respond'string | callable
Static string or callable function for custom description
callable
Optional predicate that receives a ToolCallRequest and returns
True to interrupt or False to auto-approve. Use it to gate interrupts on a call’s arguments. Requires langchain>=1.3.3.Conditional interrupts条件中断
By default, every tool call listed ininterrupt_on pauses for review. To pause only some calls, add a when predicate to a tool’s InterruptOnConfig. The predicate receives a ToolCallRequest and returns True to interrupt or False to auto-approve, so you can gate on the tool’s arguments.
Conditional interrupts require
langchain>=1.3.3.when predicate returns False, the call runs without interrupting. When it returns True, or when you omit when, the call pauses as usual. Calls that evaluate to False are never added to the interrupt batch, so a reviewer only sees the actions that need a decision.
Responding to interrupts响应中断
When you invoke the agent, it runs until it either completes or an interrupt is raised. An interrupt is triggered when a tool call matches the policy you configured ininterrupt_on. With version="v2", the result is a GraphOutput with an interrupts attribute containing the actions that require review. You can then present those actions to a reviewer and resume execution once decisions are provided.
Decision types决策类型
- ✅ approve✅ 批准 (approve)
- ✏️ edit✏️ 编辑 (edit)
- ❌ reject❌ 拒绝 (reject)
- 💬 respond💬 回复 (respond)
Use
approve to approve the tool call as-is and execute it without changes.Multiple decisions多项决策
When multiple actions are under review, provide a decision for each action in the same order as they appear in the interrupt:Streaming with human-in-the-loop人在回路的流式传输
You can stream real-time updates while the agent runs and handles interrupts usingstream_events(). Use stream.messages to stream LLM tokens and stream.values to check agent state snapshots for interrupts.
Execution lifecycle执行生命周期
The middleware defines anafter_model hook that runs after the model generates a response but before any tool calls are executed:
- The agent invokes the model to generate a response.智能体调用模型以生成响应。
- The middleware inspects the response for tool calls.中间件检查响应中是否存在工具调用。
- If any calls require human input, the middleware builds a HITLRequest with
action_requestsandreview_configsand calls interrupt.如果任何调用需要人工输入,中间件将构建包含 action_requests 和 review_configs 的 HITLRequest,并调用 interrupt。 - The agent waits for human decisions.智能体等待人工决策。
- Based on the
HITLResponsedecisions, the middleware executes approved or edited calls, synthesizes ToolMessage’s for rejected calls, returns human replies directly as ToolMessage’s forresponddecisions, and resumes execution.根据 HITLResponse 决策,中间件会执行已批准或已编辑的调用,为已拒绝的调用合成 ToolMessage,将人工回复直接作为 ToolMessage 返回以用于 respond 决策,并恢复执行。
Custom HITL logic自定义 HITL 逻辑
For more specialized workflows, you can build custom HITL logic directly using the interrupt primitive and middleware abstraction. Review the execution lifecycle above to understand how to integrate interrupts into the agent’s operation.Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

