{"record":{"id":"6a81933af4eac2b7","repo":"can1357/oh-my-pi","slug":"memory-edit-update-requires-content-or-importance","errorCode":null,"errorMessage":"memory_edit update requires content or importance.","messagePattern":"memory_edit update requires content or importance\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/memory-edit.ts","lineNumber":40,"sourceCode":"\treadonly strict = true;\n\treadonly loadMode = \"discoverable\";\n\treadonly summary = \"Update, forget, or invalidate Mnemopi memories\";\n\n\tconstructor(private readonly session: ToolSession) {}\n\n\tstatic createIf(session: ToolSession): MemoryEditTool | null {\n\t\tconst backend = session.settings.get(\"memory.backend\");\n\t\tif (backend !== \"mnemopi\") return null;\n\t\treturn new MemoryEditTool(session);\n\t}\n\n\tasync execute(_id: string, params: MemoryEditParams): Promise<AgentToolResult> {\n\t\tconst state = this.session.getMnemopiSessionState?.();\n\t\tif (!state) {\n\t\t\tthrow new Error(\"Mnemopi backend is not initialised for this session.\");\n\t\t}\n\t\tif (params.op === \"update\" && params.content === undefined && params.importance === undefined) {\n\t\t\tthrow new Error(\"memory_edit update requires content or importance.\");\n\t\t}\n\n\t\tconst importance = params.importance === undefined ? undefined : Math.max(0, Math.min(1, params.importance));\n\t\tconst result = state.editScopedMemory(params.op, params.id, {\n\t\t\tcontent: params.content,\n\t\t\timportance,\n\t\t\treplacementId: params.replacement_id,\n\t\t});\n\t\tconst location = result.bank ? ` in bank ${result.bank}${result.store ? ` (${result.store})` : \"\"}` : \"\";\n\t\tconst text =\n\t\t\tresult.status === \"not_found\"\n\t\t\t\t? `Memory ${params.id} was not found${location}.`\n\t\t\t\t: result.status === \"not_editable\"\n\t\t\t\t\t? `Memory ${params.id} is a read-only fact${location}; it cannot be edited. Read it with memory://${params.id}.`\n\t\t\t\t\t: `Memory ${params.id} ${result.status}${location}.`;\n\t\treturn {\n\t\t\tcontent: [{ type: \"text\", text }],\n\t\t\tdetails: result,","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/memory-edit.ts#L22-L58","documentation":"The memory_edit tool accepts optional content and importance fields so one schema covers update/forget/invalidate. For op === \"update\", at least one of the two must be supplied — otherwise there is nothing to change. Since the schema can't easily express this conditional requirement, execute() enforces it with this Error before calling editScopedMemory.","triggerScenarios":"Calling memory_edit with { op: \"update\", id: \"...\" } and neither content nor importance provided (both undefined/omitted).","commonSituations":"A model emits an update call intending only to touch a memory but forgets the replacement content; programmatic calls constructing params dynamically where both optional fields end up undefined.","solutions":["Include content (replacement text), importance (0–1 number), or both in the update call.","Use op \"forget\" or \"invalidate\" instead if you don't intend to change the memory's content/importance.","Validate params before calling execute() programmatically."],"exampleFix":"// before: update with nothing to change\n{ \"op\": \"update\", \"id\": \"mem_123\" }\n// after: supply the replacement field(s)\n{ \"op\": \"update\", \"id\": \"mem_123\", \"importance\": 0.9 }","handlingStrategy":"validation","validationCode":"if (params.op === \"update\" && params.content === undefined && params.importance === undefined) {\n  throw new Error(\"memory_edit update needs content or importance.\");\n}","typeGuard":"function isUpdateable(p: MemoryEditParams): boolean {\n  return p.op !== \"update\" || p.content !== undefined || p.importance !== undefined;\n}","tryCatchPattern":"try {\n  await memoryEditTool.execute(id, params);\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"update requires content or importance\")) {\n    // re-issue with at least one replacement field\n  } else {\n    throw err;\n  }\n}","preventionTips":["Decide the edit intent first: change content -> pass content; change priority -> pass importance.","Use forget/invalidate for removals rather than an empty update.","Clamp importance to 0–1; the tool clamps silently but validation avoids surprises."],"tags":["validation","tool-params","memory-edit","missing-required-field"],"backgroundTag":"missing-required-field","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}