theme-pure

You've built an agent. You've set up sessions. Now what?

How do you actually make the thing run?

Enter the Runner — the unsung hero of Google ADK. It's the component that takes your agent, connects it to sessions, and orchestrates the entire conversation flow. Think of it as the engine that makes everything move.

Let's break it down.


What Does the Runner Actually Do?

The Runner handles three critical jobs:

1. Connects your agent to sessions — It knows which conversation belongs to which user.

2. Manages the execution loop — It sends messages, gets responses, and handles tool calls.

3. Returns results — It gives you back events you can process or stream to users.

Without a Runner, your agent just sits there. The Runner brings it to life.


The Simplest Runner Example

Here's the bare minimum to get an agent running:

That's your engine. Now let's use it.


Running Your Agent

The Runner has one main method: run(). It takes a session ID and a message, then returns the agent's response.

Clean and simple. The Runner handles all the complexity behind the scenes.


Streaming Responses

Nobody likes staring at a blank screen. Streaming lets you show responses as they're generated — much better UX.

The run_stream() method returns an iterator of events. Each event contains a chunk of the response. Print them as they arrive and your users see text appearing in real-time.


Async Support

Building a web app? You'll want async. The Runner has you covered:


Use run_async() for non-blocking execution. Perfect for FastAPI, Flask, or any async framework.


A Complete Example

Let's put it all together — a simple chatbot that maintains conversation history:

Run this and you've got a working chatbot. The Runner maintains context automatically — ask follow-up questions and it remembers what you talked about.


Key Takeaways

The Runner is the glue between your agent and the outside world. Remember these three methods:

run() — Synchronous, waits for complete response

run_stream() — Returns events as they happen

run_async() — Non-blocking for async applications


Wrapping Up

The Runner might not be glamorous, but it's essential. It's the engine that turns your agent definition into actual conversations.

Create it once, pass in session, and let it handle the heavy lifting. That's the ADK way.

Leave A Comment

Your Name

Your Email

Your Comment