LangChain · the classic AgentExecutor
How HITL works
LangChain has no first-class pause/resume primitive in AgentExecutor.
Two patterns are common:
- Callback approval — register
HumanApprovalCallbackHandler(fromlangchain_community.callbacks.human). Itson_tool_starthook prints the proposed tool call and waits for a y/n; rejection raises an exception that the executor surfaces as a tool error. - "Human" as a tool — add a
HumanInputRuntool to the agent's tool list. The LLM can choose to call it; the tool runsinput()(or any custom prompt callable) to fetch a string from the user.
Both run synchronously, in-process. The agent thread is blocked while the terminal (or your custom callable) waits.
Pattern coverage
1 · Tool approval
Yes, via HumanApprovalCallbackHandler's on_tool_start hook.
2 · Pause + resume
No native primitive. The while loop blocks; restarting the process loses state.
3 · Final-output review
No built-in. You'd wrap the executor or post-process its output yourself.
4 · Long-running async
Possible only if your "Human" tool returns a future and you orchestrate the wait — not framework-managed.
Code anchor
Both classes ship in the langchain-community package (a separate repo from the core langchain repo, which only retains deprecation stubs):
· langchain_community.callbacks.human · HumanApprovalCallbackHandler
· langchain_community.tools · HumanInputRun