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.
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
agent.Stream(...)starts a Temporal-backed run; events bridge to the browser as SSE (ev.ToJSON())- Stream id (
agentStream.ID()) and each event’s durable offset are checkpointed - Cancelling the SSE subscriber does not cancel the workflow — Temporal keeps the turn alive
- 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 - On
RUN_FINISHED/RUN_ERROR— checkpoint clears; conversation history remains viaWithConversation/ Postgres
SDK features demonstrated
For setup, run instructions, and app internals see the Agent Chat repository.
Related
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