ADK
SOTA ADKs
SOTA ADKs include: - Google - OpenAI - Claude - OpenHands - LangChain - CrewAI
Core Concepts
ADK is built around a few key primitives and concepts:
- Agent
- Tool: capabilities beyond text generation
- Docstrings are crucial
- Callbacks: functions that allow to hook into specific points in the agent's execution lifecycle
- Useful for input safety
- Session Management: the context of a single conversation (events + state)
- Memory: information across multiple sessions
- Artifact Management
- Code Execution
- Planning
- Models
- Event: as the basic unit of communication during a session
- Runner: the engine that orchestrates the interaction flow
Agents
3 types of agents: LLM agents, workflow agents and custom agents. Among the agents, LLM agents are non-deterministic while workflow agents are deterministic and follow predefined execution paths.
ADK provides three core workflow agent types, each implementing a distinct execution pattern: - Sequential - Loop - Parallel
We can combine LLM agents and workflow agents to implement more complex logic as the custom agents.
Communication and Interaction
Agents often need more than just the latest user message to perform well.
- Session is the most fundamental way within the same invocation.
- LLM-driven delegation (agent transfer)
- Explicit invocation (to treat another
BaseAgentas a callableTool)
Context
The central piece is InvocationContext, managed by ADK framework itself.
Sessions server for the whole conversation, while context is just for one instruction.
Async
Interactions with LLMs and potentially tools (like external APIs) are I/O-bound operations. Using asyncio allows the program to handle these operations efficiently without blocking execution.
Session State
session.state provides memory for agents, identified by APP_NAME, USER_ID, SESSION_ID. It stores information for multiple conversational turns.
Both agents and tools can read from and write to the session state, via ToolContext or output_key.
Tools
When using a LongRunningFunctionTool, your function can initiate the long-running operation and optionally return an initial result, such as a long-running operation id.
Common Orchestration Patterns
- coordinator / dispatcher
- sequential pipeline
- parallel fan-out / gather
- hierarchical task decomposition (recursively breaking down)
- review / critique (generator-critic)
- iterative refinement
- human-in-the-loop
ADK provides agent config feature to use a YAML file without writing code.