Skip to content

feat(sdk): chat.agent — runtime + browser transport (2/4)#3543

Merged
ericallam merged 1 commit into
mainfrom
feature/chat-agent-runtime
May 14, 2026
Merged

feat(sdk): chat.agent — runtime + browser transport (2/4)#3543
ericallam merged 1 commit into
mainfrom
feature/chat-agent-runtime

Conversation

@ericallam
Copy link
Copy Markdown
Member

@ericallam ericallam commented May 10, 2026

Summary

Adds chat.agent({...}), a durable conversational task runtime, plus the browser-side TriggerChatTransport + AgentChat that drive it from a React or Next.js app. Conversations survive page refreshes, network blips, idle suspend, and process restarts, with built-in tools, HITL approvals, multi-turn state, and stop-mid-stream cancellation. Builds on #3542.

Design

Each /in/append request carries at most one new message. The agent reconstructs prior history at run boot from an object-store snapshot plus a session.out replay tail, so conversation context lives server-side instead of bloating the wire. Awaited snapshot writes after every onTurnComplete keep the chain durable across idle suspend. Registering hydrateMessages short-circuits both paths for customers who own their own conversation store.

Lifecycle hooks — onChatStart, onTurnStart, onTurnComplete, onAction, onValidateMessages, hydrateMessages — cover validation, persistence, and post-turn work. chat.history exposes read primitives (getPendingToolCalls, getResolvedToolCalls, extractNewToolResults, findMessage, all) for HITL flows. chat.local gives per-run typed state with Proxy access and dirty tracking. chat.headStart bridges first-turn TTFC via a customer HTTP handler. oomMachine opts a chat into one-shot OOM-retry on a larger machine.

TriggerChatTransport is a Transport implementation for Vercel's ai-sdk useChat: delta-only wire sends, SSE reconnection with lastEventId resume, stop/abort cleanup, dynamic accessToken refresh, X-Peek-Settled fast-close. AgentChat is the direct programmatic equivalent. A cross-tab coordinator does leader election so multiple open tabs share a single SSE.

import { chat } from "@trigger.dev/sdk/ai";
import { streamText } from "ai";

export const myChat = chat.agent({
  id: "my-chat",
  run: async ({ messages, signal }) =>
    streamText({ model: openai("gpt-4o"), messages, abortSignal: signal }),
});

Test plan

  • Run the chat.agent task end-to-end via useChat against a local webapp
  • Kill the page mid-stream, refresh, verify the stream resumes and history persists
  • Stop a turn mid-stream via stop(), verify clean abort
  • Trigger a tool that requires approval, approve it, verify resume
  • Run a long conversation (50+ turns), verify snapshot writes keep wire payloads small

Stack

