Agent skill
cva-concepts-adk
Google ADK (Agent Development Kit) architecture and core concepts. Covers agent types (LLM, Sequential, Parallel, Loop, Multi-agent), tool ecosystem, execution flows, deployment options, and observability. Model-agnostic framework for production AI agents. Use when understanding ADK architecture, selecting agent patterns, designing agent systems, or deploying to Vertex AI.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/cva-concepts-adk
SKILL.md
Google ADK (Agent Development Kit) - Architecture
Framework: Open-source by Google Version: 0.2.0+ Production: Powers Google Agentspace and CES Documentation: https://google.github.io/adk-docs/
π― What is Google ADK?
Agent Development Kit (ADK) is Google's open-source framework for developing and deploying AI agents.
Key Characteristics
- π§ Model-agnostic - Works with Gemini, OpenAI, Claude, Llama, etc.
- π Deployment-agnostic - Local, Vertex AI, Cloud Run, GKE, Kubernetes
- π§ Framework-compatible - Integrates with LangChain, CrewAI, custom tools
- π’ Production-ready - Battle-tested in Google products
- π Interoperable - Java and Python SDKs with identical APIs
ποΈ Core Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Your Application β
β (Clojure via Java interop) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Agent Layer β
β ββββββββββββ ββββββββββββ ββββββββββββββββββββ β
β β LLM β β Workflow β β Multi-Agent β β
β β Agent β β Agent β β System β β
β ββββββββββββ ββββββββββββ ββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Tool Ecosystem β
β βββββββββββ βββββββββββ ββββββββββ ββββββββββββ β
β βBuilt-in β β Custom β β OpenAPIβ βThird-partyβ β
β β Tools β βFunctionsβ β Tools β β (LC) β β
β βββββββββββ βββββββββββ ββββββββββ ββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LLM Layer β
β Gemini | Claude | GPT | Open Models β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π€ Agent Types
1. LLM Agent (Dynamic Routing)
Concept: Agent uses LLM to make decisions about which actions to execute.
When to use:
- β Adaptive behavior based on context
- β Multiple tools available
- β Complex decisions required
- β Unpredictable input patterns
Clojure Example:
(ns lab.agents.llm-agent
"LLM Agent with dynamic tool selection"
(:import [com.google.adk.agent LLMAgent]
[com.google.adk.model GeminiModel]
[com.google.adk.tool Tool]))
(defn create-calculator-tool
"Custom calculator tool"
[]
(-> (Tool/builder)
(.setName "calculator")
(.setDescription "Performs basic arithmetic operations")
(.setFunction
(reify java.util.function.Function
(apply [_ input]
;; Parse and execute calculation
(str "Result: " (eval (read-string input))))))
(.build)))
(defn create-llm-agent
"Creates LLM agent with tools"
[tools]
(-> (LLMAgent/builder)
(.setModel
(-> (GeminiModel/builder)
(.setModelName "gemini-1.5-flash")
(.setTemperature 0.7)
(.build)))
(.addTools tools)
(.setSystemPrompt "You are a helpful assistant with access to tools.")
(.build)))
;; REPL Usage
(comment
(def tools [(create-calculator-tool)])
(def agent (create-llm-agent tools))
(.execute agent "What is 25 * 4?")
;; Agent decides to use calculator tool
;; => "The result is 100"
)
Flow:
Input β LLM decides β Selects Tool β Executes β LLM synthesizes β Output
2. Workflow Agents (Structured)
2.1 Sequential Agent
Concept: Execute steps in predetermined order.
When to use:
- β Fixed pipeline (ETL, data processing)
- β Deterministic execution required
- β Lower cost (no LLM routing overhead)
(ns lab.agents.sequential
(:import [com.google.adk.agent SequentialAgent]
[com.google.adk.agent.step LLMStep]))
(defn create-sequential-pipeline
"Sequential agent for data processing"
[]
(-> (SequentialAgent/builder)
(.addStep
(-> (LLMStep/builder)
(.setPrompt "Extract key entities from: {{input}}")
(.setModel "gemini-1.5-flash")
(.build)))
(.addStep
(-> (LLMStep/builder)
(.setPrompt "Classify entities: {{previous_output}}")
(.build)))
(.addStep
(-> (LLMStep/builder)
(.setPrompt "Generate summary: {{previous_output}}")
(.build)))
(.build)))
;; REPL Usage
(comment
(def pipeline (create-sequential-pipeline))
(.execute pipeline "Process this medical text...")
;; Step 1: Extract entities
;; Step 2: Classify
;; Step 3: Summarize
;; => Final summary
)
Flow:
Input β Step 1 β Step 2 β Step 3 β ... β Output
2.2 Parallel Agent
Concept: Execute multiple agents concurrently.
When to use:
- β Independent tasks can run simultaneously
- β Need to reduce latency
- β Aggregating results from multiple sources
(ns lab.agents.parallel
(:import [com.google.adk.agent ParallelAgent]))
(defn create-parallel-researcher
"Parallel agent for multi-source research"
[]
(-> (ParallelAgent/builder)
(.addAgent "scholar" (create-scholar-agent))
(.addAgent "pubmed" (create-pubmed-agent))
(.addAgent "web" (create-web-search-agent))
(.setAggregationStrategy :merge-all)
(.build)))
;; REPL Usage
(comment
(def researcher (create-parallel-researcher))
(.execute researcher "Research: effectiveness of salicylic acid")
;; Executes 3 agents concurrently:
;; - Google Scholar search
;; - PubMed search
;; - Web search
;; => Aggregated results from all sources
)
Flow:
Input β β¬β Agent 1 ββ
ββ Agent 2 ββΌβ Aggregate β Output
ββ Agent 3 ββ
2.3 Loop Agent
Concept: Repeat execution until condition met.
When to use:
- β Iterative refinement needed
- β Quality threshold must be reached
- β Self-correction workflows
(ns lab.agents.loop
(:import [com.google.adk.agent LoopAgent]))
(defn create-refining-agent
"Loop agent that refines output until quality threshold"
[]
(-> (LoopAgent/builder)
(.setAgent (create-writer-agent))
(.setMaxIterations 5)
(.setCondition
(reify java.util.function.Predicate
(test [_ output]
(>= (calculate-quality-score output) 0.8))))
(.build)))
;; REPL Usage
(comment
(def refiner (create-refining-agent))
(.execute refiner "Write professional medical article")
;; Iteration 1: quality = 0.6
;; Iteration 2: quality = 0.75
;; Iteration 3: quality = 0.85 β
;; => Returns iteration 3 output
)
Flow:
Input β Execute β Check condition βNoββ
β β
Yes β
β β
Output ββββββββββ
3. Multi-Agent Systems
Concept: Coordinate multiple specialized agents.
Patterns:
- Hierarchical: Manager agent delegates to worker agents
- Collaborative: Agents negotiate and share information
- Competitive: Best result selected from multiple approaches
(ns lab.agents.multi-agent
(:import [com.google.adk.agent MultiAgentSystem]))
(defn create-healthcare-system
"Multi-agent system for healthcare content generation"
[]
(-> (MultiAgentSystem/builder)
(.addAgent "extractor" (create-data-extraction-agent))
(.addAgent "validator" (create-claims-validator-agent))
(.addAgent "researcher" (create-reference-search-agent))
(.addAgent "seo" (create-seo-optimizer-agent))
(.addAgent "consolidator" (create-final-consolidator-agent))
(.setOrchestrationStrategy :sequential-with-feedback)
(.build)))
π Complete implementation: See
cva-healthcare-pipelinefor production multi-agent system.
π§ Tool Ecosystem
Built-in Tools
Available out-of-box:
- Web search (Google Search, Google Scholar)
- Code execution (Python, JavaScript)
- Data retrieval (BigQuery, Cloud Storage)
- API calls (REST, GraphQL)
Custom Tools (Clojure)
(ns lab.tools.custom
(:import [com.google.adk.tool Tool]))
(defn create-database-query-tool
"Custom tool for database queries"
[db-spec]
(-> (Tool/builder)
(.setName "query_database")
(.setDescription "Queries PostgreSQL database for tenant data")
(.setInputSchema
{:type "object"
:properties {:query {:type "string"
:description "SQL query to execute"}}
:required ["query"]})
(.setFunction
(reify java.util.function.Function
(apply [_ input]
(let [query (get input "query")]
(jdbc/execute! db-spec [query])))))
(.build)))
Tool Composition
Combine tools from different sources:
(defn create-hybrid-agent
"Agent with built-in + custom + third-party tools"
[]
(let [built-in-search (GroundingTool/googleSearch)
custom-db (create-database-query-tool db-spec)
langchain-tool (from-langchain wikipedia-tool)]
(create-llm-agent [built-in-search custom-db langchain-tool])))
π Deployment Options
1. Local Development
# Run locally with Clojure CLI
clojure -M:dev -m lab.core
2. Vertex AI Agent Engine
(ns lab.deployment.vertex
(:import [com.google.cloud.vertexai.agent AgentEngine]))
(defn deploy-to-vertex
"Deploy agent to Vertex AI Agent Engine"
[agent project-id]
(-> (AgentEngine/builder)
(.setProjectId project-id)
(.setLocation "us-central1")
(.setAgent agent)
(.deploy)))
;; REPL Usage
(comment
(deploy-to-vertex my-agent "saas3-476116")
;; => Deployed to Vertex AI with endpoint URL
)
3. Cloud Run (Container)
FROM clojure:openjdk-17-tools-deps
COPY . /app
WORKDIR /app
RUN clojure -M:build
CMD ["clojure", "-M:prod"]
# Deploy to Cloud Run
gcloud run deploy agent-service \
--source . \
--region us-central1 \
--allow-unauthenticated
π Observability
Logging
(ns lab.observability.logging
(:require [clojure.tools.logging :as log]))
(defn execute-with-logging
"Execute agent with comprehensive logging"
[agent input]
(log/info "Agent execution started" {:input input})
(let [start-time (System/currentTimeMillis)
result (.execute agent input)
duration (- (System/currentTimeMillis) start-time)]
(log/info "Agent execution completed"
{:duration-ms duration
:output-length (count result)
:success true})
result))
Metrics
Track key metrics:
- Execution time
- Token usage
- Tool invocations
- Error rates
- Cost per execution
(defn track-metrics
[agent input]
(let [metrics (atom {})]
(add-watch agent :metrics
(fn [_ _ _ new-state]
(swap! metrics assoc
:tokens (:tokens-used new-state)
:tools-called (:tool-invocations new-state))))
(.execute agent input)
@metrics))
π‘ Best Practices
1. Start Simple, Optimize Later
Progression:
LLM Agent β Sequential Agent β Parallel Agent β Multi-Agent System
(Day 1) (Week 1) (Month 1) (Production)
Rationale: Build complexity incrementally based on actual requirements.
2. Choose the Right Agent Type
Decision Matrix:
| Need | Agent Type | Reason |
|---|---|---|
| Simple task, one path | Sequential | Lowest cost, deterministic |
| Complex routing needed | LLM | Flexibility, adaptability |
| Independent parallel tasks | Parallel | Reduced latency |
| Iterative refinement | Loop | Quality improvement |
| Complex system | Multi-Agent | Specialized expertise per component |
π Detailed guidance: See
cva-concepts-agent-typesfor A/B/C/D taxonomy.
3. Tool Design Principles
- Single Responsibility: One tool = one clear function
- Descriptive Names:
query_customer_databasenotdb - Rich Descriptions: Help LLM understand when to use tool
- Error Handling: Return structured errors, not exceptions
- Idempotent: Safe to retry
4. Model Selection
By task complexity:
- Simple (extraction, classification):
gemini-1.5-flash - Medium (reasoning, personalization):
gemini-1.5-proorclaude-3-5-haiku - Complex (consolidation, critical decisions):
claude-3-5-sonnetorgemini-2.0-flash-thinking
π Cost optimization: See
cva-patterns-costfor multi-model routing.
5. Testing Strategy
(ns lab.testing.agents
(:require [clojure.test :refer :all]))
(deftest test-agent-execution
(testing "Agent produces valid output"
(let [agent (create-test-agent)
result (.execute agent "test input")]
(is (string? result))
(is (> (count result) 0))
(is (valid-json? result)))))
(deftest test-agent-tools
(testing "Agent uses correct tools"
(let [agent (create-test-agent-with-mock-tools)
_ (.execute agent "calculate 2 + 2")
tool-calls (get-tool-invocations agent)]
(is (= 1 (count tool-calls)))
(is (= "calculator" (:tool-name (first tool-calls)))))))
6. Error Handling
(defn execute-with-retry
"Execute agent with exponential backoff retry"
[agent input max-retries]
(loop [attempt 1]
(try
(.execute agent input)
(catch Exception e
(if (< attempt max-retries)
(do
(Thread/sleep (* 1000 (Math/pow 2 attempt)))
(recur (inc attempt)))
(throw e))))))
π Related Skills
cva-concepts-agent-types- A/B/C/D agent taxonomy βcva-quickref-adk- ADK API quick reference βcva-patterns-workflows- Multi-agent workflow patternscva-patterns-cost- Cost optimization strategiescva-healthcare-pipeline- Production multi-agent systemcva-setup-vertex- Vertex AI deployment setup
π Additional Resources
Official Documentation
Advanced Topics
This skill provides foundational ADK knowledge. Combine with agent-types taxonomy and workflow patterns for complete understanding.
Didn't find tool you were looking for?