Skip to content

chore(ai-sdk): widen optional peer to support AI SDK v7 - #378

Closed
ybidois wants to merge 2 commits into
StackOneHQ:mainfrom
ybidois:chore/ai-sdk-v7-peer-support
Closed

chore(ai-sdk): widen optional peer to support AI SDK v7#378
ybidois wants to merge 2 commits into
StackOneHQ:mainfrom
ybidois:chore/ai-sdk-v7-peer-support

Conversation

@ybidois

@ybidoisybidois commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Widen the optional ai peer from >=5.0.108 <7.0.0 to >=5.0.108 <8.0.0 so consumers can use AI SDK v7 (still supports v5 and v6).
  • Develop/test against ai@7.0.47 and @ai-sdk/openai@4.0.27.
  • No change to StackOne tool conversion or execution behavior.toAISDK() still returns the same tool shape (inputSchema via jsonSchema(), description, optional execute / execution).

Code tweaks (typing only)

  • Accept AI SDK’s second execute options argument (ignored) so tools type-check against v7 ToolExecutionOptions (required context).
  • Tests pass context: undefined when calling execute directly.

Docs / examples

  • Replace stale maxSteps with stopWhen: stepCountIs(...) (works across v5–v7; v7 keeps stepCountIs as an alias of isStepCount).
  • Note that AI SDK v7 requires Node.js 22+ (package engines stays >=20.19.6 because ai is optional).

Test plan

  • pnpm build
  • pnpm vitest run src/tool.test.ts src/tool.test-d.ts src/tool-optional-ai.test.ts src/toolsets.test.ts
  • CI green
  • Spot-check an example with OPENAI_API_KEY + STACKONE_API_KEY if desired

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.
@ybidois
ybidois marked this pull request as ready for review August 1, 2026 09:04
@ybidois
ybidois requested a review from a team as a code ownerAugust 1, 2026 09:04
CopilotAI review requested due to automatic review settings August 1, 2026 09:04

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

CopilotAI approved these changes Aug 1, 2026

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

🟢 Ready to approve

The changes are narrowly scoped to dependency range widening, AI SDK v7-compatible typing tweaks, and corresponding doc/test updates without altering tool conversion/execution behavior.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Updates this package’s optional Vercel AI SDK integration to support AI SDK v7 while keeping compatibility with v5/v6, primarily through peer-range widening and small typing-oriented adjustments around tool execution and docs/examples.

Changes:

  • Widen optional peer dependency range for ai to >=5.0.108 <8.0.0 and bump dev/test catalogs to ai@7.0.47 + @ai-sdk/openai@4.0.27.
  • Adjust toAISDK() tool execute wrapper signature to accept AI SDK v7’s second options argument (ignored) and update tests to pass { context: undefined }.
  • Refresh docs/examples to use stopWhen: isStepCount(n) instead of maxSteps / stepCountIs.
File summaries
FileDescription
src/tool.tsUpdates AI SDK tool execute wrapper signature to accept v7 execution options arg.
src/tool.test.tsUpdates direct execute calls to include required v7-style context in options.
README.mdDocuments AI SDK v5–v7 support and updates example to isStepCount.
pnpm-workspace.yamlBumps dev catalogs to AI SDK v7 and widens peer range for ai.
pnpm-lock.yamlLockfile updates for AI SDK v7 and associated transitive dependency versions.
examples/search-tools.tsUpdates AI SDK usage to isStepCount.
examples/README.mdUpdates example docs to reference isStepCount and notes Node 22+ for AI SDK v7.
examples/ai-sdk-integration.tsUpdates AI SDK example to isStepCount and adds v5–v7 compatibility note.
Review details

Files not reviewed (1)

  • pnpm-lock.yaml: Generated file
  • Files reviewed: 7/8 changed files
  • Comments generated: 0
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:3cfb2b7e40

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadexamples/ai-sdk-integration.ts Outdated

@cubic-dev-aicubic-dev-aiBot 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.

