Skip to content
Blog

Streaming Graph Progress: Emitting Node Progress Events to Frontend Clients

Learn how to yield user-facing progress events from ADK 2.0 graph nodes, stream them from the Runner to clients over SSE or websockets, and keep node output separate from what the user sees.

Published on • December 2, 2026

AI Assistant

A user clicks “Run research workflow” and stares at a spinner for forty seconds. The graph is doing exactly what it should — fetching sources, summarizing, validating — but the client sees nothing, so the user refreshes the page and starts over. Progress is not a nice-to-have in long-running graphs; it is the difference between a workflow that feels alive and one that looks hung.

ADK already solves half of this problem: every step of a graph workflow flows through the runtime as an Event, and the Runner forwards each one upstream the moment it is processed. What you need to know is which event field carries user-facing progress, which carries data for the next node, and how to pipe that stream into a browser without confusing the two. In this tutorial you will learn exactly that — and build an SSE endpoint that streams graph progress to a frontend.

Prerequisites

  • ADK 2.0 graph workflows (Workflow, nodes, edges) — see the graph routes docs
  • Familiarity with Runner, sessions, and events (the event loop page)
  • Python 3.10+ and a passing knowledge of async generators
  • FastAPI for the SSE sketch (optional — the pattern transfers to any web framework)

1. Three fields, three audiences

Inside a graph node, an Event can carry data for three completely different destinations. The data handling docs split them cleanly:

  • output — data passed to the next node. This is the graph’s plumbing.
  • message — data intended as a response to the user. The runtime renders it; the graph does not forward it to the next node.
  • state — data persisted across nodes via events for the life of the session.

In TypeScript the user-facing field is spelled content instead of message, but the semantics are identical: “Use content for the user and output for the next node.”

This separation is the whole trick. A node can announce what it is doing to a human and hand a structured payload to its successor — by emitting two events, where only one carries output:

async def research_node(node_input: str):
    yield Event(message="Gathering sources...")          # user sees this
    sources = await fetch_sources(node_input)
    yield Event(message=f"Found {len(sources)} sources")  # user sees this too
    yield Event(output=sources)                           # next node gets this

message events are invisible to the graph’s data flow. output events are invisible to the user — unless you deliberately forward them, which is where streaming comes in.

2. Yielding progress from inside a node

Use return when a node produces a single value with no fanfare. Use yield — an async generator — when a node has more than one thing to say:

from google.adk import Event

async def enrich_alert(node_input: dict):
    """A node that streams progress while producing one output."""
    yield Event(message=f"Looking up runbook for {node_input['service']}...")
    runbook = lookup_runbook(node_input["service"])
    yield Event(message="Checking recent deployments...")
    recent = fetch_recent_deploys(node_input["service"])
    yield Event(output={**node_input, "runbook": runbook, "recent_deploys": recent})

Each yield emits a separate Event immediately. The user watching the stream sees “Looking up runbook…” before the second lookup finishes — no polling, no progress API, no guessing.

Two rules keep this honest:

  1. Progress costs nothing but a yield. A message-only event does not touch the graph’s data flow, so you can be generous with status updates.
  2. Only one output per execution. More on that in section 6 — it is the rule people break.

3. What the Runner does with every event

The event loop page describes a cooperative cycle between your node code and the Runner:

  1. Your node logic constructs an Event and yields it.
  2. Execution pauses immediately after the yield.
  3. The Runner receives the event, commits any state_delta / artifact_delta through the SessionService, and forwards the event upstream to your application.
  4. Only then does your node resume from the next statement.

The conceptual Runner loop looks like this:

async def run_async(new_query, ...) -> AsyncGenerator[Event, None]:
    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)  # commit deltas
        yield event                                         # forward to your app

Two consequences matter for streaming UIs:

  • Forwarding happens per event, not per turn. Your application consumes a live generator of events — progress messages included — not a single final blob.
  • State committed before resume. When your node continues after a yield, the state changes carried by that event are guaranteed persisted. Progress messages and state updates travel together reliably.

There is also event.partial: True means this event is an incomplete chunk of streamed model text and more will follow. Partial chunks flow through the same loop, so token-by-token streaming of an agent node’s answer works the same way as your own progress messages.

4. Distinguishing progress from output in the client