Part of a 4-PR stack. Merge bottom-up.

  1. feat: Sessions dashboard, task_kind, and chat-ready hardening (1/4) #3542main — Sessions dashboard + chat-ready hardening
  2. This PR (feat(sdk): chat.agent — runtime + browser transport (2/4) #3543) → feat: Sessions dashboard, task_kind, and chat-ready hardening (1/4) #3542
  3. feat(webapp): agent-view dashboard for chat.agent runs (3/4) #3545feat(sdk): chat.agent — runtime + browser transport (2/4) #3543 — agent-view dashboard
  4. feat: ai-chat reference project + MCP agent-chat tooling (4/4) #3546feat(webapp): agent-view dashboard for chat.agent runs (3/4) #3545 — ai-chat reference + MCP tooling

Originally split across #3543 and #3544. Folded into a single PR because the SDK package.json subpath exports for ./chat and ./chat/react made the runtime and the browser transport install-coupled.


This is part 4 of 5 in a stack made with GitButler:

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 10, 2026

🦋 Changeset detected

Latest commit: 16720a5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 31 packages
Name Type
@trigger.dev/sdk Minor
@trigger.dev/core Minor
@trigger.dev/build Minor
trigger.dev Minor
@trigger.dev/python Minor
@internal/sdk-compat-tests Patch
d3-chat Patch
references-d3-openai-agents Patch
references-nextjs-realtime Patch
references-realtime-hooks-test Patch
references-realtime-streams Patch
references-telemetry Patch
@trigger.dev/plugins Minor
@trigger.dev/redis-worker Minor
@trigger.dev/schema-to-json Minor
@internal/cache Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@trigger.dev/rbac Minor
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/schedule-engine Patch
@internal/testcontainers Patch
@internal/tracing Patch
@internal/tsql Patch
@internal/zod-worker Patch
@trigger.dev/react-hooks Minor
@trigger.dev/rsc Minor
@trigger.dev/database Minor
@trigger.dev/otlp-importer Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 10, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0de320b6-b90e-4afc-a1c0-95fcd178a003

📥 Commits

Reviewing files that changed from the base of the PR and between f8acef8 and 16720a5.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (71)
  • .changeset/agent-skills.md
  • .changeset/chat-actions-no-turn.md
  • .changeset/chat-agent-delta-wire-snapshots.md
  • .changeset/chat-agent-on-boot-hook.md
  • .changeset/chat-agent.md
  • .changeset/chat-head-start.md
  • .changeset/chat-history-read-primitives.md
  • .changeset/chat-session-attributes.md
  • .changeset/mock-chat-agent-test-harness.md
  • apps/webapp/app/components/code/AIQueryInput.tsx
  • apps/webapp/app/components/code/StreamdownRenderer.tsx
  • apps/webapp/app/components/code/shikiTheme.ts
  • apps/webapp/app/components/runs/v3/PromptSpanDetails.tsx
  • apps/webapp/app/components/runs/v3/ai/AIChatMessages.tsx
  • apps/webapp/app/components/runs/v3/ai/AISpanDetails.tsx
  • apps/webapp/app/components/runs/v3/ai/types.ts
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.test.tasks.$taskParam/AIPayloadTabContent.tsx
  • apps/webapp/package.json
  • apps/webapp/test/chat-snapshot-integration.test.ts
  • apps/webapp/test/replay-after-crash.test.ts
  • package.json
  • packages/build/package.json
  • packages/build/src/extensions/secureExec.ts
  • packages/build/src/internal.ts
  • packages/build/src/internal/additionalFiles.ts
  • packages/build/src/internal/copyFiles.ts
  • packages/core/package.json
  • packages/core/src/v3/resource-catalog/catalog.ts
  • packages/core/src/v3/resource-catalog/index.ts
  • packages/core/src/v3/resource-catalog/noopResourceCatalog.ts
  • packages/core/src/v3/resource-catalog/standardResourceCatalog.ts
  • packages/core/src/v3/taskContext/index.test.ts
  • packages/core/src/v3/taskContext/index.ts
  • packages/core/src/v3/taskContext/otelProcessors.ts
  • packages/core/src/v3/test/index.ts
  • packages/core/src/v3/test/mock-task-context.ts
  • packages/core/test/mockTaskContext.test.ts
  • packages/core/test/skillCatalog.test.ts
  • packages/trigger-sdk/package.json
  • packages/trigger-sdk/src/v3/agentSkillsRuntime.ts
  • packages/trigger-sdk/src/v3/ai-shared.ts
  • packages/trigger-sdk/src/v3/ai.ts
  • packages/trigger-sdk/src/v3/auth.ts
  • packages/trigger-sdk/src/v3/chat-client.ts
  • packages/trigger-sdk/src/v3/chat-react.ts
  • packages/trigger-sdk/src/v3/chat-server.test.ts
  • packages/trigger-sdk/src/v3/chat-server.ts
  • packages/trigger-sdk/src/v3/chat-tab-coordinator.test.ts
  • packages/trigger-sdk/src/v3/chat-tab-coordinator.ts
  • packages/trigger-sdk/src/v3/chat.test.ts
  • packages/trigger-sdk/src/v3/chat.ts
  • packages/trigger-sdk/src/v3/deployments.ts
  • packages/trigger-sdk/src/v3/index.ts
  • packages/trigger-sdk/src/v3/runs.ts
  • packages/trigger-sdk/src/v3/sessions.ts
  • packages/trigger-sdk/src/v3/skill.ts
  • packages/trigger-sdk/src/v3/skills.ts
  • packages/trigger-sdk/src/v3/test/index.ts
  • packages/trigger-sdk/src/v3/test/mock-chat-agent.ts
  • packages/trigger-sdk/src/v3/test/setup-catalog.ts
  • packages/trigger-sdk/src/v3/test/test-session-handle.ts
  • packages/trigger-sdk/test/chat-snapshot.test.ts
  • packages/trigger-sdk/test/chatHandover.test.ts
  • packages/trigger-sdk/test/merge-by-id.test.ts
  • packages/trigger-sdk/test/mockChatAgent.test.ts
  • packages/trigger-sdk/test/replay-session-out.test.ts
  • packages/trigger-sdk/test/skill.test.ts
  • packages/trigger-sdk/test/skillsRuntime.test.ts
  • packages/trigger-sdk/test/wire-shape.test.ts
  • patches/streamdown@2.5.0.patch
  • pnpm-workspace.yaml
✅ Files skipped from review due to trivial changes (6)
  • packages/trigger-sdk/src/v3/skills.ts
  • .changeset/chat-session-attributes.md
  • .changeset/chat-agent-on-boot-hook.md
  • .changeset/agent-skills.md
  • .changeset/chat-agent.md
  • patches/streamdown@2.5.0.patch
🚧 Files skipped from review as they are similar to previous changes (60)
  • .changeset/mock-chat-agent-test-harness.md
  • apps/webapp/app/components/code/StreamdownRenderer.tsx
  • apps/webapp/app/components/runs/v3/ai/types.ts
  • packages/build/src/internal.ts
  • packages/trigger-sdk/src/v3/test/setup-catalog.ts
  • pnpm-workspace.yaml
  • package.json
  • apps/webapp/app/components/code/shikiTheme.ts
  • apps/webapp/app/components/runs/v3/PromptSpanDetails.tsx
  • packages/trigger-sdk/src/v3/auth.ts
  • packages/trigger-sdk/test/wire-shape.test.ts
  • packages/core/src/v3/test/index.ts
  • packages/core/src/v3/resource-catalog/index.ts
  • apps/webapp/app/components/runs/v3/ai/AISpanDetails.tsx
  • apps/webapp/app/components/code/AIQueryInput.tsx
  • apps/webapp/package.json
  • packages/trigger-sdk/src/v3/test/index.ts
  • packages/trigger-sdk/test/skillsRuntime.test.ts
  • packages/core/src/v3/taskContext/otelProcessors.ts
  • packages/core/test/skillCatalog.test.ts
  • .changeset/chat-actions-no-turn.md
  • packages/trigger-sdk/src/v3/index.ts
  • packages/trigger-sdk/test/skill.test.ts
  • packages/build/src/extensions/secureExec.ts
  • packages/core/src/v3/taskContext/index.ts
  • packages/trigger-sdk/test/merge-by-id.test.ts
  • packages/build/src/internal/copyFiles.ts
  • packages/core/src/v3/resource-catalog/standardResourceCatalog.ts
  • packages/core/src/v3/resource-catalog/noopResourceCatalog.ts
  • packages/core/src/v3/test/mock-task-context.ts
  • packages/trigger-sdk/src/v3/chat-tab-coordinator.test.ts
  • packages/trigger-sdk/test/chat-snapshot.test.ts
  • packages/trigger-sdk/src/v3/runs.ts
  • packages/trigger-sdk/src/v3/deployments.ts
  • packages/build/package.json
  • packages/trigger-sdk/test/chatHandover.test.ts
  • apps/webapp/test/chat-snapshot-integration.test.ts
  • packages/core/src/v3/taskContext/index.test.ts
  • packages/build/src/internal/additionalFiles.ts
  • packages/trigger-sdk/src/v3/test/test-session-handle.ts
  • packages/core/test/mockTaskContext.test.ts
  • apps/webapp/app/components/runs/v3/ai/AIChatMessages.tsx
  • packages/core/src/v3/resource-catalog/catalog.ts
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.test.tasks.$taskParam/AIPayloadTabContent.tsx
  • packages/trigger-sdk/src/v3/skill.ts
  • packages/trigger-sdk/src/v3/agentSkillsRuntime.ts
  • apps/webapp/test/replay-after-crash.test.ts
  • packages/trigger-sdk/test/replay-session-out.test.ts
  • packages/trigger-sdk/src/v3/ai-shared.ts
  • packages/trigger-sdk/package.json
  • packages/trigger-sdk/test/mockChatAgent.test.ts
  • packages/trigger-sdk/src/v3/chat-tab-coordinator.ts
  • packages/trigger-sdk/src/v3/chat-server.test.ts
  • packages/trigger-sdk/src/v3/chat-server.ts
  • packages/trigger-sdk/src/v3/chat.test.ts
  • packages/trigger-sdk/src/v3/test/mock-chat-agent.ts
  • packages/trigger-sdk/src/v3/sessions.ts
  • packages/trigger-sdk/src/v3/chat-client.ts
  • packages/trigger-sdk/src/v3/chat.ts
  • packages/trigger-sdk/src/v3/chat-react.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (30)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: sdk-compat / Bun Runtime
  • GitHub Check: internal / 🧪 Unit Tests: Internal (8, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: sdk-compat / Node.js 22.12 (ubuntu-latest)
  • GitHub Check: sdk-compat / Node.js 20.20 (ubuntu-latest)
  • GitHub Check: packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: sdk-compat / Cloudflare Workers
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: sdk-compat / Deno Runtime
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: audit
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js,jsx,json,md,css,scss}

📄 CodeRabbit inference engine (AGENTS.md)

Code formatting is enforced using Prettier. Run pnpm run format before committing

Files:

  • packages/core/package.json
🪛 LanguageTool
.changeset/chat-agent-delta-wire-snapshots.md

[grammar] ~8-~8: Ensure spelling is correct
Context: ...ore env vars (OBJECT_STORE_*) on your webapp deployment if you haven't already; with...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

.changeset/chat-head-start.md

[style] ~5-~5: Consider a different verb to strengthen your wording.
Context: ... run boots in parallel. Cold-start TTFC drops by ~50% on the first message; the agent...

(DROP_DECLINE)

.changeset/chat-history-read-primitives.md

[grammar] ~7-~7: Ensure spelling is correct
Context: ...Use extractNewToolResults(message) to dedup tool results when persisting to your ow...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🔇 Additional comments (4)
.changeset/chat-agent-delta-wire-snapshots.md (1)

1-8: LGTM!

.changeset/chat-head-start.md (1)

1-35: LGTM!

.changeset/chat-history-read-primitives.md (1)

1-21: LGTM!

packages/core/package.json (1)

46-46: LGTM!

Also applies to: 164-167, 483-493


Walkthrough

Adds Trigger v3 chat transport (browser) and server head-start handler, a server/client chat client, durable sessions API with streaming I/O, skills API/runtime with catalog support, multi-tab coordination, and deployment helpers. Webapp consolidates Streamdown rendering and expands AI UI features. Build system adds a secure-exec extension. Core adds conversation-id instrumentation and skill catalog methods. Extensive tests and changesets document behavior, wire formats, snapshots/replay, head-start, and new hooks.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/chat-agent-runtime

devin-ai-integration[bot]

This comment was marked as resolved.

@ericallam ericallam force-pushed the feature/sessions-primitive branch from b84d537 to ed7bf97 Compare May 11, 2026 19:01
@ericallam ericallam force-pushed the feature/chat-agent-runtime branch from dbc0034 to 64929b7 Compare May 11, 2026 19:01
@ericallam ericallam force-pushed the feature/sessions-primitive branch from ed7bf97 to 365e73b Compare May 12, 2026 08:23
@ericallam ericallam force-pushed the feature/chat-agent-runtime branch from 64929b7 to 9d8b67b Compare May 12, 2026 08:23
@ericallam ericallam force-pushed the feature/sessions-primitive branch from 365e73b to b4a0986 Compare May 12, 2026 08:35
@ericallam ericallam force-pushed the feature/chat-agent-runtime branch from 9d8b67b to f83a0e2 Compare May 12, 2026 08:35
@ericallam ericallam force-pushed the feature/sessions-primitive branch from b4a0986 to 1712b59 Compare May 12, 2026 08:40
@ericallam ericallam force-pushed the feature/chat-agent-runtime branch from f83a0e2 to 4cedf7c Compare May 12, 2026 08:40
@ericallam ericallam force-pushed the feature/sessions-primitive branch from 1712b59 to 3721c34 Compare May 12, 2026 08:46
@ericallam ericallam force-pushed the feature/chat-agent-runtime branch from 4cedf7c to 63cb53e Compare May 12, 2026 08:46
@ericallam ericallam force-pushed the feature/sessions-primitive branch from 3721c34 to f240799 Compare May 12, 2026 08:52
@ericallam ericallam force-pushed the feature/chat-agent-runtime branch 11 times, most recently from f694134 to 13447b8 Compare May 12, 2026 13:31
@ericallam ericallam changed the title feat(sdk): chat.agent — durable conversational task runtime (2/5) feat(sdk): chat.agent — runtime + browser transport (2/4) May 12, 2026
@ericallam ericallam force-pushed the feature/chat-agent-runtime branch 2 times, most recently from 9af14ef to b54c38e Compare May 13, 2026 06:14
@ericallam ericallam force-pushed the feature/sessions-primitive branch from 2218110 to 5359eda Compare May 13, 2026 06:19
@ericallam ericallam force-pushed the feature/chat-agent-runtime branch 3 times, most recently from df753af to 950c0b5 Compare May 13, 2026 14:21
devin-ai-integration[bot]

This comment was marked as resolved.

@ericallam ericallam force-pushed the feature/sessions-primitive branch from 37ea386 to 32b0e42 Compare May 14, 2026 09:32
@ericallam ericallam force-pushed the feature/chat-agent-runtime branch from c8b5507 to 8b6fcfd Compare May 14, 2026 09:32
devin-ai-integration[bot]

This comment was marked as resolved.

@ericallam ericallam force-pushed the feature/chat-agent-runtime branch from 8b6fcfd to 353fbf1 Compare May 14, 2026 11:06
@ericallam ericallam force-pushed the feature/sessions-primitive branch from 219e550 to be1a6cf Compare May 14, 2026 12:13
@ericallam ericallam force-pushed the feature/chat-agent-runtime branch from 353fbf1 to 9a8b726 Compare May 14, 2026 12:13
devin-ai-integration[bot]

This comment was marked as resolved.

@ericallam ericallam force-pushed the feature/chat-agent-runtime branch from 9a8b726 to 7690836 Compare May 14, 2026 12:29
ericallam added a commit that referenced this pull request May 14, 2026
…3542)

