{"record":{"id":"7898b415ebb92bb5","repo":"mastra-ai/mastra","slug":"addmessage-is-deprecated-please-use-savemessages","errorCode":null,"errorMessage":"addMessage is deprecated. Please use saveMessages instead.","messagePattern":"addMessage is deprecated\\. Please use saveMessages instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/memory/memory.ts","lineNumber":604,"sourceCode":"   * @param type - The type of the message\n   * @param toolNames - Optional array of tool names that were called\n   * @param toolCallArgs - Optional array of tool call arguments\n   * @param toolCallIds - Optional array of tool call ids\n   * @returns Promise resolving to the saved message\n   * @deprecated use saveMessages instead\n   */\n  async addMessage(_params: {\n    threadId: string;\n    resourceId: string;\n    config?: MemoryConfigInternal;\n    content: UserContent | AssistantContent;\n    role: 'user' | 'assistant';\n    type: 'text' | 'tool-call' | 'tool-result';\n    toolNames?: string[];\n    toolCallArgs?: Record<string, unknown>[];\n    toolCallIds?: string[];\n  }): Promise<MastraMessageV1> {\n    throw new Error('addMessage is deprecated. Please use saveMessages instead.');\n  }\n\n  /**\n   * Generates a unique identifier\n   * @param context - Optional context information for deterministic ID generation\n   * @returns A unique string ID\n   */\n  public generateId(context?: IdGeneratorContext): string {\n    return this.#mastra?.generateId(context) || crypto.randomUUID();\n  }\n\n  /**\n   * Static helper to check FGA authorization for thread access.\n   * Can be called from HTTP handlers and agent execution paths.\n   */\n  static async checkThreadFGA(options: {\n    mastra?: Mastra;\n    user?: Record<string, unknown>;","sourceCodeStart":586,"sourceCodeEnd":622,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/memory/memory.ts#L586-L622","documentation":"Memory.addMessage is a permanently deprecated stub whose signature was changed to accept nothing useful, and it unconditionally throws instructing callers to use saveMessages. This forces a compile/runtime-visible break so code cannot silently use the removed write path.","triggerScenarios":"Calling memory.addMessage(...) with the old { threadId, resourceid, content, role, type, toolNames, toolCallArgs, toolCallIds } shape anywhere in application code.","commonSituations":"Legacy integrations or agents built against MastraMemory v1 APIs; tutorials or internal helpers still wrapping addMessage; migration scripts that append messages one at a time.","solutions":["Replace addMessage calls with saveMessages({ messages: [...] }).","Convert the v1 message fields (threadId, resourceid, role, content) into the MastraMessage format saveMessages expects.","Update wrappers/utilities around Memory to batch message writes via saveMessages."],"exampleFix":"// before\nawait memory.addMessage({ threadId, resourceid, content: 'hi', role: 'user', type: 'text' });\n\n// after\nawait memory.saveMessages({\n  messages: [{ threadId, resourceId, content: { parts: [{ type: 'text', text: 'hi' }] }, role: 'user' }],\n});","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await (memory as any).addMessage(msg);\n} catch (e) {\n  if (String((e as Error).message).includes('addMessage is deprecated')) {\n    await memory.saveMessages({ messages: [toMastraMessage(msg)] });\n  } else throw e;\n}","preventionTips":["Replace all addMessage call sites during upgrade; do not feature-detect around it.","Write a thin wrapper over saveMessages so message shape conversion lives in one place.","Update internal utilities/tests that reference addMessage."],"tags":["memory","deprecation","api-migration","messages"],"backgroundTag":"deprecated-api-removed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}