Skip to content

feat(sdk): add AI SDK 7 support#3833

Open
ericallam wants to merge 2 commits into
mainfrom
feat/ai-sdk-7-support
Open

feat(sdk): add AI SDK 7 support#3833
ericallam wants to merge 2 commits into
mainfrom
feat/ai-sdk-7-support

Conversation

@ericallam
Copy link
Copy Markdown
Member

Summary

Adds support for Vercel AI SDK 7. The ai peer range now includes v7, and the chat.agent / chat surfaces work against v7's ESM-only build. v5 and v6 keep working unchanged, so this is additive.

Telemetry on v7

On v7, model-call spans moved out of ai core into the separate @ai-sdk/otel adapter, so experimental_telemetry alone produces nothing until an integration is registered. Install @ai-sdk/otel alongside ai@7 and the SDK registers it once per worker at chat agent boot, so spans keep flowing into run traces with no extra setup.

If you (or a library you import) already register @ai-sdk/otel, the SDK detects the existing integration and skips its own registration, so you won't get duplicate spans. Set TRIGGER_AI_SDK_OTEL_AUTOREGISTER=0 to disable auto-registration entirely.

Notes

ai@7 is ESM-only, which tripped TS1479 in the SDK's CommonJS build. Runtime value imports from ai are isolated behind a paired ESM/CJS shim so both module formats resolve the right form; type-only imports stay as direct import type at their use sites.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 4, 2026

🦋 Changeset detected

Latest commit: e55fa9f

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

This PR includes changesets to release 25 packages
Name Type
@trigger.dev/sdk Patch
@trigger.dev/python Patch
@internal/sdk-compat-tests Patch
@trigger.dev/build Patch
@trigger.dev/core Patch
@trigger.dev/plugins Patch
@trigger.dev/react-hooks Patch
@trigger.dev/redis-worker Patch
@trigger.dev/rsc Patch
@trigger.dev/schema-to-json Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch
@trigger.dev/rbac Patch
trigger.dev Patch
@internal/cache Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@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

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 Jun 4, 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: 6f87cfb8-8ad4-4fc5-b8e1-d482624eec52

📥 Commits

Reviewing files that changed from the base of the PR and between 5da48c3 and e55fa9f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • .changeset/ai-sdk-7-support.md
  • packages/core/package.json
  • packages/core/tsconfig.ai-v7.json
  • packages/trigger-sdk/package.json
  • packages/trigger-sdk/src/imports/ai-runtime-cjs.cts
  • packages/trigger-sdk/src/imports/ai-runtime.ts
  • packages/trigger-sdk/src/v3/ai.ts
  • packages/trigger-sdk/src/v3/aiAutoTelemetry.ts
  • packages/trigger-sdk/src/v3/chat-client.ts
  • packages/trigger-sdk/src/v3/chat-server.ts
  • packages/trigger-sdk/tsconfig.ai-v7.json
✅ Files skipped from review due to trivial changes (2)
  • .changeset/ai-sdk-7-support.md
  • packages/trigger-sdk/tsconfig.ai-v7.json
🚧 Files skipped from review as they are similar to previous changes (9)
  • packages/trigger-sdk/src/imports/ai-runtime.ts
  • packages/trigger-sdk/package.json
  • packages/trigger-sdk/src/v3/chat-client.ts
  • packages/core/package.json
  • packages/core/tsconfig.ai-v7.json
  • packages/trigger-sdk/src/v3/aiAutoTelemetry.ts
  • packages/trigger-sdk/src/v3/chat-server.ts
  • packages/trigger-sdk/src/imports/ai-runtime-cjs.cts
  • packages/trigger-sdk/src/v3/ai.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). (31)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 8)
  • GitHub Check: sdk-compat / Bun Runtime
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 8)
  • GitHub Check: sdk-compat / Deno Runtime
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: sdk-compat / Node.js 20.20 (ubuntu-latest)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 8)
  • GitHub Check: sdk-compat / Cloudflare Workers
  • GitHub Check: internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
  • GitHub Check: sdk-compat / Node.js 22.12 (ubuntu-latest)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (8, 8)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: audit
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Build and publish previews

Walkthrough

This PR extends Trigger.dev SDK to support AI SDK v7 while maintaining backward compatibility with v5 and v6. The implementation adds parallel TypeScript type-checking against v7 definitions, creates ESM/CJS runtime shims to handle v7's ESM-only package structure, refactors type contracts to be version-agnostic using structural typing instead of concrete SDK types, and introduces automatic registration of the @ai-sdk/otel telemetry integration on v7 so span data flows into run traces.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely summarizes the main objective: adding AI SDK 7 support to the SDK, which is the central focus of all the file changes.
Description check ✅ Passed The PR description covers the main changes (v7 support, ESM build handling, telemetry registration) but lacks testing details and screenshots as specified in the repository template.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 feat/ai-sdk-7-support

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 and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 4, 2026

Open in StackBlitz

@trigger.dev/build

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

trigger.dev

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

@trigger.dev/core

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

@trigger.dev/plugins

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

@trigger.dev/python

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

@trigger.dev/react-hooks

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

@trigger.dev/redis-worker

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

@trigger.dev/rsc

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

@trigger.dev/schema-to-json

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

@trigger.dev/sdk

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

commit: e55fa9f

@ericallam ericallam marked this pull request as ready for review June 4, 2026 15:27
devin-ai-integration[bot]

This comment was marked as resolved.

ericallam added 2 commits June 4, 2026 17:08
The `ai` peer range now includes v7, and the chat surfaces work against
the v7 ESM-only build. v5 and v6 are unchanged. On v7, model-call spans
moved from `ai` core into `@ai-sdk/otel`: install it alongside `ai@7`
and the SDK registers it at chat agent boot so `experimental_telemetry`
keeps flowing into run traces. An already-registered integration is
detected and skipped; set `TRIGGER_AI_SDK_OTEL_AUTOREGISTER=0` to
disable auto-registration.

`ai@7` is ESM-only, so runtime value imports from `ai` sit behind a
paired ESM/CJS shim.
On v7 the tool execution context is passed as `context` (v6 used
`experimental_context`). createTaskToolExecuteHandler only read
`experimental_context`, so task-backed tools (`ai.toolExecute`) lost
their context on v7. Read whichever is set and stamp both names into
the subtask metadata.
@ericallam ericallam force-pushed the feat/ai-sdk-7-support branch from 5da48c3 to e55fa9f Compare June 4, 2026 16:09
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