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

  1. The agent is configured with the tools generated from ShipComputerTools: scanPlanet (safe) and initiateWarpJump (risky, gated by requireConfirmation = true).

  2. When the LLM decides to jump, the generated wrapper for initiateWarpJump records a confirmation request via com.google.adk.kt.tools.ToolContext.requestConfirmation and returns a placeholder error response.

  3. The execution loop pauses, waiting for the user to provide a com.google.adk.kt.events.ToolConfirmation.

  4. Once the confirmation is injected via a FunctionResponse for the synthetic adk_request_confirmation call, 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.

Properties

Link copied to clipboard