Skip to content

withSupermemory incompatible with AI SDK 6 #852

@urjitc

Description

@urjitc

wrapVercelLanguageModel in packages/tools/src/vercel/index.ts uses object spread to wrap the model:

return { ...model, doGenerate: ..., doStream: ... };
AI SDK 6 models (LanguageModelV3) define specificationVersion, provider, modelId, and supportedUrls as non-enumerable/prototype properties. Spread doesn't copy them, so the wrapped model has undefined for all four — causing AI_UnsupportedModelVersionError at runtime.

Fix: replace the spread pattern with wrapLanguageModel + LanguageModelV3Middleware from ai, which is the standard way to wrap models without losing spec metadata.

Repro:

import { streamText, gateway } from "ai"; // ai@^6.0
import { withSupermemory } from "@supermemory/tools/ai-sdk";

const model = withSupermemory(gateway("google/gemini-2.5-flash"), "user-1", {
  apiKey: "...", mode: "full", addMemory: "always",
});
streamText({ model, prompt: "hello" }); // throws

Versions: @supermemory/tools@1.4.1, ai@6.0.158, @ai-sdk/provider@3.0.8

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions