{"record":{"id":"a81aded60f99371c","repo":"supermemoryai/supermemory","slug":"withsupermemory-options-must-be-an-object-with-re","errorCode":null,"errorMessage":"withSupermemory: options must be an object with required containerTag and customId fields. The API changed in v2.0.0 — see https://docs.supermemory.ai/integrations/mastra for the new signature.","messagePattern":"withSupermemory: options must be an object with required containerTag and customId fields\\. The API changed in v2\\.0\\.0 — see https://docs\\.supermemory\\.ai/integrations/mastra for the new signature\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tools/src/mastra/wrapper.ts","lineNumber":80,"sourceCode":" * )\n *\n * const agent = new Agent(config)\n * ```\n *\n * @throws {Error} When neither `options.apiKey` nor `process.env.SUPERMEMORY_API_KEY` are set\n */\nexport function withSupermemory<T extends AgentConfig>(\n\tconfig: T,\n\toptions: SupermemoryMastraOptions,\n): T {\n\t// Runtime guard for breaking API change - catch old 3-arg signature usage\n\tif (\n\t\ttypeof options !== \"object\" ||\n\t\toptions === null ||\n\t\t!options.containerTag ||\n\t\t!options.customId\n\t) {\n\t\tthrow new Error(\n\t\t\t\"withSupermemory: options must be an object with required containerTag and customId fields. \" +\n\t\t\t\t\"The API changed in v2.0.0 — see https://docs.supermemory.ai/integrations/mastra for the new signature.\",\n\t\t)\n\t}\n\n\tvalidateApiKey(options.apiKey)\n\n\tconst inputProcessor = new SupermemoryInputProcessor(options)\n\tconst outputProcessor = new SupermemoryOutputProcessor(options)\n\n\tconst existingInputProcessors = config.inputProcessors ?? []\n\tconst existingOutputProcessors = config.outputProcessors ?? []\n\n\t// Supermemory input processor runs first (before other processors)\n\tconst mergedInputProcessors: Processor[] = [\n\t\tinputProcessor,\n\t\t...existingInputProcessors,\n\t]","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/supermemoryai/supermemory/blob/d436792e777a99865939dd543c8d1a16d57f54ec/packages/tools/src/mastra/wrapper.ts#L62-L98","documentation":"withSupermemory (Mastra wrapper) validates its options object at runtime and throws when it is missing, not an object, or lacking containerTag/customId. The v2.0.0 release changed the API from positional/looser arguments to a required options object.","triggerScenarios":"Calling withSupermemory with no arguments, with the pre-2.0 positional signature, or with an options object missing containerTag or customId.","commonSituations":"Upgrading @supermemory/tools to v2.x without migrating call sites; passing only an apiKey; copy-pasting old examples from docs or blogs.","solutions":["Pass a single options object: withSupermemory({ containerTag, customId, apiKey })","Check the v2 migration docs at https://docs.supermemory.ai/integrations/mastra","Ensure containerTag and customId are non-empty strings","Set SUPERMEMORY_API_KEY env var so apiKey is optional"],"exampleFix":"// before (v1 style)\nwithSupermemory(mastra, 'my-container')\n\n// after (v2)\nwithSupermemory({ containerTag: 'my-container', customId: 'session-123' })","handlingStrategy":"validation","validationCode":"if (!opts || typeof opts !== 'object' || !opts.containerTag || !opts.customId) throw new TypeError('withSupermemory requires { containerTag, customId }')","typeGuard":"const isValidSupermemoryOptions = (o: unknown): o is { containerTag: string; customId: string } => !!o && typeof o === 'object' && typeof (o as any).containerTag === 'string' && typeof (o as any).customId === 'string' && (o as any).containerTag !== '' && (o as any).customId !== ''","tryCatchPattern":null,"preventionTips":["Pin the SDK version when upgrading across a major release","Read the migration guide linked in the error message","Add a boot-time smoke call after major upgrades"],"tags":["validation","breaking-change","mastra","supermemory"],"backgroundTag":"breaking-api-change","analyzedSha":"d436792e777a99865939dd543c8d1a16d57f54ec","analyzedAt":"2026-08-28T18:04:46.947Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}