fix(agents): support human-in-the-loop (HITL) approval buttons inside ExecuteFlow - #6659
Open
SyncWithRaj wants to merge 4 commits into
Open
fix(agents): support human-in-the-loop (HITL) approval buttons inside ExecuteFlow #6659SyncWithRaj wants to merge 4 commits into
SyncWithRaj wants to merge 4 commits into
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Fixes #5608 - Resolves the bug where "Require Human Input" (HITL) tools inside an
ExecuteFlownode cause the parent chat UI to hang forever without showing the Approve/Reject buttons.Why this was happening
Right now,
ExecuteFlowtreats 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 anactionpayload instead of final text.Because
ExecuteFlowdidn't know what to do with anactionpayload, 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:
ExecuteFlow.ts): We modifiedExecuteFlowso when it gets an HTTP response from a child flow, it checks for anactionobject. If found, instead of waiting for text, it returns a special state:{ isWaitingForHumanInput: true, childFlowId: "...", childExecutionId: "...", humanInputAction: { ... } }buildAgentflow.ts): When the core engine seesisWaitingForHumanInput = truecoming from an ExecuteFlow node, it halts the parent flow, takes thehumanInputActionfrom the child, and emits it over the parent's SSE stream. This makes the buttons finally render in the UI!ChatMessage.jsx&Interface.ts): ExtendedIHumanInputto support child routing metadata. Updated the React frontend so when you click "Approve",onSubmitResponsegrabs thechildFlowId,childExecutionId,childChatId, andchildNodeIdand sends them back in the payload.ExecuteFlow.ts): When the server receives that approval click, the parentExecuteFlownode 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
ExecuteFlowexecution, and successfully continuing once clicked:Testing steps
use-tools) with a tool -> toggle "Require Human Input" to TRUE.ExecuteFlowpointing to flow A.