Skip to content

Support and test Vercel AI SDK 7 - #1

Merged
x1xhlol merged 1 commit into
masterfrom
ai-sdk-v7
Oct 4, 2026
Merged

x1xhlol merged 1 commit into
masterfrom
ai-sdk-v7

Conversation

@x1xhlol

@x1xhlol x1xhlol commented Oct 4, 2026

Copy link
Copy Markdown
Member

Adds official support for Vercel AI SDK 7 (ai@7.0.127, the current npm latest).

What changed

  • Test matrix: the ai devDependency moves to ^7.0.127, and the existing AI SDK 6 harness now imports from a new ai-v6 alias (npm:ai@^6.0.292, same version as before). The v4/v5/v6 tests are otherwise unchanged.
  • AI SDK 7 tests (using MockLanguageModelV4 from ai/test, since AI SDK 7 uses the v4 model spec): the full shieldLanguageModelMiddleware matrix now runs on 7 (generateText, streamText, redaction, throwOnLeak, chunked mode, credentials, canaries, blockOnOutputFindings). There are also 7-specific cases for stream part ordering, provider metadata on deltas, raw chunk dropping, UI message stream errors, injections in all tool result output types, scanToolResults: false, tool call input redaction (generate and stream), and a wrapped transformParams.
  • Middleware: shieldLanguageModelMiddleware needed no changes. AI SDK 7's wrapLanguageModel accepts middleware of any specificationVersion, and the v4 call options, results, and stream parts have the shapes it already reads.
  • Legacy helper fix: AI SDK 7 deprecates system and replaces it with instructions. shieldMiddleware().wrapParams() / wrapParamsAsync() only hardened system, so a prompt passed as instructions reached the model unhardened. They now harden both. (3 new tests cover this, and they fail without the fix.)
  • Docs: the README support table now says "Vercel AI SDK 4, 5, 6, 7", and there's a CHANGELOG [Unreleased] entry. The package version is unchanged.

Test results (local, Node 20.19 / bun 1.4.2)

  • bun run typecheck: pass
  • bun run test: 40 files, 1233 passed, 2 skipped (base branch: 1193 passed, 2 skipped; +40 new tests)
  • bun run build: pass
  • bun install --frozen-lockfile and npm pack --dry-run: pass
  • Smoke test of the built dist with ai@7.0.127 on Node 20: clean output passes, a leaked system prompt is redacted, and an injection throws InjectionDetectedError.

I didn't run the paid integration tests (test:integration).

Note: ai@7 declares engines.node >=22. Shield's own engines is unchanged.

- Move the ai devDependency to ^7.0.127 and keep the AI SDK 6 harness on an
  ai-v6 alias (npm:ai@^6.0.292).
- Run the shieldLanguageModelMiddleware matrix on AI SDK 7 with
  MockLanguageModelV4, plus v7 cases for stream parts, raw chunks, UI message
  streams, tool results, tool call arguments, and wrapped transformParams.
- shieldMiddleware().wrapParams/wrapParamsAsync now harden AI SDK 7's
  instructions option as well as the deprecated system option.
- README support table and CHANGELOG Unreleased entry.
@x1xhlol
x1xhlol merged commit 88087ad into master Oct 4, 2026
1 check passed
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