Uh oh!
There was an error while loading. Please reload this page.
chore(ai-sdk): support AI SDK v7 and test the full peer range - #379
Conversation
Declare compatibility with ai v7 (>=5.0.108 <8) and develop against ai@7 / @ai-sdk/openai@4. toAISDK() behavior is unchanged; only typing and docs/examples are updated for the v7 ToolExecutionOptions shape and isStepCount stop condition.
isStepCount is v7-only; stepCountIs works on v5/v6 and remains an alias in v7, matching the advertised ai peer range.
Co-Authored-By: Yannick Bidois <yannick@lekanoe.com>
Co-Authored-By: Yannick Bidois <yannick@lekanoe.com>
Co-Authored-By: Yannick Bidois <yannick@lekanoe.com>
commit: |
There was a problem hiding this comment.
Pull request overview
Updates the package to officially support Vercel AI SDK v7 within the optional ai peer range, while keeping the test suite type-checking and running cleanly across v5/v6/v7 and adding CI coverage for the widened peer range.
Changes:
- Widen
aioptional peer range to>=5.0.108 <8.0.0and update dev catalog/lockfile toai@7.0.47and@ai-sdk/openai@4.0.27. - Make direct AI SDK tool
executecalls in tests version-agnostic via anexecuteAISDKToolhelper to avoid cross-major type incompatibilities. - Update docs/examples to use
stopWhen: stepCountIs(...)and document the Node.js 22+ requirement for AI SDK v7; add anai-peer-rangeCI job to validate lower majors.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/tool.test.ts | Adds an untyped execution helper and routes direct execute calls through it to type-check across AI SDK majors. |
| README.md | Fixes AI SDK example snippet (stopWhen: stepCountIs(...)) and notes v5–v7 support + Node 22+ for v7. |
| pnpm-workspace.yaml | Updates dev catalog pins to AI SDK v7 and widens the optional peer range for ai. |
| pnpm-lock.yaml | Refreshes lockfile to reflect updated AI SDK / provider dependencies. |
| examples/README.md | Notes AI SDK v5–v7 compatibility and Node 22+ requirement for v7 in the example description. |
| examples/ai-sdk-integration.ts | Updates header comment to reflect v5–v7 compatibility and stepCountIs availability/aliasing. |
| .github/workflows/ci.yaml | Adds ai-peer-range matrix job to run tests/typecheck against pinned v5/v6 versions. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Uh oh!
There was an error while loading. Please reload this page.
Co-Authored-By: Yannick Bidois <yannick@lekanoe.com>
Co-Authored-By: Yannick Bidois <yannick@lekanoe.com>
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Requires human review: Widening the public ai peer range to v7 is a compatibility-contract decision, and the PR admits the exported AISDKToolDefinition.execute type still collapses under v7; the tests dodge that with a cast rather than proving the public type works. A maintainer should sign off on claiming v7 support.
Re-trigger cubic
Co-Authored-By: Yannick Bidois <yannick@lekanoe.com>
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Requires human review: Widening the public ai peer range to include v7 is a consumer-facing compatibility commitment and expands the supported audience; a human should approve that product/contract decision even though tests and CI verify the change.
Re-trigger cubic
Uh oh!
There was an error while loading. Please reload this page.
ybidois
commented
Aug 11, 2026
Thanks again @StuBehan! Any timeframe for the change to be released on NPM? 🙌 |
Carries @ybidois's #378 forward with the fixes needed to get it green, plus CI to keep the widened range honest. Their commits are preserved as-is; supersedes #378, which can be closed when this merges.
What #378 does
Widens the optional
aipeer from>=5.0.108 <7.0.0to>=5.0.108 <8.0.0so consumers can use AI SDK v7, and replaces the stalemaxStepsin the README/example withstopWhen: stepCountIs(...). That doc fix is worth having on its own —maxStepswas removed in AI SDK v5, so the snippet was broken across the entire existing peer range.What this PR adds on top
1. README indentation — a code fence had moved from tabs to spaces, which failed
lint:oxfmtand was the only thing making #378 red.2. Reverted the
src/tool.tschange.#378 added a second_executionOptions: unknownparameter to theexecuteimplementation to satisfy v7'sToolExecutionOptions. It isn't needed — a 1-arg function is still assignable to v7's 2-argToolExecuteFunction, and the suite type-checks clean againstai@7.0.47without it. With this reverted, this PR contains zero production-code change, which is what the compatibility claim should imply.3. Made the test call sites version-agnostic. This is the substantive one. #378 added
context: undefinedto the two directexecutecalls insrc/tool.test.ts, which made the suite type-check only against v7:ai#378The two shapes are mutually exclusive across majors:
ToolCallOptionshas nocontext, so the excess-property check rejects the object literal.contextis required onToolExecutionOptions<CONTEXT>, andToolbecame a union (FunctionTool | DynamicTool | ProviderDefinedTool | ProviderExecutedTool). Because it's a union, overload resolution collapses and the error surfaces on the args line rather than the options line, asArgument of type '{ id: string; }' is not assignable to parameter of type 'never'.So a directly-typed call site can only ever satisfy one major. The tests now go through an
executeAISDKToolhelper that callsexecutevia a plain signature, which holds across all three.Worth knowing for the consumer-facing side:
AISDKToolDefinitionis exported publicly asTool & { execution?: ToolExecution }, so under v7 it becomes a union too, and anyone callingtool.execute?.(args, opts)directly hits the same collapse. The tests were the canary, not a special case.4. CI over the rest of the range.
build-and-testonly ever proves whatever the dev catalog pins, so before this the "v5–v7" claim had nothing behind it. Newai-peer-rangejob runs the suite (including the vitest typecheck) against the lower half of the range. Verified it actually bites: re-running the v5 leg against #378's original call sites fails with exit 1 and 2 type errors.Verification
Full suite plus typecheck against each major, using the repo's own TypeScript 5.9.3:
aipnpm test)Also green:
pnpm build,publint(no issues),oxfmt --checkon every changed file.Separately confirmed against all three majors:
stepCountIsis exported by v5/v6/v7 (v7 aliases it toisStepCount),JSONSchema7is still exported byai, andai@7'senginesreally is>=22, so the Node 22+ note is accurate. Keepingengines.nodeat>=20.19.6is right, sinceaiis an optional peer.Known limitation
The matrix pins exact versions rather than using
^5/^6. Newer patches in both lines resolve transitive packages that this repo'strustPolicy: no-downgraderejects —ai@5.0.228andai@6.0.246both fail to install onundici@5.29.0. Ranged matrix entries would therefore fail CI for supply-chain-policy reasons unrelated to the code under test. The tradeoff is that the matrix won't catch a break introduced in a newer v5/v6 patch. LooseningtrustPolicyExcludeto allow ranges felt like the wrong call to smuggle into a compatibility PR; happy to do it separately if we'd rather have the coverage.Two smaller notes, neither addressed here:
examples/package.jsonusesai: catalog:peer, so the examples workspace floats to the newest v7 while the root pins^7.0.47.typescriptreachesnode_modules/.binonly as a transitive dep. If that ever stops being hoisted, vitest's typecheck fails to spawntsc— it exits non-zero, so it won't pass silently, but the message (spawn tsc ENOENTnext to "Type Errors: no errors") is confusing enough to be worth knowing.Summary by cubic
Expanded the optional
aipeer to>=5.0.108 <8.0.0to support AI SDK v7 and updated examples to usestopWhen: stepCountIs(...). Added CI to cover v5–v7 and a type-level check to ensuretoAISDK()tools are valid forgenerateText; no production code changes.Dependencies
aipeer to>=5.0.108 <8.0.0(v7 requires Node.js 22+).ai@7.0.47and@ai-sdk/openai@4.0.27.Refactors
ai-peer-rangeCI job to run type-checked tests onai@5.0.108,ai@6.0.7, andai@7.0.0; asserts the resolvedaiversion and installs with--filter ..executeAISDKTool; added a d.ts assertion thattoAISDK()output is accepted asgenerateTexttools across v5–v7; updated docs/examples tostopWhen: stepCountIs(3), noted v5–v7 support, and thatToolLoopAgentneeds v6+.`Written for commit a59349c. Summary will update on new commits.