The events reference gives you the vocabulary. An event arriving at your application tells you:

  • Who produced it — event.author ('user' or an agent/node name)
  • What it carries — text parts, get_function_calls(), get_function_responses()
  • Whether it is a streaming chunk — event.partial
  • Whether the turn is done — event.is_final_response(), which filters out tool calls, tool results, and partial chunks

A practical serializer for a frontend stream tags each event by intent:

def serialize(event) -> dict:
    text = ""
    if event.content and event.content.parts and event.content.parts[0].text:
        text = event.content.parts[0].text

    if event.partial:
        kind = "chunk"            # token streaming
    elif event.is_final_response():
        kind = "final"            # complete, displayable answer
    else:
        kind = "progress"         # your Event(message=...) updates

    return {"author": event.author, "kind": kind, "text": text}

This is the distinction the topic keeps circling: progress messages are events you choose to display; node output is data the graph consumes. The frontend never sees output unless you serialize it deliberately — and it usually should not, since output is often a structured object meant for the next node, not a human.

5. Streaming to a frontend over SSE

Your application already iterates the runner. Turning that into a server-sent events endpoint is a thin wrapper:

import json

from fastapi import FastAPI
from fastapi.responses import StreamingResponse
from google.genai import types

app = FastAPI()

@app.post("/run")
async def run(payload: dict):
    async def event_stream():
        message = types.Content(role="user", parts=[types.Part(text=payload["message"])])
        async for event in runner.run_async(
            user_id=payload["user_id"],
            session_id=payload["session_id"],
            new_message=message,
        ):
            yield f"data: {json.dumps(serialize(event))}\n\n"

    return StreamingResponse(event_stream(), media_type="text/event-stream")

On the client, EventSource only speaks GET, so either accept GET /run?message=... or read the POST response with fetch and a ReadableStream:

const res = await fetch("/run", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ message, user_id, session_id }),
});
const reader = res.body.getReader();
const decoder = new TextDecoder();
while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  for (const line of decoder.decode(value).split("\n\n")) {
    if (!line.startsWith("data: ")) continue;
    const evt = JSON.parse(line.slice(6));
    if (evt.kind === "chunk") appendToken(evt.text);
    else if (evt.kind === "progress") showStatus(evt.text);
    else if (evt.kind === "final") showFinal(evt.text);
  }
}

Zero-build alternative: adk api_server already exposes a POST /run_sse endpoint that streams events as SSE. If you only need progress in a demo or internal tool, point your frontend at the API server and skip the custom route entirely.

A websocket works the same way — swap StreamingResponse for a socket and push the same serialized dictionaries. SSE is simpler (auto-reconnect, no upgrade handshake); websockets earn their complexity when you also need client-to-server messages mid-run, such as answering a human-input node.

6. The one-output-per-execution rule

Here is the constraint that shapes every progress-emitting node:

Nodes are only allowed to emit a single Event.output data payload per execution. While you can use more than one yield in a node, having two or more yield commands with an Event.output results in a runtime error.

In Python, a second output is a hard failure. In TypeScript the docs note a softer failure mode: multiple outputs do not raise, but each overwrites the previous one and the successor receives only the final value — silent data loss. Either way, the contract is the same: one output, any number of messages.

The correct pattern is what section 1 showed — interleaved yields where progress events carry message and exactly one event carries output. If a node genuinely produces multiple data items, aggregate them into one structured payload (a dict or Pydantic model) and emit that as the single output.

This rule also protects your frontend: because only one event per node carries graph data, every other event in the stream is safe to render as progress without accidentally leaking an intermediate payload into the UI.

7. Checklist

Before you ship a streaming graph UI:

  • Every node that takes more than a second yields Event(message=...) progress updates.
  • Exactly one output per node execution — progress never rides on output.
  • Your client serializer distinguishes chunk / progress / final using event.partial and event.is_final_response().
  • Progress events are display-only; the frontend does not parse output payloads.
  • The SSE route buffers nothing — each yield reaches the network immediately.
  • Long model calls inside agent nodes are consumed with partial events enabled, so token streaming appears between your progress messages.
  • A demo run shows progress before the first node finishes, not just at the end.

Progress streaming turns a graph from a black box into a narrated process. ADK hands you the event stream for free; the only real work is labeling each event correctly so the browser shows the story instead of the plumbing.

References