· 2 min read · ← All posts
Ardan Labs Go Agents Streaming UX

Field notes from working through example 14 of Ardan Labs’ Ultimate AI course by Bill Kennedy and Florin Pățan (Apache 2.0). My fork: PratikDhanave/ai-training. Thank you Bill and Florin for teaching this material — the patterns in this post are derived from the course; the production reflections at the end are mine.

What the example teaches

A non-streaming agent makes the user wait 10-30 seconds while it does its work. A streaming agent shows the same work as it happens — reasoning, tool calls, tool results, partial answers. Same total latency, dramatically better perceived latency.

What it looks like

func StreamAgent(ctx context.Context, w http.ResponseWriter, msg string) {
    w.Header().Set("Content-Type", "text/event-stream")
    flusher := w.(http.Flusher)

    for event := range agent.Run(ctx, msg) {
        switch event.Kind {
        case EventReasoning:
            fmt.Fprintf(w, "event: reasoning\ndata: %s\n\n", event.Text)
        case EventToolCall:
            fmt.Fprintf(w, "event: tool_call\ndata: %s\n\n", event.Tool)
        case EventToolResult:
            fmt.Fprintf(w, "event: tool_result\ndata: %s\n\n", event.Result)
        case EventTokens:
            fmt.Fprintf(w, "event: tokens\ndata: %s\n\n", event.Tokens)
        }
        flusher.Flush()
    }
}

What I learned

Perceived latency dominates real latency for UX. A 20-second agent that streams reasoning feels faster than a 12-second agent that holds the response. Users hate the silent gap.

The reasoning stream is also debugging gold. When the agent does something weird, the stream shows you exactly where the train left the rails. No need to dig through structured logs after the fact.

Production connection

Genie’s /v1/ask/stream endpoint uses this shape — SSE with named events for ai_disclosure, agent.handle, report. The UI subscribes; the user sees the agent’s progress in real-time. Direct lift of the pattern.


Credit & reference. This post is field notes on example 14 from Ardan Labs’ Ultimate AI by Bill Kennedy + Florin Pățan, licensed Apache 2.0. The original example: cmd/examples/example14-streaming-agent/. My fork with notes: PratikDhanave/ai-training. Highly recommend the course for anyone building AI applications in Go — the material is rigorous and the Kronk + yzma + llama.cpp pipeline gives you hardware-accelerated local inference end-to-end. Thank you, Bill and Florin.

← Back to all posts