Skip to content

feat(core,sdk,webapp): version skew protection for chat.agent sessions - #4789

Open
0ski wants to merge 2 commits into
mainfrom
oskar/feat-chat-agent-version-skew-protection
Open

feat(core,sdk,webapp): version skew protection for chat.agent sessions#4789
0ski wants to merge 2 commits into
mainfrom
oskar/feat-chat-agent-version-skew-protection

Conversation

@0ski

@0ski 0ski commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

A chat session now carries an external deployment id, so every run it schedules lands on the deployment that matched the app build that started the conversation: the first run, each continuation after an idle suspend, and each recovery after a crash. A chat started by one release of your app keeps talking to the agent build that release shipped with, however many turns that takes.

The id is resolved wherever the session is started, with the same precedence trigger() already uses: an explicit externalDeploymentId, then configure(), then TRIGGER_EXTERNAL_DEPLOYMENT_ID, then your platform's commit SHA when TRIGGER_AUTOMATIC_SKEW_VERSION_PROTECTION is 1. If none of those yields a value, no id is sent and nothing changes: the chat's runs go to the current version exactly as they do today, and nothing parks.

There is no chat-specific setup either way, so an app already pinning its task runs gets pinned chats with no code change:

// app/actions.ts
"use server";
import { chat } from "@trigger.dev/sdk/ai";
import type { myChat } from "@/trigger/chat";

export const startChatSession = chat.createStartSessionAction<typeof myChat>("my-chat");

Chats need the same two halves as tasks and no more: a deployment carrying an id, and an app that sends the same one. Pass externalDeploymentId: null on triggerConfig to opt one chat out while the rest of the app stays pinned.

Pinning to an id you choose

Discovery covers the common case, a commit SHA your platform already exposes. To name the deployment yourself instead, deploy the agent under that id and give your app the same value:

npx trigger.dev@latest deploy --external-id "$RELEASE_ID"
// app/actions.ts
export const startChatSession = chat.createStartSessionAction<typeof myChat>("my-chat", {
  triggerConfig: { externalDeploymentId: process.env.RELEASE_ID },
});

sessions.start({ triggerConfig: { externalDeploymentId } }) and AgentChat's triggerConfig take the same field. Setting TRIGGER_EXTERNAL_DEPLOYMENT_ID in the app's environment does the same job without touching code, and an explicit value wins over it.

Waiting on a deployment

A run pinned to a deployment that has not landed yet parks rather than failing, and messages sent meanwhile are stored and answered once it arrives. That is a strict improvement on lockToVersion, which throws on session create and is swallowed on the append path, leaving the chat hung with no run at all. PENDING_VERSION is non-final, so the parked run is reused rather than re-triggered.

The session-create and .in/append responses now report pendingVersion, and the transport emits a matching event, so the wait can read as a deploy in progress instead of a stall:

// app/components/chat.tsx
const transport = useTriggerChatTransport<typeof myChat>({
  task: "my-chat",
  accessToken: ({ chatId }) => mintChatAccessToken(chatId),
  startSession: ({ chatId, clientData }) => startChatSession({ chatId, clientData }),
  onEvent: (event) => {
    if (event.type === "run-pending-version") setDeploying(true);
    if (event.type === "first-chunk") setDeploying(false);
  },
});

Escaping the pin

chat.requestUpgrade() re-applied the stored pin, which made upgrading away from a pinned version impossible. It now clears the session's id and persists that, so the next continuation cannot bounce back, and takes a target when you want to move to a specific deployment instead:

// trigger/chat.ts
chat.requestUpgrade({ externalDeploymentId: clientData.commitSha });

lockToVersion is deliberately untouched: it still wins where both are set, and requestUpgrade() still cannot escape it.

Docs: a new Chat sessions section on the version skew protection page, plus notes on the version-upgrades pattern page.

@changeset-bot

