Skip to main content
A chat agent is three parts: a long-lived agent task that runs the turn loop, a durable Session carrying messages in and the response stream out, and a frontend transport that plugs the session into useChat. The pages in this section each own one part of that picture. This page is the map — if you’d rather read mechanics end to end, skip to How it works. Everything below maps onto one annotated agent:
trigger/my-agent.ts
The frontend side is one hook — useTriggerChatTransport connects useChat to the agent’s session, no API routes (Frontend). Underneath, the conversation lives on a Session: a pair of durable streams keyed on your chatId that survives refreshes, deploys, and run boundaries.

Where each part is covered

PartPage
chat.agent() options, the turn loop, pipingBackend
Hooks around each turn (onTurnComplete, hydration)Lifecycle hooks
Declaring tools, typed payloads, toModelOutputTools
useChat wiring, tokens, starting sessionsFrontend
Driving a chat from your server instead of a browserServer-side chat
The durable substrate under every agentSessions
Per-run typed state inside the loopchat.local
Type-safe payloads, client data, and messagesTypes
Building without the managed lifecycleCustom agents
End-to-end mechanics: what survives a refresh and whyHow it works
Beyond this section: Features covers opt-in capabilities (Head Start, compaction, steering, actions), and Patterns covers production recipes (sub-agents, HITL approvals, persistence, recovery).