{"record":{"id":"157061dee630dbfb","repo":"mem0ai/mem0","slug":"memory-id-is-required-for-update","errorCode":null,"errorMessage":"memory_id is required for update","messagePattern":"memory_id is required for update","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"integrations/pi-agent-plugin/src/memory/tools.ts","lineNumber":97,"sourceCode":"          content: [{ type: \"text\" as const, text: msg }],\n          details: { eventId: res.eventId ?? null, status: res.status ?? null },\n        };\n      }\n\n      case \"get_all\": {\n        if (signal?.aborted) throw new Error(\"Cancelled\");\n        const filters = resolveSearchFilters(scope, scopeCtx);\n        const result = await mem0.getAll({ filters });\n        const memories = result.results ?? [];\n        return {\n          content: [{ type: \"text\" as const, text: truncateOutput(formatMemoryList(memories)) }],\n          details: { totalCount: result.count ?? memories.length },\n        };\n      }\n\n      case \"update\": {\n        if (signal?.aborted) throw new Error(\"Cancelled\");\n        if (!params.memory_id) throw new Error(\"memory_id is required for update\");\n        if (!params.content) throw new Error(\"content is required for update\");\n        const updateResult = await mem0.update(params.memory_id, { text: params.content });\n        const res = updateResult as MemoryResult;\n        return {\n          content: [{ type: \"text\" as const, text: res.status ?? \"Memory updated.\" }],\n          details: { memoryId: params.memory_id },\n        };\n      }\n\n      case \"delete\": {\n        if (signal?.aborted) throw new Error(\"Cancelled\");\n        if (!params.memory_id) throw new Error(\"memory_id is required for delete\");\n        const result = await mem0.delete(params.memory_id);\n        return {\n          content: [{ type: \"text\" as const, text: result.message ?? \"Memory deleted.\" }],\n          details: {},\n        };\n      }","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/integrations/pi-agent-plugin/src/memory/tools.ts#L79-L115","documentation":"Validation error thrown by the pi-agent-plugin memory tool's 'update' action when params.memory_id is missing. The tool requires both an id (which memory to edit) and content (the new text) before calling mem0.update(memory_id, { text }). This is a tool-invocation contract violation, typically from an LLM omitting a required parameter.","triggerScenarios":"The agent (LLM) calls the memory tool with action='update' but no memory_id in params — e.g. it invented an update without first retrieving an id from search/get_all, or passed the id under a wrong key (id instead of memory_id).","commonSituations":"LLM tool-calling hallucination: updating 'the memory about X' without looking up its id first; schema drift between the tool's declared parameters and what the model emits.","solutions":["In the agent flow, always search or get_all first and feed a real memory id into the update call.","Check the parameter name: it must be memory_id, not id or memoryId.","Improve the tool description/prompt so the model knows memory_id is required for update."],"exampleFix":"// before (agent tool params)\n{ \"action\": \"update\", \"content\": \"new text\" } // no memory_id\n\n// after\n{ \"action\": \"update\", \"memory_id\": \"m-abc123\", \"content\": \"new text\" }","handlingStrategy":"validation","validationCode":"if (params.action === 'update') {\n  if (!params.memory_id || !params.content) {\n    return { content: [{ type: 'text', text: 'update requires memory_id and content; run search first to get an id' }] };\n  }\n}","typeGuard":"function isValidUpdateParams(p: ToolParams): p is ToolParams & { memory_id: string; content: string } {\n  return typeof p.memory_id === 'string' && p.memory_id.length > 0 && typeof p.content === 'string';\n}","tryCatchPattern":null,"preventionTips":["Tool description should state memory_id is required and comes from search/get_all.","Always search before update in agent prompts; never let the model invent ids.","Use the exact key memory_id (not id/memoryId)."],"tags":["validation","agent-tool","llm","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}