Skip to content

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.

  1. Session is the most fundamental way within the same invocation.
  2. LLM-driven delegation (agent transfer)
  3. Explicit invocation (to treat another BaseAgent as a callable Tool)

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

  1. coordinator / dispatcher
  2. sequential pipeline
  3. parallel fan-out / gather
  4. hierarchical task decomposition (recursively breaking down)
  5. review / critique (generator-critic)
  6. iterative refinement
  7. human-in-the-loop

ADK provides agent config feature to use a YAML file without writing code.

Google ADK as an Example