$npx -y skills add VeerMuchandi/rad-skills --skill adk_developerComprehensive guide to building, orchestrating, and deploying agents with the Google Agent Development Kit (ADK).
| 1 | # ADK Developer Skill |
| 2 | |
| 3 | This document serves as a long-form, comprehensive reference for building, orchestrating, and deploying AI agents using the Python Agent Development Kit (ADK). It covers every significant aspect with detailed code examples and in-depth best practices. |
| 4 | |
| 5 | |
| 6 | ## 0. Skill Initialization |
| 7 | **CRITICAL**: This skill relies on local reference documentation that must be kept in sync with the official repository. |
| 8 | |
| 9 | **When starting a new session or tasks involving ADK:** |
| 10 | 1. **Ask Permission**: "Shall I check for updates to the ADK references from the official global cache?" |
| 11 | 2. **Execute Update**: If the user agrees, run: |
| 12 | ```bash |
| 13 | python3 scripts/update_skill.py |
| 14 | ``` |
| 15 | 3. **Confirm**: Report the update status before proceeding. |
| 16 | |
| 17 | ## 1. Golden Rules for ADK Development |
| 18 | > [!IMPORTANT] |
| 19 | > 1. **Always use Vertex AI**: Set `GOOGLE_GENAI_USE_VERTEXAI=True`. |
| 20 | > 2. **Configuration**: Ask for `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` from the user. |
| 21 | > 3. **Models**: Use `gemini-2.5-flash` or higher. **NEVER** use `gemini-1.5-flash` or `gemini-1.5-pro`. |
| 22 | > 4. **Directory Structure**: **NEVER** put code in the root folder. Always create specific agent subfolders (e.g., `my_agent/`). |
| 23 | > 5. **Simplicity First**: **ALWAYS** start with a single `LlmAgent`. Only introduce Workflow/Multi-Agent architectures if the task complexity specifically demands it (e.g., rigid determinism, context limits). Do not over-engineer. |
| 24 | > 6. **Process Boundaries**: When asked to **Design**, produce the design artifact and **STOP**. Do not implement code until explicitly requested. |
| 25 | > 7. **Configuration Protocol**: **NEVER** assume values for `GOOGLE_CLOUD_PROJECT`, `GOOGLE_CLOUD_LOCATION`, or other secrets. **ALWAYS** ask the user for these values before creating configuration files. |
| 26 | |
| 27 | ## Table of Contents |
| 28 | |
| 29 | 1. [Core Concepts & Project Structure](#1-core-concepts--project-structure) |
| 30 | 2. [Agent Definitions (`LlmAgent`)](#2-agent-definitions-llmagent) |
| 31 | 3. [Orchestration with Workflow Agents](#3-orchestration-with-workflow-agents) |
| 32 | 4. [Multi-Agent Systems & Communication](#4-multi-agent-systems--communication) |
| 33 | 5. [Building Custom Agents (`BaseAgent`)](#5-building-custom-agents-baseagent) |
| 34 | 6. [Models: Gemini, LiteLLM, and Vertex AI](#6-models-gemini-litellm-and-vertex-ai) |
| 35 | 7. [Tools: The Agent's Capabilities](#7-tools-the-agents-capabilities) |
| 36 | 8. [Context, State, and Memory Management](#8-context-state-and-memory-management) |
| 37 | 9. [Runtime, Events, and Execution Flow](#9-runtime-events-and-execution-flow) |
| 38 | 10. [Control Flow with Callbacks](#10-control-flow-with-callbacks) |
| 39 | 11. [Authentication for Tools](#11-authentication-for-tools) |
| 40 | 12. [Deployment Strategies](#12-deployment-strategies) |
| 41 | 13. [Evaluation and Safety](#13-evaluation-and-safety) |
| 42 | 14. [Debugging, Logging & Observability](#14-debugging-logging--observability) |
| 43 | 15. [Streaming & Advanced I/O](#15-streaming--advanced-io) |
| 44 | 16. [Performance Optimization](#16-performance-optimization) |
| 45 | 17. [General Best Practices & Common Pitfalls](#17-general-best-practices--common-pitfalls) |
| 46 | 18. [Official API & CLI References](#18-official-api--cli-references) |
| 47 | |
| 48 | --- |
| 49 | |
| 50 | ## 1. Core Concepts & Project Structure |
| 51 | |
| 52 | ### 1.1 ADK's Foundational Principles |
| 53 | |
| 54 | * **Modularity**: Break down complex problems into smaller, manageable agents and tools. |
| 55 | * **Composability**: Combine simple agents and tools to build sophisticated systems. |
| 56 | * **Observability**: Detailed event logging and tracing capabilities to understand agent behavior. |
| 57 | * **Extensibility**: Easily integrate with external services, models, and frameworks. |
| 58 | * **Deployment-Agnostic**: Design agents once, deploy anywhere. |
| 59 | |
| 60 | ### 1.2 Essential Primitives |
| 61 | |
| 62 | * **`Agent`**: The core intelligent unit. Can be `LlmAgent` (LLM-driven) or `BaseAgent` (custom/workflow). |
| 63 | * **`Tool`**: Callable function/class providing external capabilities (`FunctionTool`, `OpenAPIToolset`, etc.). |
| 64 | * **`Session`**: A unique, stateful conversation thread with history (`events`) and short-term memory (`state`). |
| 65 | * **`State`**: Key-value dictionary within a `Session` for transient conversation data. |
| 66 | * **`Memory`**: Long-term, searchable knowledge base beyond a single session (`MemoryService`). |
| 67 | * **`Artifact`**: Named, versioned binary data (files, images) associated with a session or user. |
| 68 | * **`Runner`**: The execution engine; orchestrates agent activity and event flow. |
| 69 | * **`Event`**: Atomic unit of communication and history; carries content and side-effect `actions`. |
| 70 | * **`InvocationContext`**: The comprehensive root context object holding all runtime information for a single `run_async` call. |
| 71 | |
| 72 | ### 1.3 Standard Project Layout |
| 73 | |
| 74 | A well-structured ADK project is crucial for maintainability and leveraging `adk` CLI tools. |
| 75 | |
| 76 | ```text |
| 77 | your_project_root/ |
| 78 | ├── my_first_agent/ # Each folder is a distinct agent |