## Summary

A `/sessions` dashboard for inspecting durable Sessions, an `AGENT` /
`SCHEDULED` task-kind filter for the runs list, and the server-side
hardening (rate-limit exemption for packets, retry-with-backoff on
stream appends, typed too-large-chunk error) that the `chat.agent`
runtime in #3543 needs. Builds on the Sessions primitive shipped in
#3417.

## Design

The Sessions list + detail routes mirror the run inspector pattern.
`TaskTriggerSource` gains `AGENT` and `SCHEDULED` values, persisted on
`BackgroundWorker.taskKind` and `TaskRun.taskKind` (plus a matching
Clickhouse column), so the runs list can filter by kind.

New `@trigger.dev/core` modules — `sessionStreams`, `inputStreams`, a
`sessionStreamInstance` for realtime streams, and the
`realtime-streams-api` / `session-streams-api` surfaces — expose the
typed shapes that chat.agent will use to drive `session.out`.
`ChatChunkTooLargeError` lets the runtime drop oversized chunks with a
typed surface instead of failing the run. `s2Append` retries transient
failures with exponential backoff. `/api/v[12]/packets/*` is exempt from
customer rate limits so chat snapshot reads and writes don't get
throttled under load.

## Stack

Part of a 4-PR stack. Merge bottom-up.

