Skip to content

feat(sdk,core,webapp): transcript storage for chat.agent - #4896

Open
ericallam wants to merge 5 commits into
feat/transcript-storage-gate-split-tri-13667from
feat/transcript-storage-tri-13667
Open

feat(sdk,core,webapp): transcript storage for chat.agent#4896
ericallam wants to merge 5 commits into
feat/transcript-storage-gate-split-tri-13667from
feat/transcript-storage-tri-13667

Conversation

@ericallam

Copy link
Copy Markdown
Member

Summary

The public surface for transcript storage: chat.agent({ storage }), the exported types and factories, a read path that works for any storage, a conformance suite, and the docs.

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

export const myChat = chat.agent({ id: "my-chat", storage: myTranscriptStorage, run });

// app server
export const loadTranscript = chat.createLoadTranscriptAction(defaultStorage, { limit: 50 });

// browser
const { messages, isLoading } = useLoadTranscript(chatId, loadTranscript, { transport });

load on the storage is the one read for every backend. chat.createLoadTranscriptAction wraps it for the app server and useLoadTranscript renders the result and seeds the transport's resume cursor. A new secret-key endpoint, GET /api/v1/sessions/:id/transcript?limit=&before=, pages the platform snapshot server-side so rendering the last page of a long conversation does not download all of it; the default storage uses it for paged reads and falls back to the whole blob.

runTranscriptStorageTests from @trigger.dev/sdk/ai/test is the contract a storage has to meet: appends and in-place replacement, idempotent remove and truncateAfter, state round-trips, cursors, replaying a changeset, paging, and chat isolation. It runs here against memoryTranscriptStorage(), the default snapshot storage, and a row-per-message adapter over the dashboard agent's own tables, which is the real-schema target and adds two nullable columns to its chats table.

hydrateMessages is documented as deprecated, with loadContext on a storage as the replacement. The changeset in this PR is the release note for the whole feature.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds a TranscriptStorage adapter for chat.agent, including default and custom storage, incremental changesets, transcript state, cursors, and context loading. Adds paginated transcript APIs, server and React loading helpers, and storage conformance tests. Adds dashboard-agent database persistence with migrations. Updates snapshot handling, crash recovery, injection and compaction persistence, deprecates hydrateMessages, and documents the new APIs and migration path.

Merge Risk: 🟡 Moderate · up to 3ddfb

This change adds persisted chat transcripts, loading, paging, and recovery behavior. The remaining documentation issues could cause users to implement incompatible action handling or incomplete recovery flows, so they should be corrected before merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides a detailed and relevant summary, but it does not follow the repository template. It omits the issue reference, checklist, Testing section, Changelog section, and Screenshots s… Add the required template sections. Include the issue reference, complete the checklist, describe the test steps, add a short changelog entry, and state whether screenshots are applicable.
Docstring Coverage ⚠️ Warning Docstring coverage is 47.06% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 17 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding transcript storage for chat.agent across the SDK, core, and webapp.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description provides a detailed and relevant summary, but it does not follow the repository template. It omits the issue reference, checklist, Testing section, Changelog section, and Screenshots section.

Full details: Docstring Coverage

Explanation

Docstring coverage is 47.06% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 17 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/transcript-storage-tri-13667

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@changeset-bot

changeset-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bca2b92

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

This PR includes changesets to release 27 packages
Name Type
@trigger.dev/sdk Minor
@trigger.dev/core Minor
@trigger.dev/python Minor
@internal/dashboard-agent Patch
@trigger.dev/build Minor
trigger.dev Minor
@trigger.dev/redis-worker Minor
@trigger.dev/schema-to-json Minor
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@internal/metrics-pipeline Patch
@trigger.dev/rbac Minor
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/run-store Patch
@internal/schedule-engine Patch
@internal/tracing Patch
@internal/webhook-engine Patch
@internal/webhook-sources Patch
@internal/cache Patch
@trigger.dev/react-hooks Minor
@trigger.dev/rsc Minor
@trigger.dev/database Minor
@trigger.dev/otlp-importer Minor
@trigger.dev/sso Minor
@internal/testcontainers Patch

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

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Observability map