changeset-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f8da67e

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 Patch
@trigger.dev/core Patch
@trigger.dev/python Patch
@internal/dashboard-agent Patch
@trigger.dev/build Patch
trigger.dev Patch
@trigger.dev/redis-worker Patch
@trigger.dev/schema-to-json Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@internal/metrics-pipeline Patch
@trigger.dev/rbac Patch
@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 Patch
@trigger.dev/rsc Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch
@trigger.dev/sso Patch
@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

@0ski
0ski marked this pull request as draft August 26, 2026 13:22
@coderabbitai

coderabbitai Bot commented Aug 26, 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

The change adds external deployment ID support to chat session configuration and API schemas. The SDK resolves deployment IDs, preserves explicit null opt-outs, and forwards trigger options. Session runs retain deployment pins across continuations and upgrades, expose pending-version state, and emit run-pending-version events. The web application propagates and persists deployment pins. Tests cover schemas, SDK resolution, session orchestration, upgrades, and pending-version events. Documentation and changesets describe the new behavior.

Merge Risk: 🟡 Moderate · up to f8da6

This change pins chat sessions to deployments and adds pending-version and recovery behavior, but the current implementation can leave resumed chats waiting indefinitely or fail to deliver queued steering messages; callers may also bypass an action-level deployment pin in directly exposed actions. The PR is not merge-ready until these bounded correctness and policy risks are fixed or explicitly accepted.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description gives a detailed and relevant summary of the implementation, behavior, configuration, and documentation changes. However, it omits the required issue reference, checklist, Testing sect… Add the required template sections. Include Closes #<issue> with the issue number, complete the checklist, describe the tests that were run, add a short changelog entry, and state whether screenshots are applicable. Preserve the existing …
Docstring Coverage ⚠️ Warning Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 18 files. (3 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 identifies the main change: version skew protection for chat.agent sessions. It is concise and specific.
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 gives a detailed and relevant summary of the implementation, behavior, configuration, and documentation changes. However, it omits the required issue reference, checklist, Testing section, Changelog section, and Screenshots section from the repository template.

Resolution

Add the required template sections. Include Closes #&lt;issue&gt; with the issue number, complete the checklist, describe the tests that were run, add a short changelog entry, and state whether screenshots are applicable. Preserve the existing technical summary and examples.

Full details: Docstring Coverage

Explanation

Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 18 files. (3 skipped: 3 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch oskar/feat-chat-agent-version-skew-protection

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.

@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: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

coderabbitai[bot]

This comment was marked as resolved.

@0ski
0ski force-pushed the oskar/feat-chat-agent-version-skew-protection branch from 8ec56c3 to 847175f Compare August 26, 2026 14:17
@pkg-pr-new

pkg-pr-new Bot commented Aug 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

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

trigger.dev

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

@trigger.dev/core

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

@trigger.dev/python

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

@trigger.dev/react-hooks

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

@trigger.dev/redis-worker

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

@trigger.dev/rsc

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

@trigger.dev/schema-to-json

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

@trigger.dev/sdk

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

commit: f8da67e

@0ski
0ski marked this pull request as ready for review August 26, 2026 14:21
coderabbitai[bot]

This comment was marked as resolved.

@0ski
0ski force-pushed the oskar/feat-chat-agent-version-skew-protection branch from 847175f to b25e79b Compare August 26, 2026 14:35

@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.

Note

This report is out of date. Scroll down for Devin Review's latest report on this PR.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment on lines +528 to +537
const winner = await runStore.findRun(
{ id: fresh.currentRunId },
{ select: { status: true } },
prisma
);

return {
runId: fresh.currentRunId,
swapped: false,
pendingVersion: winner ? isPendingVersionStatus(winner.status) : false,

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.

🟡 Unused database read in preempted swap path

The lost-race branch of swapSessionRun issues an extra runStore.findRun on the winning run only to compute pendingVersion. The sole caller, the end-and-continue route, discards that field, so each preempted upgrade makes a database round-trip whose result nothing reads.

Open in Devin Review

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.changeset/chat-agent-version-skew-protection.md (1)

8-13: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add temporary crumb markers to every new code example.

Both files add code examples without the required crumb instrumentation.

  • .changeset/chat-agent-version-skew-protection.md#L8-L13: add a crumb marker to the TypeScript example.
  • docs/deployment/version-skew-protection.mdx#L287-L295: add a crumb marker to the session-start example.
  • docs/deployment/version-skew-protection.mdx#L303-L313: add a crumb marker to the transport example.
  • docs/deployment/version-skew-protection.mdx#L321-L325: add a crumb marker to the opt-out example.
  • docs/deployment/version-skew-protection.mdx#L333-L335: add a crumb marker to the upgrade example.

As per coding guidelines, **/* files must add crumbs while code is written.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 01a6d9b1-93db-4d74-92ea-054afb1565ed

📥 Commits

Reviewing files that changed from the base of the PR and between 847175f and b25e79b.

📒 Files selected for processing (2)
  • .changeset/chat-agent-version-skew-protection.md
  • docs/deployment/version-skew-protection.mdx

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📜 Review details
⏰ Context from checks skipped due to timeout. (42)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (24, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (14, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (16, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (22, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (23, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (15, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (21, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (20, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (19, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (17, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (13, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (18, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 24)
  • GitHub Check: sdk-compat / Node.js 22.23 (warp-ubuntu-latest-x64-4x)
  • GitHub Check: sdk-compat / Cloudflare Workers
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-windows-latest-x64-8x - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-ubuntu-latest-x64-4x - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-windows-latest-x64-8x - pnpm)
  • GitHub Check: packages / 🧪 Unit Tests: Packages (3, 3)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-ubuntu-latest-x64-4x - npm)
  • GitHub Check: packages / 🧪 Unit Tests: Packages (1, 3)
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (2, 2)
  • GitHub Check: internal / 🧪 Unit Tests: Internal
  • GitHub Check: packages / 🧪 Unit Tests: Packages (2, 3)
  • GitHub Check: runops-guard / runops-guard
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (1, 2)
  • GitHub Check: code-quality / code-quality
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: 🛡️ E2E Auth Tests (full)
  • GitHub Check: 🛡️ E2E Auth Tests (full)
  • GitHub Check: Build and publish previews
🧰 Additional context used
📓 Path-based instructions (2)
Add crumbs as you write code — not just when debugging. Mark lines with

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • docs/deployment/version-skew-protection.mdx
MDX documentation pages must include frontmatter with title (required), description (required), and sidebarTitle (optional) in YAML format

📄 CodeRabbit inference engine (docs/CLAUDE.md)

Files:

  • docs/deployment/version-skew-protection.mdx
🧠 Learnings (1)
📚 Learning: 2026-04-30T20:30:29.458Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3226
File: docs/ai-chat/quick-start.mdx:13-13
Timestamp: 2026-04-30T20:30:29.458Z
Learning: In this repo’s documentation MDX files (`docs/**/*.mdx`), use `ts` and `tsx` (not `typescript`) as the code-fence language tags for TypeScript/TSX snippets. Do not flag `ts`/`tsx` code-fence language tags as incorrect in any docs MDX file, since this is the site-wide Mintlify-compatible convention.

Applied to files:

  • docs/deployment/version-skew-protection.mdx
🔇 Additional comments (2)
.changeset/chat-agent-version-skew-protection.md (1)

1-6: LGTM!

docs/deployment/version-skew-protection.mdx (1)

279-285: LGTM!

Also applies to: 297-301, 315-317, 329-331, 336-338

});
```

Messages sent while a chat waits on a deployment that is still building are stored and answered once it lands, and the transport emits a `run-pending-version` event so your UI can say so. `chat.requestUpgrade()` now clears the session's pin so the handoff can reach a new version, and accepts `{ externalDeploymentId }` to move to a specific one.

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep external deployment pinning distinct from lockToVersion.

The documentation overstates what external deployment opt-out and chat.requestUpgrade() can change.

  • .changeset/chat-agent-version-skew-protection.md#L15: state that chat.requestUpgrade() cannot override lockToVersion.
  • docs/deployment/version-skew-protection.mdx#L317-L327: clarify that these options disable external-deployment pinning only; they do not override lockToVersion.

The PR objective states that lockToVersion remains authoritative and cannot be overridden.

📍 Affects 2 files
  • .changeset/chat-agent-version-skew-protection.md#L15-L15 (this comment)
  • docs/deployment/version-skew-protection.mdx#L317-L327

@0ski
0ski force-pushed the oskar/feat-chat-agent-version-skew-protection branch from b25e79b to fa56d28 Compare August 26, 2026 14:56
0ski added 2 commits August 27, 2026 18:01
A chat session now carries an external deployment id, so every run it
schedules lands on the deployment that matched the app build that
started the conversation: the first run, each continuation after an idle
suspend, and each recovery after a crash.

Public SDK surface:

- `triggerConfig.externalDeploymentId`, on every entry point that starts
  a session (`sessions.start`, `chat.createStartSessionAction`,
  `chat.headStart`, `chat.handover`, `AgentChat`). Normally omitted: it
  is discovered wherever the session is started, with the same
  precedence `trigger()` uses. `null` opts one chat out.
- `pendingVersion` on the session-create and `.in/append` responses, on
  `ChatStartSessionResult` and on `StartSessionResult`, plus a new
  `run-pending-version` transport event, so a chat waiting on a
  deployment that is still building can say so instead of appearing to
  stall.
- `chat.requestUpgrade({ externalDeploymentId })`. Called without a
  target it now clears the session's pin, which is what makes upgrading
  away from a pinned version possible at all, and the cleared pin is
  persisted so the next continuation cannot bounce back.
- `SessionTriggerConfigInput` and `CreateSessionInput`, the caller-facing
  forms of the trigger config and the create body.

Parking is the right failure mode here, and an improvement on
`lockToVersion`, which throws on session create and is swallowed on the
append path, leaving the chat hung with no run at all. `PENDING_VERSION`
is non-final, so a parked run is reused rather than re-triggered and
appended messages stay durable until the deployment lands.

`lockToVersion` is deliberately untouched: it still wins where both are
set, and `requestUpgrade()` still cannot escape it.
`AgentChat.ensureStarted` built its session config field by field and
never copied these three across, so anyone who set them on
`triggerConfig` got no error and no effect.
@0ski
0ski force-pushed the oskar/feat-chat-agent-version-skew-protection branch from fa56d28 to f8da67e Compare August 27, 2026 16:07

@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 1 new potential issue.

Devin Review

Comment on lines +448 to +455
const storedConfig = SessionTriggerConfigSchema.parse(session.triggerConfig);

// The upgrade's pin is persisted in the claim below, not applied to this run alone: the next
// continuation re-reads the stored config. `lockToVersion` is deliberately untouched.
const config =
reason === "upgrade"
? { ...storedConfig, externalDeploymentId: params.externalDeploymentId ?? undefined }
: storedConfig;

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.

🔍 Upgrade-cleared pin can be reinstated by a later start

requestUpgrade() clears and persists the session's external deployment id so continuations don't return to the rejected version. The cached path of findOrCreateSession overwrites the whole stored config on every sessions.start, so a client that re-starts (reload, reconnect, preload) while still on the rejected build re-pins the session to it and the agent upgrades again. Continuations via .in/append never call start, so they keep the cleared pin. The docs acknowledge this, so likely intended; confirm the escape guarantee is meant to hold across re-starts.

Devin Review

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

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
packages/trigger-sdk/src/v3/sessions.ts (1)

810-817: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Bound the post-wake record read in wait().

After awaitWake() succeeds, sessionStreams.onceRecord(this.sessionId, "in") registers a waiter with no timeout. If no record is delivered, wait() can remain pending indefinitely. Pass a bounded timeoutMs so the existing error branch can run.

packages/trigger-sdk/src/v3/ai.ts (1)

3691-3709: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Resolve the router only when a claim is needed.

When shouldInject returns true and the queue contains only entries from ChatMessageAccumulator.steer(), drainSteeringQueue calls chatInputRouter() before processing those entries. getChatSession() then throws outside a chat session, so local messages are not injected. Initialize the router inside the seqNum branch and guard router.untake().

docs/ai-chat/patterns/version-upgrades.mdx (1)

202-203: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Document deployment-pin precedence for continuations.

The continuation documentation should state that externalDeploymentId keeps subsequent runs on the selected deployment, while lockToVersion remains authoritative when both fields are set. Apply the same precedence clarification to the client protocol documentation.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0276b430-0510-4122-8ba7-4c8ca090545d

📥 Commits

Reviewing files that changed from the base of the PR and between fa56d28 and f8da67e.

📒 Files selected for processing (7)
  • docs/ai-chat/client-protocol.mdx
  • docs/ai-chat/patterns/version-upgrades.mdx
  • docs/ai-chat/reference.mdx
  • packages/trigger-sdk/src/v3/ai.ts
  • packages/trigger-sdk/src/v3/chat.test.ts
  • packages/trigger-sdk/src/v3/chat.ts
  • packages/trigger-sdk/src/v3/sessions.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/ai-chat/reference.mdx

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📜 Review details
⏰ Context from checks skipped due to timeout. (20)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (19, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (16, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (15, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (20, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (14, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (17, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (21, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (18, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (13, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 24)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-windows-latest-x64-8x - pnpm)
  • GitHub Check: internal / 🧪 Unit Tests: Internal
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-windows-latest-x64-8x - npm)
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (1, 2)
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (2, 2)
  • GitHub Check: packages / 🧪 Unit Tests: Packages (1, 3)
  • GitHub Check: packages / 🧪 Unit Tests: Packages (3, 3)
  • GitHub Check: 🛡️ E2E Auth Tests (full)
🧰 Additional context used
📓 Path-based instructions (11)
Always import from `@trigger.dev/sdk`. Never use `@trigger.dev/sdk/v3` or deprecated `client.defineJob`.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/trigger-sdk/src/v3/sessions.ts
  • packages/trigger-sdk/src/v3/ai.ts
  • packages/trigger-sdk/src/v3/chat.test.ts
  • packages/trigger-sdk/src/v3/chat.ts
We use vitest exclusively. **Never mock anything** - use testcontainers instead.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/trigger-sdk/src/v3/chat.test.ts
**Prefer static imports over dynamic imports.** Only use dynamic `import()` when:

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/trigger-sdk/src/v3/sessions.ts
  • packages/trigger-sdk/src/v3/ai.ts
  • packages/trigger-sdk/src/v3/chat.test.ts
  • packages/trigger-sdk/src/v3/chat.ts
Add crumbs as you write code — not just when debugging. Mark lines with

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • docs/ai-chat/patterns/version-upgrades.mdx
  • packages/trigger-sdk/src/v3/sessions.ts
  • docs/ai-chat/client-protocol.mdx
  • packages/trigger-sdk/src/v3/ai.ts
  • packages/trigger-sdk/src/v3/chat.test.ts
  • packages/trigger-sdk/src/v3/chat.ts
Always import from `@trigger.dev/sdk`. Never use `@trigger.dev/sdk/v3` (deprecated path alias)

📄 CodeRabbit inference engine (packages/trigger-sdk/CLAUDE.md)

Files:

  • packages/trigger-sdk/src/v3/sessions.ts
  • packages/trigger-sdk/src/v3/ai.ts
  • packages/trigger-sdk/src/v3/chat.test.ts
  • packages/trigger-sdk/src/v3/chat.ts
In the Trigger.dev SDK (packages/trigger-sdk), prefer isomorphic code like fetch and ReadableStream instead of Node.js-specific code

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • packages/trigger-sdk/src/v3/sessions.ts
  • packages/trigger-sdk/src/v3/ai.ts
  • packages/trigger-sdk/src/v3/chat.test.ts
  • packages/trigger-sdk/src/v3/chat.ts
Use vitest for all tests in the Trigger.dev repository

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • packages/trigger-sdk/src/v3/chat.test.ts
Use function declarations instead of default exports

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • packages/trigger-sdk/src/v3/sessions.ts
  • packages/trigger-sdk/src/v3/ai.ts
  • packages/trigger-sdk/src/v3/chat.test.ts
  • packages/trigger-sdk/src/v3/chat.ts
MDX documentation pages must include frontmatter with title (required), description (required), and sidebarTitle (optional) in YAML format

📄 CodeRabbit inference engine (docs/CLAUDE.md)

Files:

  • docs/ai-chat/patterns/version-upgrades.mdx
  • docs/ai-chat/client-protocol.mdx
Use types over interfaces for TypeScript

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • packages/trigger-sdk/src/v3/sessions.ts
  • packages/trigger-sdk/src/v3/ai.ts
  • packages/trigger-sdk/src/v3/chat.test.ts
  • packages/trigger-sdk/src/v3/chat.ts
When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs

📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)

Files:

  • packages/trigger-sdk/src/v3/sessions.ts
  • packages/trigger-sdk/src/v3/ai.ts
  • packages/trigger-sdk/src/v3/chat.test.ts
  • packages/trigger-sdk/src/v3/chat.ts
🧠 Learnings (2)
📚 Learning: 2026-04-30T20:30:29.458Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3226
File: docs/ai-chat/quick-start.mdx:13-13
Timestamp: 2026-04-30T20:30:29.458Z
Learning: In this repo’s documentation MDX files (`docs/**/*.mdx`), use `ts` and `tsx` (not `typescript`) as the code-fence language tags for TypeScript/TSX snippets. Do not flag `ts`/`tsx` code-fence language tags as incorrect in any docs MDX file, since this is the site-wide Mintlify-compatible convention.

Applied to files:

  • docs/ai-chat/patterns/version-upgrades.mdx
📚 Learning: 2026-06-04T18:16:35.386Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 3836
File: apps/supervisor/src/backpressure/backpressureMonitor.ts:3-5
Timestamp: 2026-06-04T18:16:35.386Z
Learning: When reviewing TypeScript in this repo, apply the rule “prefer type aliases over interfaces” only to data/object shapes and union/intersection type modeling. If an interface is being used as a behavioral contract for collaborators to implement (e.g., method-shape interfaces that define required behavior, such as `BackpressureLogger` / `BackpressureSignalSource` in `apps/supervisor/src/backpressure/backpressureMonitor.ts`), keep it as an `interface` and do not flag it as a type-alias-vs-interface violation.

Applied to files:

  • packages/trigger-sdk/src/v3/sessions.ts
🔇 Additional comments (7)
packages/trigger-sdk/src/v3/sessions.ts (1)

56-68: LGTM!

Also applies to: 114-119

packages/trigger-sdk/src/v3/ai.ts (2)

1505-1523: LGTM!

Also applies to: 1866-1897, 1983-2032, 8968-9038, 9853-9943, 10012-10020, 11258-11294, 11359-11365


1577-1601: 🩺 Stability & Availability

No change required. CHAT_INPUT_ROUTES marks messages as replayable. resumeFloor() scans all routes and remains below any queued message, including when awaitWake first delivers a stop or handover record. Non-replayable queued routes are intentionally excluded.

packages/trigger-sdk/src/v3/chat.test.ts (1)

519-622: LGTM!

packages/trigger-sdk/src/v3/chat.ts (1)

228-239: LGTM!

Also applies to: 431-436, 1529-1543, 1600-1613, 1668-1680

docs/ai-chat/client-protocol.mdx (1)

957-961: LGTM!

docs/ai-chat/patterns/version-upgrades.mdx (1)

4-18: LGTM!

Also applies to: 30-48, 181-186, 189-201, 204-208, 218-218

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.

1 participant