Chapter 2: Architecture and Runner Lifecycle
April 13, 2026 ยท View on GitHub
Welcome to Chapter 2: Architecture and Runner Lifecycle. In this part of ADK Python Tutorial: Production-Grade Agent Engineering with Google's ADK, you will build an intuitive mental model first, then move into concrete implementation details and practical production tradeoffs.
This chapter explains ADK's execution model so you can reason about behavior under load and during failures.
Learning Goals
- understand the stateless runner model
- map invocation lifecycle steps end-to-end
- see where sessions, artifacts, and memory fit
- design around event persistence and compaction
Runner Lifecycle (Mental Model)
- retrieve session state from session service
- build invocation context for current turn
- run agent reason-act loop
- stream and persist events
- optionally compact historical events
Design Implications
- keep agent code deterministic per invocation
- treat persistence services as system boundaries
- design event schemas for observability and replay
Source References
Summary
You now understand why ADK runner behavior is reliable when state is externalized and lifecycle boundaries are explicit.
Next: Chapter 3: Agent Design and Multi-Agent Composition
Source Code Walkthrough
google/adk/runners.py
The Runner class in google/adk/runners.py is the entry point for the architecture covered in this chapter. It wires together the agent, session service, and memory service into the request/response lifecycle. Tracing the run_async method shows how events flow from user input through the agent graph and back to the caller, which is the central architectural pattern this chapter explains.