Skip to content

Conversation

@shentongmartin
Copy link
Contributor

@shentongmartin shentongmartin commented Nov 5, 2025

feat: Add Common Human-in-the-Loop Patterns

This PR introduces a suite of common and powerful "human-in-the-loop" (HITL) patterns to the Eino examples. These patterns demonstrate how to build sophisticated agentic workflows that can pause for human intervention, enabling collaboration, oversight, and fine-grained control over agent execution.

Each pattern is implemented as a self-contained example within the adk/human-in-the-loop/ directory and includes detailed README.md files in both English and Chinese.

Core Contribution

This PR adds four distinct HITL patterns:

  1. Approval: Simple, explicit approval before a critical tool call.
  2. Review-and-Edit: In-place editing of tool call arguments before execution.
  3. Feedback Loop: Iterative refinement of generated content based on human feedback.
  4. Follow-up: Proactive clarification when a tool's output is insufficient.

These examples are built using a new set of reusable tool wrappers (approval_wrapper.go, review_edit_wrapper.go, etc.) that make it easy to integrate these HITL mechanisms into any agent.


1. Approval Pattern

  • What it is: The most straightforward HITL pattern. An agent's action (specifically, a tool call) is paused, and a human user must explicitly approve (Y) or deny (N) it before it can proceed.
  • How it works: It uses an InvokableApprovableTool wrapper that triggers a stateful interrupt before executing the wrapped tool. The workflow only resumes after receiving the user's confirmation.
  • Use Case: Ideal for critical or irreversible operations, such as database modifications, sending emails, or confirming financial transactions.

2. Review-and-Edit Pattern

  • What it is: A more advanced pattern that allows a human to act as a final checkpoint with editing capabilities. The user can review the arguments for a tool call and either approve them, disapprove the call, or edit them in-place before execution.
  • How it works: It uses an InvokableReviewEditTool wrapper. On interrupt, the user can provide a new JSON string with corrected arguments, which are then used when the tool call resumes.
  • Use Case: Perfect for scenarios where an agent might misinterpret details. For example, correcting a destination in a flight booking, adjusting a parameter in a complex API call, or refining a database query.

3. Feedback Loop Pattern

  • What it is: An iterative refinement pattern where an agent generates content, and a human provides qualitative feedback for improvement. The loop continues until the human is satisfied.
  • How it works: A multi-agent setup where a WriterAgent generates content and a ReviewerAgent presents it to the user. The user's feedback is passed back to the WriterAgent to generate a revised version.
  • Use Case: Content creation workflows like drafting emails, writing articles, generating code, or creating marketing copy, where iterative human guidance is key to achieving the desired quality.

4. Follow-up Pattern

  • What it is: A proactive pattern where an agent can recognize when a tool's output is insufficient to complete a task and can ask the user for a follow-up action or clarification.
  • How it works: The agent uses a FollowUpTool that, when its own capabilities are insufficient, can interrupt and ask the user for the next step (e.g., "The search results are ambiguous, which one should I proceed with?").
  • Use Case: Complex research or data retrieval tasks where the results may be ambiguous or incomplete, requiring human judgment to guide the next step.

@shentongmartin shentongmartin force-pushed the feat/hitl branch 5 times, most recently from e2ed289 to 70b7480 Compare November 6, 2025 03:10
@shentongmartin shentongmartin changed the title feat: add approval human-in-the-loop pattern feat: add common human-in-the-loop patterns Nov 6, 2025
shentongmartin and others added 7 commits November 19, 2025 14:51
Change-Id: I8217d0b92e5df954adfbae129f945a52d9367a08
Change-Id: Ifebae102fe01c6b5c1239c56d4bde9b83f89ff45
Change-Id: I79323759e03607496b411a7e6bd06a6eac18c986
Change-Id: I6c0a94d97a745dce9badda5b73e895ea440076e4
Change-Id: If2058922c3e2428ab896c5f8c59d12de79ae2ae5
Change-Id: I22b30575551f3f9d9b10a65ce11bcc2a92199a0b
Change-Id: Ie61a51f9d6dc0edbc1ddac973966740f2edf466b
@shentongmartin shentongmartin added this pull request to the merge queue Nov 20, 2025
Merged via the queue into main with commit d41b497 Nov 20, 2025
10 checks passed
@shentongmartin shentongmartin deleted the feat/hitl branch November 20, 2025 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants