feat: add HITL approval gateway for production ADK agent workflows#110
Draft
garythomasgeorge wants to merge 2 commits intogoogle:mainfrom
Draft
feat: add HITL approval gateway for production ADK agent workflows#110garythomasgeorge wants to merge 2 commits intogoogle:mainfrom
garythomasgeorge wants to merge 2 commits intogoogle:mainfrom
Conversation
- Add ADK 1.x adapter and data models - Add FastAPI backend and SQLite state management routes - Add Streamlit dashboard UI for human reviewers - Add sample credit_agent showcasing the full @hitl_tool integration - Fully formatted under pyink and isort conventions
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.
Summary
Closes #111
Adds a production-ready Human-in-the-Loop approval gateway for Google ADK agents. This addresses a documented gap where ADK's built-in Tool Confirmation feature explicitly does not support
DatabaseSessionServiceorVertexAiSessionService— the two session backends required for production deployments — making structured human oversight unavailable in any persistent production environment.Problem
ADK's Tool Confirmation (v1.14.0+) is experimental and has three blockers for production use:
DatabaseSessionServiceorVertexAiSessionServiceAgentToolor across A2A boundariesValidated by community issues: #1797, #1851, #2645, #3276, #3567 on
google/adk-python.Solution
A session-agnostic HITL approval gateway that manages approval state in its own persistence layer (SQLite, with a documented path to Postgres), independent of ADK's session service. The agent resumes via ADK's standard REST API after a human decision is submitted.
What's included
Core module (
src/google/adk_community/tools/hitl/)gateway.py—hitl_tooldecorator that wraps any async function before it is passed toFunctionTool. Adding HITL to an existing tool takes ~5 lines.models.py—ApprovalRequestPydantic model, normalised data contract capturing agent context, payload, risk level, and audit metadataadapters/adk1.py— ADK 1.x adapter translatingrequest_confirmation()events intoApprovalRequestobjectsService (
src/google/adk_community/services/hitl_approval/)api.py— FastAPI applicationroutes.py— REST endpoints for approval queue managementstore.py— SQLite persistence with full audit logSample (
contributing/samples/hitl_approval/)credit_agent/agent.py— Credit approval agent demonstrating end-to-end integrationdashboard/app.py— Reference Streamlit approval inbox UIstart_servers.sh— One-command startup for all three servicesrequirements.txt— Sample-only dependenciesArchitecture
Forward compatibility
Built with an adapter pattern so the same approval backend and dashboard work with ADK 1.x today and ADK 2.0's
RequestInputpattern when it reaches stable — without teams needing to rebuild their approval layer on upgrade.Testing
Unit tests
All 11 tests passing:
Manual E2E
Full end-to-end flow verified:
ADK_HITL.Demo.webm
Testing plan
For reviewers wanting to reproduce locally:
cd contributing/samples/hitl_approval uv pip install -r requirements.txt ./start_servers.shThen open:
http://localhost:8080http://localhost:8501http://localhost:8000/docsTrigger an approval by asking the credit agent to process an amount over $500.
Notes for reviewers
adapters/adk2.py) is planned as a follow-up PR once 2.0 moves toward stabletools/hitlfor the gateway and models,services/hitl_approvalfor the FastAPI backend — let me know if you'd prefer a different organisationRelated