Skip to content
Blog

Understanding the ADK Anatomy: Agents, Runners, Sessions, Events, and Tools

A guided tour of ADK's runtime anatomy: LlmAgent, Runner, Session, Event and Tools, plus the yield/pause/resume event loop that ties them together.

Published on • November 24, 2026

AI Assistant

Every ADK program looks deceptively small — a class definition here, a function there — yet a single user message triggers a sophisticated machinery of components handing events to each other. To debug, extend or deploy an ADK agent well, you need to know the cast by name and understand the choreography between them.

This post is that map: the five load-bearing structures — Agents, Runner, Sessions, Events and Tools — and the cooperative event loop that connects them, drawn from ADK’s technical overview and runtime documentation.

The cast

ComponentWhere it livesOne-line role
Agentgoogle.adk.agents (BaseAgent, LlmAgent aka Agent)Decides what to do; yields events
Workflow agentsSequentialAgent, ParallelAgent, LoopAgentDeterministic orchestration without an LLM
Runnergoogle.adk.runnersOrchestrates one invocation of the event loop
Sessiongoogle.adk.sessions.SessionHolds one conversation’s state + events
Eventgoogle.adk.events.EventCarries content and side effects between components
ToolsFunctionTool, AgentTool, built-insGive agents capabilities beyond chat

Agents: the workers

An LlmAgent bundles a model, an instruction, optional tools, callbacks and sub-agents. For deterministic flows, ADK ships workflow agents — SequentialAgent, ParallelAgent and LoopAgent — which are agents without an LLM: they execute code paths and control sequencing. Agents coordinate by LLM-driven transfer or explicit AgentTool invocation, where an entire agent becomes a tool of another.

Under the hood (Python), agent logic implements _run_async_impl, a generator that yields Event objects instead of returning a single value. That one design choice is why streaming, state commits and multi-step tool calls all flow through the same channel.

Runner: the orchestrator for one invocation

The Runner is the entry point for a single user query — run_async is the primary API across SDKs (the docs note Run in Go, runAsync in Java/TypeScript). Its responsibilities per turn: append the user’s message as an event through the SessionService, kick off the root agent, receive every yielded event, commit the side effects those events declare, and forward the event to your application.

# Conceptual shape of the Runner's loop (from the ADK event-loop docs)
async def run_async(new_query, ...):
    await session_service.append_event(session, Event(author='user', content=new_query))
    async for event in agent_to_run.run_async(context):
        await session_service.append_event(session, event)   # commits state/artifact deltas
        yield event                                          # to your UI or API

An invocation is everything that happens for one user query — potentially several agent runs, LLM calls, tool executions and callbacks — all tied to a single invocation_id.

Sessions: where a conversation lives

A Session (google.adk.sessions.Session) is the container for exactly one conversation thread, with the fields id, app_name, user_id, the state dictionary (working memory), the chronological events list (history), and last_update_time. You never manage it by hand: a SessionService creates, retrieves, appends and deletes sessions.

SessionServicePersistenceInstall / notes
InMemorySessionServiceNone — data lost on restartDefault for dev and tests
DatabaseSessionServiceSQL tables you ownpip install google-adk[db]; async driver required (sqlite+aiosqlite)
VertexAiSessionServiceManaged Google Cloud storagepip install google-adk[gcp]; Agent Runtime resource required

Short-term memory is state inside a session; long-term recall across sessions is the separate Memory service. State keys prefixed temp: are scoped to a single invocation and discarded afterwards.

Events: the universal currency

An Event (google.adk.events.Event) extends the model response with ADK metadata. In Python its conceptual structure is:

# Conceptual structure of an Event (Python)
# class Event(LlmResponse):
#     content: Optional[types.Content]   # text, function_call, function_response
#     partial: Optional[bool]            # streaming chunk?
#     author: str                        # 'user' or agent name
#     invocation_id: str                 # the whole run this belongs to
#     id: str; timestamp: float
#     actions: EventActions              # state_delta, artifact_delta, control signals
#     branch: Optional[str]              # hierarchy path

Everything the framework learns flows through events: text, tool calls (event.get_function_calls()), tool results (event.get_function_responses()), state changes (event.actions.state_delta), artifact saves (event.actions.artifact_delta) and control signals such as transfer_to_agent, escalate and skip_summarization. Your UI filters the stream with event.is_final_response() to show only complete, user-facing output — partial streaming chunks (partial=True) never leak through.

Tools: capabilities with a contract

Tools are how agents act. FunctionTool wraps a plain Python function (type hints and docstring become the schema), AgentTool exposes another agent as a callable tool, and built-ins cover things like Google Search and code execution:

def get_weather(city: str) -> dict:
    """Returns the current weather for a city."""
    return {"city": city, "temp_c": 21}

root_agent = Agent(name="helper", model="gemini-flash-latest",
                   instruction="Use tools when needed.", tools=[get_weather])

Beyond functions, ADK ingests OpenAPI specs and MCP servers, and supports long-running tools (is_long_running=True): their events carry long_running_tool_ids, letting the agent finish its turn while the tool completes in the background. Tool results re-enter history as FunctionResponse events authored by the requesting agent.

The event loop: yield → pause → commit → resume

The runtime’s heartbeat is a cooperative cycle between Runner and execution logic:

agent code runs  ──▶  yield Event  ──▶  PAUSE
▲                                   │
│          Runner: commit state/artifact deltas via SessionService,
│          append to session.events, forward event to your app
└────────── agent RESUMES — guaranteed to see committed state

Two consequences matter in practice. First, state written in a tool or callback is only persisted after the event carrying its state_delta is processed — code after a yield can rely on it; code before it may see uncommitted “dirty reads.” Second, because run_async is the primary API and only non-partial events are committed, streaming UIs must accumulate partial=True chunks themselves.

Pitfalls to remember

  • InMemorySessionService loses every conversation on restart — swap it before production.
  • A missing session raises SessionNotFoundError (a ValueError); create the session first or construct the Runner with auto_create_session=True.
  • Treating every streamed event as a final message garbles the UI — filter with is_final_response().
  • Mutating session.state and expecting immediate durability breaks under retries; let the event’s delta commit it.

Takeaway: ADK’s anatomy is a strict division of labor — Agents decide and yield, the Runner orchestrates and commits, Sessions store state and history, Events carry every message and side effect, and Tools extend capability — all synchronized by a yield/pause/commit/resume loop that makes streaming, persistence and debugging three views of the same event stream.

Sources