HitlDemoAgent
Example Space Commander agent demonstrating the Human-in-the-Loop (HITL) workflow using the Kotlin ADK.
This example showcases how to declare a @Tool-annotated function with requireConfirmation = true so that the framework pauses agent execution and requests human confirmation before executing a potentially destructive or high-risk tool (here, initiateWarpJump).
The agent is configured to use the Gemini API for inference, behaving like a ship's computer equipped with the tools defined in ShipComputerTools.
How it works
The agent is configured with the tools generated from ShipComputerTools:
scanPlanet(safe) andinitiateWarpJump(risky, gated byrequireConfirmation = true).When the LLM decides to jump, the generated wrapper for
initiateWarpJumprecords a confirmation request via com.google.adk.kt.tools.ToolContext.requestConfirmation and returns a placeholder error response.The execution loop pauses, waiting for the user to provide a com.google.adk.kt.events.ToolConfirmation.
Once the confirmation is injected via a
FunctionResponsefor the syntheticadk_request_confirmationcall, the flow resumes and executes the tool.
The example can be exercised interactively with com.google.adk.kt.runners.ReplRunner, which prompts the operator for a yes/no decision whenever a tool gated by requireConfirmation = true is about to run.