Skip to main content
Agent Chat is a full-stack reference application built end-to-end with Agent SDK for Go — React UI, Go API, Temporal-backed agent runs, and real-time streaming over SSE.
Demo app for learning and reference. Not intended for production use as-is.

What it demonstrates

Most agent frameworks run in-process — if your HTTP server restarts or the browser drops, the agent turn is gone. Agent Chat shows how the SDK’s Temporal-first model powers a durable chat product:

Architecture

The API and Temporal worker are separate processes from the same server image. APP_MODE selects the role: Both share agent options (name, LLM, conversation, Temporal queue) so the SDK fingerprint check passes.
Conversations and messages live in PostgreSQL. The SDK conversation bridge feeds history into WithConversation on each turn.

Resilience and crash recovery

Without a durable runtime:
  • Browser refresh mid-stream → reply lost
  • API process crash → in-memory agent run gone
  • Long LLM / tool turns → HTTP timeouts force awkward workarounds
With Agent SDK for Go + Temporal:
  1. agent.Stream(...) starts a Temporal-backed run; events bridge to the browser as SSE (ev.ToJSON())
  2. Stream id (agentStream.ID()) and each event’s durable offset are checkpointed
  3. Cancelling the SSE subscriber does not cancel the workflow — Temporal keeps the turn alive
  4. On reconnect — GetAgentStream(savedID) + Events(ctx, WithOffset(savedOffset)) resumes the stream (Temporal runtime; not LocalRuntime). The UI reopens a chat still marked in-progress and continues the same AG-UI → bubble mapping
  5. On RUN_FINISHED / RUN_ERROR — checkpoint clears; conversation history remains via WithConversation / Postgres
Client and worker both use the same agent options so the worker can execute workflows the API started — see Distributed Execution.

SDK features demonstrated

For setup, run instructions, and app internals see the Agent Chat repository.

Reconnect

GetAgentStream + WithOffset after a crash

Durable Agent (Temporal)

SDK durable execution example

Agent Worker

Client and worker split example

Streaming

Stream, Events, and AG-UI wiring