1. **This PR** (#3542) → `main`
2. #3543#3542 — `chat.agent` runtime + browser transport
3. #3545#3543 — agent-view dashboard
4. #3546#3545 — ai-chat reference + MCP tooling

Replaces #3173 (closed).

<!-- GitButler Footer Boundary Top -->
---
This is **part 5 of 5 in a stack** made with GitButler:
- <kbd>&nbsp;5&nbsp;</kbd> #3612
- <kbd>&nbsp;4&nbsp;</kbd> #3546
- <kbd>&nbsp;3&nbsp;</kbd> #3545
- <kbd>&nbsp;2&nbsp;</kbd> #3543
- <kbd>&nbsp;1&nbsp;</kbd> #3542 👈 
<!-- GitButler Footer Boundary Bottom -->
Base automatically changed from feature/sessions-primitive to main May 14, 2026 12:41
@ericallam ericallam force-pushed the feature/chat-agent-runtime branch from 7690836 to 535245f Compare May 14, 2026 12:44
github-advanced-security[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@ericallam ericallam force-pushed the feature/chat-agent-runtime branch from 535245f to f8acef8 Compare May 14, 2026 13:10
coderabbitai[bot]

This comment was marked as resolved.

Adds the chat.agent({...}) task definition (server runtime) and the
browser-side TriggerChatTransport + AgentChat that drives it from a
React or Next.js app. The runtime sits on top of the Sessions primitive
and handles the durable conversational task lifecycle.

Server runtime:
- chat.agent({...}) — session-aware task definition
- Lifecycle hooks: onChatStart, onTurnStart, onTurnComplete, onAction,
  onValidateMessages, hydrateMessages
- chat.history read primitives for HITL flows
- chat.local, chat.headStart, chat.handover, oomMachine
- Delta-only wire + S3 snapshot reconstruction at run boot
- Actions are no longer turns

Browser transport:
- TriggerChatTransport (ai-sdk Transport): delta-only wire sends,
  SSE reconnection with lastEventId resume, stop/abort cleanup,
  dynamic accessToken refresh
- AgentChat: direct programmatic API
- useTriggerChatTransport (React hook)
- chat-tab-coordinator: cross-tab leader election

Includes the chat-agent, chat-agent-delta-wire-snapshots,
chat-history-read-primitives, chat-head-start, chat-actions-no-turn,
chat-session-attributes, agent-skills, and mock-chat-agent-test-harness
changesets.
@ericallam ericallam force-pushed the feature/chat-agent-runtime branch from f8acef8 to 16720a5 Compare May 14, 2026 14:10
@ericallam ericallam merged commit a97365d into main May 14, 2026
41 of 42 checks passed
@ericallam ericallam deleted the feature/chat-agent-runtime branch May 14, 2026 14:29
ericallam added a commit that referenced this pull request May 14, 2026
## Summary

A chat-aware run inspector and a `/playground` UI for testing
`chat.agent` tasks interactively. Builds on #3543's runtime.

## Design

The run inspector grows a new tab that renders the conversation chain
for any `chat.agent`-kind run. It subscribes to the run's session
streams, threads chat parts through a per-message renderer, and uses a
shared markdown + Shiki component for code highlighting (also used by
the test-payload panel).

The playground is a standalone `/playground` route that lets you drive a
deployed chat agent from the dashboard — pick a task, send messages,
watch tool calls render, and see span detail on every turn. The matching
`/agents` list view shows all deployed agents in the project.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants