Skip to content

Accept AI SDK 7 in the ai peer range - #82

Open
madster456 wants to merge 1 commit into
agentmail-to:mainfrom
madster456:support-ai-sdk-v7
Open

madster456 wants to merge 1 commit into
agentmail-to:mainfrom
madster456:support-ai-sdk-v7

Conversation

@madster456

@madster456 madster456 commented Oct 15, 2026 •

Copy link
Copy Markdown

Summary

The ai peer range is ^6.0.0-beta.150, which excludes AI SDK 7 (current: 7.0.140). Installing the toolkit next to it fails before any code runs:

$ npm install agentmail-toolkit ai@7
npm error ERESOLVE could not resolve

The adapter itself already works on v7, so this widens the range to ^6.0.0-beta.150 || ^7.0.0. Nothing in src/ changes.

The new docs (mintlify-docs integrations/ai-sdk.mdx) currently tell readers to pin ai@6 @ai-sdk/openai@3 for this reason. Once this ships, that pin can be dropped in a one-line follow-up.

Test

tests/ai-sdk-versions.test.ts runs the adapter's tools through each major's real generateText tool loop with that major's mock model (MockLanguageModelV3 for v6, MockLanguageModelV4 for v7). The existing adapter tests only call execute() directly. v7 comes from an ai-v7 devDependency alias (npm:ai@7.0.140), so it runs in the normal pnpm test without any CI change. For each major the test checks that:

  • every toolkit tool reaches the model, and a call produces a tool-result with normalized output (Date → ISO string);
  • an AgentMailError produces the SDK's native tool-error part with the concise message (inbox not found (HTTP 404)), not a successful result.

To confirm the test catches regressions, I made the adapter return the error string instead of throwing. Both tool-error cases failed on both majors.

Checks

  • pnpm install --frozen-lockfile, pnpm lint, pnpm build, pnpm test: 677 passed (673 existing + 4 new).
  • tsc --noEmit reports the same 5 errors as main, none new.
  • Type level: with ai resolved to 7.0.140, src/ai-sdk.ts and a consumer calling generateText({ tools: new AgentMailToolkit().getTools() }) typecheck cleanly.
  • Packaging: pnpm pack, then npm install <tarball> ai@7 zod@4 in an empty project. It now resolves with ai@7.0.140 deduped (previously ERESOLVE), and a two-step generateText loop runs list_inboxes and finishes.

The ai peer range was ^6.0.0-beta.150, so `npm install agentmail-toolkit ai@7`
failed with ERESOLVE even though the adapter's tools already run on v7. Widen
it to `^6.0.0-beta.150 || ^7.0.0` and add a test that drives the adapter through
each major's real generateText tool loop (v7 via an `ai-v7` alias), covering the
tool-result and native tool-error paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@madster456

Copy link
Copy Markdown
Author

A bit of context I should have included up front. I noticed 5ac2f8f aligned the dev dependency to ai@6.0.224 on July 10, two weeks after 7.0.0 went stable, to resolve the provider-type conflict in examples/. This PR doesn't revisit that: examples/ and the ai devDependency stay on v6, and v7 is only added to the peer range and tested through the ai-v7 alias.

I also checked the v7 changes that could matter for consumers:

  • Node ≥22 (v6 supports ≥18): the range only widens, so Node 18/20 projects keep resolving v6 as before.
  • ESM-only (CommonJS exports removed): dist/ai-sdk.cjs has no runtime require("ai"), only a type import, so require('agentmail-toolkit/ai-sdk') still works next to ai@7 (verified in a packed install).
  • Removed APIs (ToolCallOptions, media result parts, experimental_prepareStep, …): the adapter uses none of them.
  • agentmail-mcp: pins agentmail-toolkit at exactly 0.14.0 and doesn't import ai, so it's unaffected.

Happy to update the example and the docs pin to v7 in a follow-up if you'd like to move them too.

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