Docs say single_turn is "Human in the Loop: Disallowed", but the code and its own test support pausing for a human and resuming
🔴 Required Information
Describe the Bug:
The collaboration page describes single_turn as not allowing a human in the loop, but nothing in adk-python enforces that, and the code and its own test treat a human-approval pause in a single_turn sub-agent as supported. I am not sure which of the two is intended, so I am asking you to decide, and I can send a docs or code PR once you do.
What the docs say (page source: docs/workflows/collaboration.md in adk-docs, rendered at https://adk.dev/workflows/collaboration/):
- Table "Mode configuration and behaviors", row Human in the Loop:
chat= "Full interaction",task= "For clarification only",single_turn= "Disallowed". The next row, User interaction, says "No user interaction". - The intro says "Single-turn: No user interaction with automatic return", and the example has
mode="single_turn", # no user interaction.
What the code does:
- Nothing rejects it. I found no validation or exception in the core that stops a
single_turnagent from having a tool that needs confirmation, a long-running tool or anadk_request_inputpause. The onlyraisetied tosingle_turnis inlabs/antigravity. AgentToolrecommendssingle_turnfor exactly this. When a wrapped agent pauses,AgentTool.run_asynclogs: "Agent %r paused with unresolved long-running tool call(s) %s, which AgentTool cannot resume because its nested session is discarded. Configure the agent under sub_agents (e.g. with mode='single_turn' for LlmAgent) if it needs to pause and resume." The comment above it listsadk_request_confirmation,adk_request_inputand a remote agent'sinput_requiredas the pauses it means.- A test expects it to work.
test_single_turn_child_agent_interrupt_and_resumebuilds a parent with amode='single_turn'child whose tool is long-running, asserts the pause (long_running_tool_ids) and asserts that after resuming the run "should complete successfully". - The in-repo guides do not say it is disallowed.
docs/guides/tools/agent_tool/index.mdrecommends a single-turn sub-agent overAgentTooland explains the difference: the sub-agent runs in the parent's session, while anAgentToolagent runs in "a separate session that ADK discards after each call", which is why it cannot resume. - The only thing that tells the model "no user" is a sentence in the prompt,
_SINGLE_TURN_NUDGE("You will not receive any user replies or clarifications."). I did not trace when it is added; in the script below the child's model is never shown it.
Steps to Reproduce:
pip install google-adk(I ran it onmain, d05e482, ADK 2.14.1, and on 2.14.0, with the same output)- Run the script below. It needs no API key: every model is scripted.
"""Can a single_turn sub-agent pause for a human and resume?
The docs table says single_turn is "Human in the Loop: Disallowed". This script uses the human-in-the-loop mechanism ADK ships for
tools, `FunctionTool(..., require_confirmation=True)`, with a `mode="single_turn"` sub-agent. Every model is scripted, so it needs
no API key and prints the same thing every time.
"""
import asyncio
import json
from google.adk import Agent
from google.adk.models.base_llm import BaseLlm
from google.adk.models.llm_response import LlmResponse
from google.adk.runners import InMemoryRunner
from google.adk.tools.agent_tool import AgentTool
from google.adk.tools.function_tool import FunctionTool
from google.genai import types
CONFIRMATION = "adk_request_confirmation"
class ScriptedLlm(BaseLlm):
model: str = "scripted"
script: list[list[types.Part]] = []
calls: list[int] = []
nudged: list[bool] = []
async def generate_content_async(self, llm_request, stream=False):
index = len(self.calls)
self.calls.append(index)
self.nudged.append(
any("will not receive any user replies" in (p.text or "") for c in llm_request.contents for p in (c.parts or []))
)
yield LlmResponse(content=types.Content(role="model", parts=self.script[index]))
def call(name, **args):
return [types.Part(function_call=types.FunctionCall(name=name, args=args))]
def text(value):
return [types.Part(text=value)]
def delete_order(order_id: str) -> dict:
"""Deletes an order. A person has to confirm it."""
return {"deleted": order_id}
def show(event):
parts = []
for part in (event.content.parts if event.content else None) or []:
if part.function_call:
parts.append(f"CALL {part.function_call.name}")
elif part.function_response:
parts.append(f"RESP {part.function_response.name} -> {json.dumps(part.function_response.response)[:80]}")
elif part.text:
parts.append(f"TEXT {part.text!r}")
lro = " [long_running_tool_ids]" if event.long_running_tool_ids else ""
print(f" {event.author}: {' | '.join(parts)}{lro}")
async def turn(runner, session_id, message):
events = []
async for event in runner.run_async(user_id="user", session_id=session_id, new_message=message):
events.append(event)
show(event)
return events
def pending_confirmation(events):
answered = {r.id for e in events for r in e.get_function_responses()}
pending = [c for e in events for c in e.get_function_calls() if c.name == CONFIRMATION and c.id not in answered]
return pending[-1] if pending else None
def user(value):
return types.Content(role="user", parts=[types.Part(text=value)])
def answer(pending, confirmed):
response = types.FunctionResponse(id=pending.id, name=CONFIRMATION, response={"confirmed": confirmed})
return types.Content(role="user", parts=[types.Part(function_response=response)])
async def start(root):
runner = InMemoryRunner(agent=root)
session = await runner.session_service.create_session(app_name=runner.app_name, user_id="user")
return runner, session.id
async def main():
for confirmed in (True, False):
child = Agent(
name="deleter", mode="single_turn", description="Deletes orders.", instruction="Delete the order.",
model=ScriptedLlm(script=[call("delete_order", order_id="42"), text("done" if confirmed else "not deleted")], calls=[]),
tools=[FunctionTool(delete_order, require_confirmation=True)],
)
root = Agent(
name="root", instruction="Delegate.", sub_agents=[child],
model=ScriptedLlm(script=[call("deleter", request="delete order 42"), text("all done")], calls=[]),
)
runner, session_id = await start(root)
print(f"\n1. single_turn sub-agent whose tool needs confirmation; the person {'approves' if confirmed else 'rejects'}")
print(" turn 1:")
events = await turn(runner, session_id, user("delete order 42"))
pending = pending_confirmation(events)
print(f" -> confirmation request waiting for the user: {pending is not None}")
print(" turn 2 (the user's answer):")
events = await turn(runner, session_id, answer(pending, confirmed))
ran = any(r.name == "delete_order" and r.response.get("deleted") for e in events for r in e.get_function_responses())
print(f" -> the tool ran: {ran}; the root answered: {any(e.author == 'root' and e.content and any(p.text for p in e.content.parts) for e in events)}")
print(f" -> the child's model was shown the 'no user replies' sentence: {any(child.model.nudged)}")
plain = Agent(
name="deleter_tool", description="Deletes orders.", instruction="Delete the order.",
model=ScriptedLlm(script=[call("delete_order", order_id="42"), text("done")], calls=[]),
tools=[FunctionTool(delete_order, require_confirmation=True)],
)
root = Agent(
name="root", instruction="Delegate.", tools=[AgentTool(plain)],
model=ScriptedLlm(script=[call("deleter_tool", request="delete order 42"), text("could not")], calls=[]),
)
runner, session_id = await start(root)
print("\n2. control: the same agent wrapped in AgentTool")
print(" turn 1:")
events = await turn(runner, session_id, user("delete order 42"))
print(f" -> confirmation request waiting for the user: {pending_confirmation(events) is not None}")
asker = Agent(
name="asker", mode="single_turn", description="Deletes orders.", instruction="Ask what is missing.",
model=ScriptedLlm(script=[text("Which order?")], calls=[]),
)
root = Agent(
name="root", instruction="Delegate.", sub_agents=[asker],
model=ScriptedLlm(script=[call("asker", request="delete an order"), text("it needs the order number")], calls=[]),
)
runner, session_id = await start(root)
print("\n3. free text: the single_turn agent ends with a question")
print(" turn 1:")
await turn(runner, session_id, user("delete an order"))
asyncio.run(main())
Expected Behavior:
Either the docs say that a single_turn sub-agent can pause for approval or input through a tool, and that what it cannot do is chat with the user, or the code rejects the pause, in which case the AgentTool warning and the test above would need to change. Today they disagree.
Observed Behavior:
Cases 1 and 2: the confirmation request reaches the user (its author is the single_turn child), the run stops, and after the user's answer the tool runs (or not, if rejected), the child finishes and the root answers. Case 3 is the control the AgentTool warning describes: nothing reaches the user. Case 4 (free text) matches the docs: the child just ends with a question and the root receives it as the tool result, so nobody waits on the child.
1. single_turn sub-agent whose tool needs confirmation; the person approves
turn 1:
root: CALL deleter
deleter: CALL delete_order
deleter: CALL adk_request_confirmation [long_running_tool_ids]
deleter: RESP delete_order -> {"error": "This tool call requires confirmation, please approve or reject."}
-> confirmation request waiting for the user: True
turn 2 (the user's answer):
deleter: RESP delete_order -> {"deleted": "42"}
deleter: TEXT 'done'
root: RESP deleter -> {"result": "done"}
root: TEXT 'all done'
-> the tool ran: True; the root answered: True
-> the child's model was shown the 'no user replies' sentence: False
1. single_turn sub-agent whose tool needs confirmation; the person rejects
turn 1:
root: CALL deleter
deleter: CALL delete_order
deleter: CALL adk_request_confirmation [long_running_tool_ids]
deleter: RESP delete_order -> {"error": "This tool call requires confirmation, please approve or reject."}
-> confirmation request waiting for the user: True
turn 2 (the user's answer):
deleter: RESP delete_order -> {"error": "This tool call is rejected."}
deleter: TEXT 'not deleted'
root: RESP deleter -> {"result": "not deleted"}
root: TEXT 'all done'
-> the tool ran: False; the root answered: True
-> the child's model was shown the 'no user replies' sentence: False
2. control: the same agent wrapped in AgentTool
turn 1:
root: CALL deleter_tool
root: RESP deleter_tool -> {"result": "Error: agent 'deleter_tool' stopped waiting on unresolved long-runni
root: TEXT 'could not'
-> confirmation request waiting for the user: False
3. free text: the single_turn agent ends with a question
turn 1:
root: CALL asker
asker: TEXT 'Which order?'
root: RESP asker -> {"result": "Which order?"}
root: TEXT 'it needs the order number'
Environment Details:
- ADK Library Version (pip show google-adk): 2.14.1 (
main, d05e482) and 2.14.0 - Desktop OS: macOS
- Python Version (python -V): 3.12
Model Information:
- Are you using LiteLLM: No
- Which model is being used: none, scripted stub models (I also see this with a real model through LiteLLM)
🟡 Optional Information
Regression: N/A
Additional Context:
Something like this would match what the code does, if that is the intent. In the table: Human in the Loop for single_turn = "Pause for approval or input from a tool; no free-form chat with the user", and in the example, # no free-form chat with the user. I have only tried tool-based pauses with require_confirmation; I have not tried adk_request_input or a LongRunningFunctionTool directly in single_turn (the test above covers the latter).
I am filing this here because the behavior and the test are in this repository. The table itself lives in adk-docs, so I can open a matching issue there if you prefer.
How often has this issue occurred?:
- Always (100%)
@fponsse. Your script gives me the same output on 2.14.1 and current main: the single_turn child pauses on adk_request_confirmation and resumes fine after approve/reject.
Since the AgentTool warning and test_single_turn_child_agent_interrupt_and_resume both rely on this, I’d lean towards keeping the behavior and fixing the docs, something like your wording: “Pause for approval or input from a tool; no free-form chat with the user”.
Before opening the adk-docs PR, could you also try adk_request_input and a plain LongRunningFunctionTool pause in single_turn and confirm they resume the same way?
If those hold up, a matching issue/PR in adk-docs linked back here would be great. I’ll get the owner to confirm the intended behavior.
I verified the remaining two pause mechanisms requested above (adk_request_input and plain LongRunningFunctionTool) offline on google-adk==2.14.1 (Python 3.12.13, Darwin arm64) using scripted BaseLlm stubs — all resume the same way as adk_request_confirmation:
-
adk_request_input(google.adk.tools.request_input) inmode="single_turn":- Turn 1 pauses with
CALL adk_request_input(...) [long_running_tool_ids]on the child branch (also confirmed when thesingle_turnagent is aWorkflownode). - Turn 2 (
FunctionResponse(id=pending.id, name="adk_request_input", response={"result": "staging"})) resumes the child with the answer in context, emits the child's final text, and returns the tool result torootto complete. - Control (
AgentToolwrapping the same agent) fails withAgentTool's warning recommendingsub_agentswithmode='single_turn'.
- Turn 1 pauses with
-
Plain
LongRunningFunctionToolinmode="single_turn":- Returning
None: pauses withlong_running_tool_idson turn 1, resumes cleanly on the finalFunctionResponseon turn 2, and returns toroot. (AgentToolcontrol fails with the same warning.) - Returning an intermediate pending dict (e.g.
{"status": "pending", "ticket": "T-100"}): emits the intermediateFunctionResponseand child's intermediate text ('waiting on T-100') and still pauses before returning toroot; sending the finalFunctionResponseon turn 2 resumes the child (with the final response in context) and only then returns toroot. (InAgentTool, returning a truthy dict resolves immediately without pausing or warning.)
- Returning
Two related codebase notes from google-adk==2.14.1:
google/adk/workflow/_llm_agent_wrapper.py(prepare_llm_agent_input, lines 361–372) has explicit logic forsingle_turnskipping synthetic input injection whenbool(ctx.resume_inputs)specifically for HITL pause/resume — and no docstring or metadata ingoogle-adk==2.14.1describessingle_turnas disallowing HITL (LlmAgent.modeatllm_agent.py:407already says"Agents that complete a task without chatting with the user.").- On
_SINGLE_TURN_NUDGE:_contents.py:659-667only calls_build_task_input_user_content(..., is_single_turn=True)whenisolation_scope is not None. That is whychat -> single_turnnever shows the nudge (isolation_scope=None), whiletask -> single_turndoes (nudged=[True]). - Minor log note: on turn 2 resume across all three mechanisms,
google/adk/flows/llm_flows/tools/_rearranger.py:351logs a benign warning (Dropping function calls with no matching function response: [<root delegation call id>]) while building child context becauseroot's outer delegation call is still open until the child returns.
Offline repro output (google-adk 2.14.1, zero API keys)
Python 3.12.13, google-adk 2.14.1, Darwin arm64
1. single_turn + adk_request_input (google.adk.tools.request_input)
turn 1:
root: CALL deployer({"request": "deploy v2"})
deployer: CALL adk_request_input({"message": "Which environment?", "response_schema": {"type": "string"}}) [long_running_tool_ids]
turn 2 (user answers adk_request_input):
deployer: TEXT 'deployed to staging'
root: RESP deployer -> {"result": "deployed to staging"}
root: TEXT 'release v2 deployed to staging'
-> child turn 2 context: ["user:TEXT('deploy v2')", 'model:FC(adk_request_input)', "user:FR(adk_request_input={'result': 'staging'})"]
2. single_turn + LongRunningFunctionTool (returns None)
turn 1:
root: CALL approver_none({"request": "approve T-99"})
approver_none: CALL approve_none({"ticket": "T-99"}) [long_running_tool_ids]
turn 2 (final FunctionResponse arrives):
approver_none: TEXT 'T-99 approved'
root: RESP approver_none -> {"result": "T-99 approved"}
root: TEXT 'approval complete'
-> child turn 2 context: ["user:TEXT('approve T-99')", 'model:FC(approve_none)', "user:FR(approve_none={'status': 'approved', 'ticket': 'T-99'})"]
3. single_turn + LongRunningFunctionTool (returns pending dict)
turn 1:
root: CALL approver_dict({"request": "approve T-100"})
approver_dict: CALL approve_pending({"ticket": "T-100"}) [long_running_tool_ids]
approver_dict: RESP approve_pending -> {"status": "pending", "ticket": "T-100"}
approver_dict: TEXT 'waiting on T-100'
turn 2 (final FunctionResponse arrives):
approver_dict: TEXT 'T-100 finally approved'
root: RESP approver_dict -> {"result": "T-100 finally approved"}
root: TEXT 'all done'
-> child turn 3 context: ["user:TEXT('approve T-100')", 'model:FC(approve_pending)', "user:FR(approve_pending={'status': 'approved', 'ticket': 'T-100'})"]
4. control: AgentTool + adk_request_input
turn 1:
root: CALL deployer_tool({"request": "deploy v2"})
root: RESP deployer_tool -> {"result": "Error: agent 'deployer_tool' stopped waiting on unresolved long-running tool c
root: TEXT 'could not deploy'
Note: Verified locally offline with AI assistance; all tests and outputs were run firsthand on google-adk 2.14.1.
Thanks @KilianTheMagnificent, that covers the two cases I asked about. Checked again on 2.15.0 (current main): adk_request_input also pauses in a single_turn child and resumes back to root, and the original confirmation script gives the same output, so nothing has changed there.
Since all three pause types work and the _llm_agent_wrapper.py resume path is written for this case, I think the docs are what's out of date. @fponsse if you're still up for it, please open the adk-docs PR with your wording ("Pause for approval or input from a tool; no free-form chat with the user") and link it back here.
The nudge only appearing for task -> single_turn and not chat -> single_turn looks like a separate thing. I'll raise it with the owner along with the docs change rather than mix it into this one.