Skip to content

fix(agents): support human-in-the-loop (HITL) approval buttons inside ExecuteFlow - #6659

Open
SyncWithRaj wants to merge 4 commits into
FlowiseAI:mainfrom
SyncWithRaj:fix/executeflow-hitl-buttons
Open

fix(agents): support human-in-the-loop (HITL) approval buttons inside ExecuteFlow #6659
SyncWithRaj wants to merge 4 commits into
FlowiseAI:mainfrom
SyncWithRaj:fix/executeflow-hitl-buttons

Conversation

@SyncWithRaj

Copy link
Copy Markdown
Contributor

What this PR does

Fixes #5608 - Resolves the bug where "Require Human Input" (HITL) tools inside an ExecuteFlow node cause the parent chat UI to hang forever without showing the Approve/Reject buttons.

Why this was happening

Right now, ExecuteFlow treats sub-flows like a standard, synchronous HTTP call, it just sits there waiting for a final text string to come back. When a child flow hits a tool that requires human approval, the backend pauses execution and sends back an action payload instead of final text.

Because ExecuteFlow didn't know what to do with an action payload, it simply ignored it. On top of that, the SSE stream from the sub-flow wasn't wired to the parent UI. Result: the backend paused successfully (which is why buttons showed up in the Executions List dashboard), but the parent chat UI hung forever waiting for text that was never coming.

How we fixed it (The 4-Part Bridge)

Instead of trying to force a messy live SSE proxy between the child sandbox and the parent, we built a bottom-up wakeup bridge using the HTTP response state:

  1. Intercepting the Pause (ExecuteFlow.ts): We modified ExecuteFlow so when it gets an HTTP response from a child flow, it checks for an action object. If found, instead of waiting for text, it returns a special state:
    { isWaitingForHumanInput: true, childFlowId: "...", childExecutionId: "...", humanInputAction: { ... } }
  2. Halting the Parent Flow (buildAgentflow.ts): When the core engine sees isWaitingForHumanInput = true coming from an ExecuteFlow node, it halts the parent flow, takes the humanInputAction from the child, and emits it over the parent's SSE stream. This makes the buttons finally render in the UI!
  3. Capturing the Click (ChatMessage.jsx & Interface.ts): Extended IHumanInput to support child routing metadata. Updated the React frontend so when you click "Approve", onSubmitResponse grabs the childFlowId, childExecutionId, childChatId, and childNodeId and sends them back in the payload.
  4. Resuming the Child Flow (ExecuteFlow.ts): When the server receives that approval click, the parent ExecuteFlow node wakes up, reads the routing metadata, and forwards the approval directly into a new POST request to the sub-flow. The child flow sees the approval, runs the tool, and finishes up!

Screenshot

Here is the chat UI now properly rendering the Approve/Reject buttons inside a parent ExecuteFlow execution, and successfully continuing once clicked:

image

Testing steps

  1. Create flow A (use-tools) with a tool -> toggle "Require Human Input" to TRUE.
  2. Create flow B -> add ExecuteFlow pointing to flow A.
  3. Chat with flow B and prompt it to use the tool.
  4. You'll see the Proceed/Reject buttons appear. Click Proceed, and the flow finishes natively!

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No approve/reject button when enable "require human input" in ExecuteFlow

1 participant