0Pricing
AI Agents with LangChain & Autonomous Workflows · 课时

人在回路中的审批

在自主工作流中加入安全检查点,由人类在代理继续执行前审核或批准高风险操作,在自动化与控制之间取得平衡。

人在回路中的审批 是 CoddyKit 上的免费 AI Agents with LangChain & Autonomous Workflows 课时。 这是第 4 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 AI Agents with LangChain & Autonomous Workflows 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 AI Agents with LangChain & Autonomous Workflows 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

Why Pause for Humans

Full autonomy is risky for high-stakes actions: sending money, deleting records, emailing customers. A mistake can be costly and irreversible.

Human-in-the-loop (HITL) inserts an approval step so a person confirms before the agent acts.

Where to Add Checkpoints

You do not need approval everywhere — only at sensitive points:

  • Before destructive or irreversible operations
  • Before external side effects (payments, emails)
  • When the agent's confidence is low

Read-only steps can stay fully automatic.

The Interrupt Pattern

In LangGraph you mark nodes where the graph should pause. Execution stops, state is saved, and control returns to your application to await a decision.

graph = builder.compile(
    checkpointer=memory,
    interrupt_before=['execute_payment']
)

Persisting State to Resume

To pause and resume later, the workflow needs a checkpointer that saves state under a thread id. The human might approve minutes or hours later.

config = {'configurable': {'thread_id': 'order-42'}}
result = graph.invoke(initial_state, config)

Surfacing the Pending Action

When paused, inspect the saved state to show the human exactly what the agent wants to do — the tool, the arguments, and the reason.

state = graph.get_state(config)
print(state.next)
print(state.values['proposed_action'])

Approve and Continue

If the human approves, resume the graph by invoking again with the same thread id. It picks up right where it paused.

graph.invoke(None, config)  # resume

Reject or Edit

Approval is not the only outcome. A human can reject the action or edit the agent's proposed arguments before continuing — for example fixing a wrong recipient.

graph.update_state(
    config,
    {'proposed_action': edited_action}
)
graph.invoke(None, config)

Asynchronous Approvals

In production the human is not at a console. The pause sends a notification (Slack, email, a dashboard task); the resume happens when they click approve. The thread id ties the request to the right paused run.

Timeouts and Defaults

Decide what happens if no one responds. Options:

  • Auto-reject after a timeout (safe default)
  • Escalate to another approver
  • Hold indefinitely for critical actions

Auditability

Log every approval decision: who approved, when, and what was executed. This audit trail is essential for compliance and for debugging agent behavior later.

Balancing Automation

Too many approvals defeat the purpose of automation; too few add risk. Start cautious, then remove checkpoints as you gain confidence in the agent for specific action types.

Quick Check

Test your HITL knowledge.

Recap

You learned to add human oversight to autonomous workflows:

  • Insert approval checkpoints at risky steps only
  • Use interrupt_before plus a checkpointer to pause
  • Surface the proposed action, then approve, reject, or edit
  • Handle async approvals, timeouts, and audit logging

Human-in-the-loop makes autonomy safe for high-stakes work.

常见问题解答

「人在回路中的审批」课时是免费的吗?

是的 — 「人在回路中的审批」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 AI Agents with LangChain & Autonomous Workflows 课程的其余内容,请升级到 CoddyKit PRO。 AI Agents with LangChain & Autonomous Workflows 课程共包含 4 节课。

「人在回路中的审批」这节课中我会学到什么?

在自主工作流中加入安全检查点,由人类在代理继续执行前审核或批准高风险操作,在自动化与控制之间取得平衡。 你通过在浏览器中直接运行的动手代码来练习 AI Agents with LangChain & Autonomous Workflows,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 AI Agents with LangChain & Autonomous Workflows 需要有经验吗?

无需任何先前经验。CoddyKit 上的 AI Agents with LangChain & Autonomous Workflows 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 4 节课,共 4 节。

「人在回路中的审批」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 AI Agents with LangChain & Autonomous Workflows 课中编写并运行代码吗?

能。每节 AI Agents with LangChain & Autonomous Workflows 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 设计复杂工作流
  2. 异步执行智能体
  3. 错误处理与韧性
  4. 人在回路中的审批
← 返回 AI Agents with LangChain & Autonomous Workflows