Skip to content

human-in-the-loop #378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jleva12 opened this issue Mar 28, 2025 · 6 comments
Open

human-in-the-loop #378

jleva12 opened this issue Mar 28, 2025 · 6 comments
Labels
question Question about using the SDK

Comments

@jleva12
Copy link

jleva12 commented Mar 28, 2025

Human Review/Approval Step for Agent Tool Execution

Problem Statement

When using AI agents with tool execution capabilities, we currently don't have a way to intercept the tool execution and have a human review before allowing the action to proceed. I need a mechanism to:

  1. Pause the agent's execution before the tool is called
  2. Display what the agent is about to do to a human user
  3. Present an approval UI for the human to accept or reject
  4. Continue execution only after approval (or abort if rejected)

Current Limitations

  • We can't rely on prompt-based solutions as they're not reliable for this use case
  • Need an architectural solution that intercepts tool execution at the system level
  • Want to avoid simply terminating the entire run - we need to gracefully pause and resume

Desired Implementation

I'm looking for a pattern/architecture that would allow:

  • Agent begins a run and determines it needs to use a tool
  • System intercepts the tool call before execution
  • Human user receives a notification/message showing the intended action
  • A UI component displays the details and provides Accept/Reject buttons
  • On Accept: tool executes and agent continues normally
  • On Reject: agent is informed the tool call was rejected and can choose alternate approaches

Questions

  • Is this possible with the current agent architecture?

  • Are there examples of similar implementations?

  • What's the recommended approach for intercepting tool calls?

  • What's the best way to design the human approval UI flow?

  • How should we handle timeouts if a human doesn't respond promptly?

  • human-in-the-loop

@jleva12 jleva12 added the question Question about using the SDK label Mar 28, 2025
@rm-openai
Copy link
Collaborator

Thanks for the question - please search the closed issues for human in the loop for some ideas, and followup here if you still have questions!

@Cayden96
Copy link

Potential Ideas:

  1. Embed a UI confirmation flow in the function tool itself, though could become excessive—maybe use an agent to decide when user confirmation is needed? This might be an independent agent that gets called as part of the function, rather than via handoff/agent-as-tool.
  2. Ensure that an informative message is returned by the tool that captures confirmation/rejection, so the original agent knows how to handle failure due to user rejection (e.g. asking the user how to proceed or trying a different approach). Ideally you would also capture why a rejection occurred, so the agent doesn't retry the same thing (or conversely, does if rejection is temporary—such as a timeout).

I imagine the flow to be something like: ... -> Function Tool call -> trigger for UI confirmation flow/agent -> Accept=continue; Reject=return error message -> Original agent see's either success or failure output.

Hopefully this helps.

Copy link

github-actions bot commented Apr 7, 2025

This issue is stale because it has been open for 7 days with no activity.

@github-actions github-actions bot added the stale label Apr 7, 2025
@devv-shayan
Copy link

devv-shayan commented Apr 9, 2025

is there any update on this human in the loop feature @rm-openai

@github-actions github-actions bot removed the stale label Apr 16, 2025
@vladkolotvin
Copy link

The "human-in-the-loop" mechanism would also solve the issue of long-running tool executions. This would enable moving execution outside the main agent loop and processing resource-intensive operations asynchronously. If an application instance restarts, the system could restore state and continue execution after receiving the result, significantly improving reliability when working with resource-intensive tasks.

@yanmxa
Copy link

yanmxa commented Apr 26, 2025

Another way to implement the review/approval step is by using the agent hook on_tool_start. Currently, the tool call is missing parameters needed for the hook, and I'm working on adding them here: #252. Once it's merged, one approach would be to insert the pre-check (human-in-the-loop) step within the hook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about using the SDK
Projects
None yet
Development

No branches or pull requests

6 participants