chat.agent

Build reliable
chat agents

Build chat agents in TypeScript with no timeouts. Keep state between turns, sleep while idle, and let users pick up the conversation after a refresh.

16 reasons to use chat agent


Reason 01

Your chat survives refreshes, deploys and crashes

Refresh the page or come back after a crash. Your conversation is still there. Deploys leave existing chats on the version they started on.

Reason 02

The whole backend is one function

Use chat.agent with streamText on the backend and useChat from the AI SDK on the frontend.

const transport =
useTriggerChatTransport({
accessToken,
});
const chat = useChat({ transport });
import { chat } from "@trigger.dev/sdk/ai";
import { streamText } from "ai";
export const agent = chat.agent({
id: "research-agent",
run: async ({ messages, signal }) =>
streamText({
model: "claude-sonnet-4.5",
messages,
abortSignal: signal,
}),
});
Reason 03

Used in production at scale

Arena

“With chat.agent, every conversation gets a real machine, which made our durable agents much more straightforward to build. The default tracing and observability make viewing and debugging agentic sessions incredibly easy.”

Graham Tremper

Arena

Arena
Reason 04

Every LLM call is traced

Turns, tool calls and model requests land in a trace automatically, with logs and metrics alongside them. Export everything through OpenTelemetry.

Every LLM call is traced

Turns, tool calls and model requests land in a trace automatically, with logs and metrics alongside them. Export everything through OpenTelemetry.

See spend and token usage across every run

Query input and output tokens, cost and latency by task, model or prompt version.

Prompts are versioned

Manage your system prompt as versioned config with typed variables. Override it without a deploy, and link every LLM call to the version that produced it.

Reason 05

Write agents that coding agents understand

Write your agents in plain TypeScript. Coding agents already know how. Use normal loops and API calls, without structuring your code around replay rules.

You
build ai agnet in typescript pls. No misteaks
Claude
Thinking…Thought for a moment
Plain TypeScript, a tool or two, and absolutely no steaks. Understood.
Let’s build it with Trigger.dev. Your agent is a TypeScript function, so I can write it using the code and tools you already have. No new language to learn. First, the agent. Then, a tool it can call.
Reason 06

Durable streaming out of the box

Refresh mid-response and the stream picks up where your browser stopped reading, without re‑running the model.

Reason 07

Build rich experiences

An agent can do more than reply. Build dashboards, canvases, and creative tools that users can shape as they go.

Reason 08

A real Linux machine per agent

Run ffmpeg, a headless browser, or any CLI that expects a real filesystem and process tree.

A condensed replay of recorded FFmpeg output illustrates the transcode tool in a Trigger.dev chat agent. A six-second input video is encoded to an H.264 MP4 file. This is not a render-speed benchmark.

Reason 09

No timeout on a turn

A single turn can run as long as it needs to, including slow tools and sub-agents that think for minutes, hours, or even days.

Reason 10

Pause for human approval

Let your agent do the work. Bring in a human when it matters, then pick up exactly where you left off.

support.acme.example/ conversations / 1042
NoraAI agentCustomer support
Order #1042
Today, 10:42 AM
I think I was charged twice for order #1042. Can you check and refund the duplicate?AM
Nora
I found two $49 charges for the same order. I can refund the duplicate to your original payment method.
Checked payment history
I’ll complete the refund as soon as it’s approved.
Needs your review
Refund paymentDuplicate charge
$49.00USD
CustomerAlex Morgan
Order#1042
Refund toVisa ···· 4242
Your approval is required to continue.
Only approved actions are executed.
Pause before actingThe agent sleeps until approval, with no compute charges while it waits.
Let a person decideReview the action and approve or reject it directly in your app.
Continue with contextThe same conversation resumes, with its state and context intact.
Reason 11

Keep state between turns

Each conversation gets a long-lived process that keeps variables, caches and working state in memory between turns.

Five chat.agent sessions, each with its own working memory. Incoming messages wake each session's suspended run. It calls a tool, then streams a reply back out. The same working memory is retained through sleep and resume, shown by the unchanged pattern of memory blocks. Compute sleeps again after replying and waiting for another message. A session can span multiple runs; this animation shows the same run resuming, rather than a new run starting.

Reason 12

Sitting idle is free

A suspended agent costs nothing while it waits. Come back days later with a new message and the conversation picks up where you left off.

This is the root task
launch-research-agent
Root
chat turn 1
ai.streamText
researchCompetitors
next message
idleup to 30s
wait.forToken()
chat turn 2
ai.streamText
reviseLaunchPlan
This is the root task
launch-research-agent
Root
chat turn 1
ai.streamText
researchCompetitors
next message
idleup to 30s
wait.forToken()3d
chat turn 2
ai.streamText
reviseLaunchPlan
3d
$0compute during the 3-day suspension
Reason 13

Start simple, take control when you need to

Begin with chat.agent, which handles the turn loop, approvals and recovery. When you need more, own the loop with createSession and keep the frontend unchanged.

Reason 14

Deploys don't interrupt a conversation

A run continues on the version it started on. Call chat.requestUpgrade() to move a chat to a new version when you choose.

Deployments
DeployVersionStatus
h7kp9mCurrent
20261016.3
Deployed
f3nx2q
20261016.2
Deployed
d8wr4v
20261016.1
Deployed
c2mt6b
20261015.2
Deployed
a9js5r
20261015.1
Deployed
New conversations use your latest deployment.
research-agent
Overview
Detail
Context
Metadata
Status
Executing
Run ID
run_cmq8h2vp4n7k9
Version
20261016.1
Existing conversations stay on their version until you upgrade them.
Reason 15

Use any model or any framework

Bring the AI SDK and any provider you like, or your own loop.

Reason 16

Open source under Apache 2.0

chat.agent lives in the Apache 2.0 repository alongside the rest of the platform. Read the exact code that keeps a conversation alive through a crash, or self-host the whole thing.

Deploy your first
agent today

Get started for free