Google ADK Human Approval Workflow with AgentOps
This example shows you how to build a complete human approval workflow using Google’s Agent Development Kit (ADK) with comprehensive tracking via AgentOps.What We’re Building
A 3-agent sequential workflow for processing approval requests:- 🔍 Prepare Agent: Extracts and validates approval request details
- 👤 Approval Agent: Handles human approval via external tool
- ✅ Decision Agent: Processes approval decisions and provides final response
Step-by-Step Implementation
Step 1: Install Dependencies
Install Google ADK with required packages and AgentOps for tracking:- 🔍 Automatic tracking of all LLM calls and agent interactions
- 💰 Cost monitoring with token usage breakdown
- 🛠️ Tool usage analytics for approval workflow steps
- 📊 Performance metrics and execution timelines
- 🐛 Session replay for debugging and optimization
Step 2: Create Google ADK Project
Create the proper project structure for your approval workflow:Step 3: Set Up Environment Variables
Create the.env
file in approval_agent/
directory:
- Google API Key: Google AI Studio
- AgentOps API Key: AgentOps Settings
GOOGLE_GENAI_USE_VERTEXAI=TRUE
and run gcloud auth application-default login
Step 4: Create Module Initialization
Editapproval_agent/__init__.py
:
Step 5: Define the Agent Workflow
Editapproval_agent/agent.py
to create your approval workflow:
Step 6: Define the Three-Agent Workflow
Add the agent definitions to create your sequential workflow:Step 7: Create the Sequential Workflow and Runner
Combine agents into a workflow with session management:Step 8: Add the Main Execution Function
Create the function to run the approval workflow with AgentOps tracking:Step 9: Run Your Approval Workflow
Navigate to your project directory and run the workflow: Option 1: Interactive Development UI- AgentOps session starts automatically
- Prepare agent extracts amount and reason from requests
- Approval agent prompts for human input via terminal
- Decision agent processes the approval and provides final response
- AgentOps captures all interactions, tool usage, and costs
- Session ends with success/failure status
View Results in AgentOps Dashboard
After running your approval workflow, visit your AgentOps Dashboard to see:- Session Overview: Complete timeline of the 3-agent workflow
- Agent Conversations: Every LLM call with prompts and responses
- Tool Execution: Human approval interactions and decisions
- Cost Breakdown: Token usage and costs per agent and step
- Performance Analytics: Execution times and success rates
- Session Replay: Step-by-step playback for debugging
Key Files Created
Project structure you built:approval_agent/__init__.py
- Module initialization with agent importapproval_agent/agent.py
- Complete workflow with 3 agents and AgentOps integrationapproval_agent/.env
- API keys for Google AI and AgentOps
agentops.init()
- Enables automatic instrumentationagentops.start_session()
- Begins tracking each workflow runagentops.end_session()
- Completes the session with status
Next Steps
- Customize approval thresholds and business logic
- Add more sophisticated approval routing
- Integrate with external approval systems (Slack, email, etc.)
- Use Google ADK’s web UI for better user experience
- Use AgentOps analytics to optimize approval times