A complete AI agent application with Google Search and Maps grounding capabilities, built with Google's Agent Development Kit (ADK), CopilotKit, and AG-UI protocol.
- π Google Search Grounding - Real-time web search with source attribution
- πΊοΈ Google Maps Grounding - Location-based queries, directions, and place information
- π¨ Dynamic Theme - Agent can change application colors
- π Proverbs Management - Add/remove proverbs through conversation
- π¦οΈ Weather Cards - Generative UI components for weather information
- π¬ Real-time Chat - Powered by AG-UI protocol and CopilotKit
This project demonstrates the Agent-as-Tool Pattern for integrating Google's grounding tools:
βββββββββββββββββββ AG-UI Protocol βββββββββββββββββββ
β Next.js UI βββββββββββββββββββββΊβ ADK Agent β
β (CopilotKit) β β (Python) β
βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β Grounding β
β - Search Agent β
β - Maps Agent β
βββββββββββββββββββ
- Node.js 18+
- Python 3.12+
- Google Cloud Account with billing enabled
- Google AI Studio API Key - Get it here
- CopilotKit License Key - Get it here
- Package Manager - npm, pnpm, yarn, or bun
# Clone the repository
git clone <your-repo-url>
cd ag-ui-adk-app
# Install Node.js dependencies
npm install
# Install Python dependencies (creates virtual environment)
npm run install:agent# Install Google Cloud SDK
brew install google-cloud-sdk # macOS
# or download from: https://cloud.google.com/sdk/docs/install
# Initialize and authenticate
gcloud init
gcloud auth application-default login
# Enable required APIs
gcloud services enable aiplatform.googleapis.comCreate a .env file in the project root:
cp .env.example .envEdit .env with your credentials:
# Google API Key
GOOGLE_API_KEY=your-google-api-key-here
# Vertex AI Configuration
GOOGLE_GENAI_USE_VERTEXAI=true
GOOGLE_CLOUD_PROJECT=your-project-id
GOOGLE_CLOUD_LOCATION=us-central1
# CopilotKit License Key
NEXT_PUBLIC_COPILOT_LICENSE_KEY=your-copilotkit-license-keynpm run devThis starts:
- UI Server: http://localhost:3000
- Agent Server: http://localhost:8000
Try these prompts in the chat:
- "Set the theme to ocean blue"
- "Change the color to sunset orange"
- "Write a proverb about AI"
- "Add a proverb about technology"
- "Remove the first proverb"
- "Get the weather in San Francisco"
- "What's the weather like in Tokyo?"
- "What's the latest news about artificial intelligence?"
- "Search for information about climate change"
- "Tell me about the recent developments in quantum computing"
- "Find restaurants near Central Park"
- "What hotels are in downtown Lagos?"
- "Give me directions from Ajao Estate to Gbagada, Lagos"
- "What's the distance between these locations?"
ag-ui-adk-app/
βββ agent/ # ADK agent backend
β βββ agent.py # Main agent logic with grounding
β βββ requirements.txt # Python dependencies
βββ src/
β βββ app/
β βββ layout.tsx # CopilotKit provider setup
β βββ page.tsx # Main UI with agent integration
β βββ api/
β βββ copilotkit/
β βββ route.ts # CopilotKit API route
βββ .env.example # Environment variables template
βββ README.md
# Development
npm run dev # Start both UI and agent servers
npm run dev:ui # Start only Next.js UI
npm run dev:agent # Start only ADK agent
npm run dev:debug # Start with debug logging
# Production
npm run build # Build for production
npm run start # Start production server
# Maintenance
npm run lint # Run ESLint
npm run install:agent # Install/reinstall Python dependenciesThe agent uses dedicated sub-agents for grounding to avoid tool conflicts:
# Search Agent - Handles web search
search_agent = LlmAgent(
model='gemini-2.5-flash',
name='SearchAgent',
tools=[GoogleSearchTool()],
)
# Maps Agent - Handles location queries
maps_agent = LlmAgent(
model='projects/{project}/locations/{location}/publishers/google/models/gemini-2.5-flash',
name='MapsAgent',
tools=[GoogleMapsGroundingTool()],
)
# Main agent uses them as tools
proverbs_agent = LlmAgent(
tools=[
AgentTool(agent=search_agent),
AgentTool(agent=maps_agent),
# ... other tools
]
)The UI uses CopilotKit's hooks for agent interaction:
const { state, setState } = useCoAgent<AgentState>({
name: "my_agent",
initialState: { /* ... */ }
});
useCopilotAction({
name: "setThemeColor",
parameters: [/* ... */],
handler: async ({ color }) => {
// Handle action
}
});- Verify the agent is running on port 8000
- Check your Google API key is set correctly
- Ensure both servers started successfully
- Confirm
gcloud auth application-default loginis run - Verify your project has Vertex AI API enabled
- Check that
GOOGLE_CLOUD_PROJECTis set correctly
cd agent
source .venv/bin/activate
pip install -r requirements.txt- Ensure Vertex AI is properly configured
- Verify
GOOGLE_GENAI_USE_VERTEXAI=truein your.env - Check that you're using the Vertex AI model path for maps agent
Contributions are welcome! This is a great learning resource for building AI agents.
Built with:
- Google's Agent Development Kit (ADK)
- CopilotKit for agent UI
- AG-UI Protocol for real-time communication
- Vertex AI for grounding capabilities
Next Steps:
- Add more grounding sources (Vertex AI Search)
- Implement authentication
- Deploy to Cloud Run
- Add database persistence