As of bca2b92.

19/100 over 457 measured of 475 entry points (base 19, no change)

What this PR changed

route base head now failing
/resources/preferences/chat-open-mode new 0 request-context
/api/v1/sessions/:sessionId/transcript new 50 request-context

FIX FIRST

  • /api/v1/projects/:projectRef/envvars (sensitive) - auth-boundary, request-context
  • /auth/sso (sensitive) - auth-boundary, request-context
  • /_app/orgs/:organizationSlug/settings/team (sensitive) - error-classification, auth-scope, request-context

AUDIT 3 of 50 sensitive mutations record an actor. 47 without one.
CONTEXT 23 of 457 entry points name a tenant on a failure path. 354 appear only here, 39 of them sensitive, in the JSON rather than the fix list.

What the score is made of
CHECKS
  error-classification  186 applicable, 107 pass,   0 sole, global without it 11
  auth-boundary          62 applicable,  57 pass,   0 sole, global without it 16
  auth-scope             19 applicable,  17 pass,   0 sole, global without it 19
  request-context       457 applicable,  23 pass, 249 sole, global without it 64
  audit-trail            50 applicable,   3 pass,   0 sole, not in the score

The score and findings here are report-only and never gate the merge. Separately, a required test suite keeps this tool's symbol and route lists in sync with the code they name, and can fail a pull request that renames or removes a symbol they reference, or that adds the first route with a segment they anticipate. Each failure names the list to edit. The rules and their reasons: internal-packages/observability-map/README.md.

@ericallam
ericallam force-pushed the feat/transcript-storage-tri-13667 branch from 2b2ea99 to be72173 Compare September 5, 2026 20:29
@pkg-pr-new

pkg-pr-new Bot commented Sep 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

npm i https://pkg.pr.new/@trigger.dev/build@bca2b92

trigger.dev

npm i https://pkg.pr.new/trigger.dev@bca2b92

@trigger.dev/core

npm i https://pkg.pr.new/@trigger.dev/core@bca2b92

@trigger.dev/python

npm i https://pkg.pr.new/@trigger.dev/python@bca2b92

@trigger.dev/react-hooks

npm i https://pkg.pr.new/@trigger.dev/react-hooks@bca2b92

@trigger.dev/redis-worker

npm i https://pkg.pr.new/@trigger.dev/redis-worker@bca2b92

@trigger.dev/rsc

npm i https://pkg.pr.new/@trigger.dev/rsc@bca2b92

@trigger.dev/schema-to-json

npm i https://pkg.pr.new/@trigger.dev/schema-to-json@bca2b92

@trigger.dev/sdk

npm i https://pkg.pr.new/@trigger.dev/sdk@bca2b92

commit: bca2b92

@ericallam
ericallam force-pushed the feat/transcript-storage-tri-13667 branch from be72173 to 5dc4365 Compare September 5, 2026 20:38
@ericallam
ericallam force-pushed the feat/transcript-storage-tri-13667 branch from 5dc4365 to 3bdfd45 Compare September 6, 2026 05:42
@ericallam
ericallam force-pushed the feat/transcript-storage-tri-13667 branch from 3bdfd45 to db561bb Compare September 6, 2026 05:55
@ericallam
ericallam force-pushed the feat/transcript-storage-tri-13667 branch from db561bb to 185360a Compare September 6, 2026 06:17
@ericallam
ericallam force-pushed the feat/transcript-storage-tri-13667 branch from 185360a to 461a6d2 Compare September 6, 2026 06:18
@ericallam
ericallam force-pushed the feat/transcript-storage-tri-13667 branch from 461a6d2 to 1a3b477 Compare September 6, 2026 06:39
@ericallam
ericallam force-pushed the feat/transcript-storage-tri-13667 branch from 1a3b477 to d06408f Compare September 6, 2026 08:06
@ericallam
ericallam force-pushed the feat/transcript-storage-tri-13667 branch from d06408f to a4f1bfe Compare September 6, 2026 08:43
@ericallam
ericallam marked this pull request as ready for review September 6, 2026 16:36
devin-ai-integration[bot]