3 issues found across 8 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="examples/search-tools.ts">
<violation number="1" location="examples/search-tools.ts:125">
P2: This example claims AI SDK v5–v7 compatibility, but isStepCount was introduced in v7 (renamed from stepCountIs). Under ai@5.x/6.x the import { isStepCount } resolves to undefined, so stopWhen: isStepCount(5) throws at runtime, and the catch in main() only handles missing-module errors, not this. Recommend resolving the symbol across versions or noting the example now requires v7.</violation>
</file>
<file name="examples/README.md">
<violation number="1" location="examples/README.md:63">
P2: The example now uses `isStepCount(3)`, which the AI SDK 6→7 migration renamed from the v5/v6 `stepCountIs` export. So claiming "Compatible with AI SDK v5–v7" right next to a v7-only API is misleading: a v5/v6 user following this example would hit an `isStepCount` import error (the peer range here permits v5/v6/v7). Consider clarifying that the example targets AI SDK v7 (with `stepCountIs` for v5/v6), or noting the version-dependent helper.</violation>
</file>
<file name="README.md">
<violation number="1" location="README.md:214">
P2: The docs/examples now claim compatibility with AI SDK v5–v7 but use `isStepCount`, which only exists in AI SDK v7. The official AISDK 6.x → 7.0 migration guide documents that the stop-condition helper was renamed from `stepCountIs` to `isStepCount` in v7. Users on v5/v6 who follow this README (or the examples) and copy `stopWhen: isStepCount(3)` / `import { isStepCount } from 'ai'` will hit an undefined export, contradicting the stated v5-v7 support. Consider documenting that v5/v6 use `stepCountIs` while v7 uses `isStepCount`, or scoping the `isStepCount` example to v7 so the compatibility claim stays accurate.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment threadexamples/search-tools.ts Outdated
Comment threadexamples/README.md Outdated
Comment threadREADME.md Outdated
isStepCount is v7-only; stepCountIs works on v5/v6 and remains an alias
in v7, matching the advertised ai peer range.
@ybidois

Copy link
Copy Markdown
ContributorAuthor

Addressed review feedback: examples and README now use stepCountIs instead of v7-only isStepCount, so snippets work across the advertised ai peer range (v5–v7). In v7, stepCountIs remains an alias of isStepCount.

@cubic-dev-aicubic-dev-aiBot 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.

No issues found across 7 files

Auto-approved: Widens the optional ai peer range to v7, updates dev deps/tests to v7, and refreshes docs/examples; the tool-shape and execution behavior are unchanged, making this a bounded compatibility and typing-only change.

Re-trigger cubic

@ybidois

ybidois commented Aug 1, 2026

Copy link
Copy Markdown
ContributorAuthor

@StuBehan@glebedel would be amazing if someone could approve this mini-PR this weekend 🤗 I kept the dependency range compatible with previous versions, so it should really not be a problem! Thanks folks 🙌

@ryoppippi

ryoppippi commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

@ybidois sorry i've already left stackone. do not ping me here please

@ybidois

Copy link
Copy Markdown
ContributorAuthor

@joeStackOne can you help?

@pkg-pr-new

pkg-pr-newBot commented Aug 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/StackOneHQ/stackone-ai-node/@stackone/ai@378

commit: 8b6e942

@StuBehan

Copy link
Copy Markdown
Contributor

Thanks @ybidois, and sorry for the wait. I've carried your commits into #379 with your authorship intact; the follow-ups there are co-authored to you.

Your maxStepsstopWhen: stepCountIs(...) fix was worth having on its own: maxSteps was removed in v5, so that snippet was broken across the whole existing peer range, not just under v7.

Four changes on top:

  • README — the code fence had moved from tabs to spaces, failing lint:oxfmt. That was the only red check here.
  • Reverted the src/tool.ts change — the extra _executionOptions param isn't needed, since a 1-arg function is still assignable to v7's ToolExecuteFunction. chore(ai-sdk): support AI SDK v7 and test the full peer range #379 carries zero production-code change.
  • context: undefined in the tests made the suite type-check only under v7 — v5/v6 have no context, and v7's Tool union collapses overload resolution to never. The tests now call execute through a plain signature, which holds on all three majors.
  • CI — new ai-peer-range matrix over 5.0.108 / 6.0.7 / 7.0.0, plus a type test asserting toAISDK() output is accepted by generateText. Nothing previously verified the widened range.

On the main thing you were after: v7 works for the consumer path, verified on both 7.0.0 and 7.0.47. Closing this once #379 merges.

@ybidois

Copy link
Copy Markdown
ContributorAuthor

Thanks a lot @StuBehan! 🙌

Sign up for freeto 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.

4 participants

@ybidois@ryoppippi@StuBehan