How to implement HITL (Human-in-the-Loop) with runner.run_live() bidirectional streaming? #3992
Replies: 3 comments
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: Your current method of checking the session for pending confirmations is likely necessary because Hello! Here is a more detailed breakdown based on the ADK documentation: 1. Detecting HITL Requirements in
|
Beta Was this translation helpful? Give feedback.
-
|
The streaming HITL flow is tricky because the confirmation event arrives mid-stream. You need to buffer the stream, pause on confirmation events, wait for user input, then resume. If you are using the web runner, the confirmation state needs to persist across SSE reconnects or you lose the pending approval. |
Beta Was this translation helpful? Give feedback.
-
|
I dug through the current ADK source/tests, and the resume contract is a bit narrower than the session shape makes it look. What ADK itself treats as the HITL boundary is the synthetic function call Source-backed bits:
So the practical shape is: confirmation_part = types.Part(
function_response=types.FunctionResponse(
id=request_confirmation_call_id, # the synthetic adk_request_confirmation call id
name="adk_request_confirmation",
response={"confirmed": True}, # or your payload schema
)
)A couple implications for your questions:
The closest samples I found were:
If it helps, I can turn this into a minimal |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question
I'm trying to implement HITL (Human-in-the-Loop) with
runner.run_live()for bidirectional audio streaming. I have aLongRunningFunctionToolthat usestool_context.request_confirmation().The Problem
When the tool is called in live mode:
event.long_running_tool_idscontains the function call IDevent.actions.requested_tool_confirmationsis empty {}session_service.get_session()), not in the live event streamCurrent Workaround
I'm checking the session on each event to detect pending confirmations:
Questions
run_live()mode?live_request_queue.send_content()withFunctionResponsecorrect?Environment
runner.run_live()withLongRunningFunctionToolBeta Was this translation helpful? Give feedback.
All reactions