This comment was marked as resolved.

@ericallam
ericallam force-pushed the feat/transcript-storage-tri-13667 branch 6 times, most recently from 39a00da to bf8496f Compare September 7, 2026 07:48
coderabbitai[bot]

This comment was marked as resolved.

@ericallam
ericallam force-pushed the feat/transcript-storage-tri-13667 branch from bf8496f to 84643b8 Compare September 7, 2026 08:16
coderabbitai[bot]

This comment was marked as resolved.

@ericallam
ericallam force-pushed the feat/transcript-storage-tri-13667 branch from 84643b8 to 7a6c3fd Compare September 7, 2026 10:09
coderabbitai[bot]

This comment was marked as resolved.

@ericallam
ericallam force-pushed the feat/transcript-storage-tri-13667 branch from 7a6c3fd to 0a10002 Compare September 7, 2026 10:22
devin-ai-integration[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

…nformance suite

chat.agent takes a storage option, with the platform snapshot as the default and the TranscriptStorage types, defaultStorage, snapshotTranscriptStorage, memoryTranscriptStorage and reduceTranscriptChanges exported from @trigger.dev/sdk/ai. chat.createLoadTranscriptAction(storage) reads a conversation on the server for any storage, and useLoadTranscript renders it in the browser and seeds the transport's resume cursor. runTranscriptStorageTests from @trigger.dev/sdk/ai/test is the contract a storage implementation has to meet.

A new secret-key endpoint, GET /api/v1/sessions/:id/transcript, pages the platform snapshot server-side so rendering the last page of a long conversation does not download all of it; the default storage uses it for paged reads and falls back to the whole blob.
… message rows

The real-schema conformance target for the storage contract: one row per message in chat_messages, with the runtime's state and cursors in two new nullable columns on chats. Paging is by position in SQL. The agent itself still persists through its hooks.
Treat a non-positive page limit as no limit instead of an empty page a
caller cannot tell apart from the end of the transcript. Hold a seeded
resume cursor until the session exists, so a transcript load that resolves
before the session is created still opens the live stream past the
persisted history instead of replaying it.
Consume a pending resume cursor in setSession() and stop seedResumeCursor
from moving an existing session's cursor backward, so a transcript load that
resolves around session creation, or after the live stream already advanced,
does not replay persisted events. Add conformance coverage for a partial
answer's non-final status, and drive the resume-cursor unit tests through a
real transport. Docs: loadContext also fires on actions, a custom storage is
not limited to row-per-message backends, and the bring-your-own example
imports anthropic.
@ericallam
ericallam force-pushed the feat/transcript-storage-tri-13667 branch from 3ddfb85 to bca2b92 Compare September 8, 2026 09:48

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 new potential issues.

Devin Review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Feature includes extensive documentation

SDK guidance normally separates documentation updates from feature work. Confirm this combined release is the intended exception.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +32 to +39
function isObjectNotFound(error: unknown): boolean {
if (!error) return false;
const name = (error as { name?: unknown }).name;
if (name === "NoSuchKey" || name === "NotFound") return true;
const status = (error as { $metadata?: { httpStatusCode?: number } }).$metadata?.httpStatusCode;
if (status === 404) return true;
const message = error instanceof Error ? error.message : String(error);
return /not found|nosuchkey|404|does not exist/i.test(message);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Provider errors control empty transcripts

Missing snapshots rely on provider-specific error names and status text. Verify all supported object stores produce a recognized 404 signal.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

2 participants