can1357/oh-my-pi · error · Error

memory_edit update requires content or importance.

Error message

memory_edit update requires content or importance.

What it means

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.

Source

Thrown at packages/coding-agent/src/tools/memory-edit.ts:40

	readonly strict = true;
	readonly loadMode = "discoverable";
	readonly summary = "Update, forget, or invalidate Mnemopi memories";

	constructor(private readonly session: ToolSession) {}

	static createIf(session: ToolSession): MemoryEditTool | null {
		const backend = session.settings.get("memory.backend");
		if (backend !== "mnemopi") return null;
		return new MemoryEditTool(session);
	}

	async execute(_id: string, params: MemoryEditParams): Promise<AgentToolResult> {
		const state = this.session.getMnemopiSessionState?.();
		if (!state) {
			throw new Error("Mnemopi backend is not initialised for this session.");
		}
		if (params.op === "update" && params.content === undefined && params.importance === undefined) {
			throw new Error("memory_edit update requires content or importance.");
		}

		const importance = params.importance === undefined ? undefined : Math.max(0, Math.min(1, params.importance));
		const result = state.editScopedMemory(params.op, params.id, {
			content: params.content,
			importance,
			replacementId: params.replacement_id,
		});
		const location = result.bank ? ` in bank ${result.bank}${result.store ? ` (${result.store})` : ""}` : "";
		const text =
			result.status === "not_found"
				? `Memory ${params.id} was not found${location}.`
				: result.status === "not_editable"
					? `Memory ${params.id} is a read-only fact${location}; it cannot be edited. Read it with memory://${params.id}.`
					: `Memory ${params.id} ${result.status}${location}.`;
		return {
			content: [{ type: "text", text }],
			details: result,

View on GitHub (pinned to 9690622007)

Solutions

  1. Include content (replacement text), importance (0–1 number), or both in the update call.
  2. Use op "forget" or "invalidate" instead if you don't intend to change the memory's content/importance.
  3. Validate params before calling execute() programmatically.

Example fix

// before: update with nothing to change
{ "op": "update", "id": "mem_123" }
// after: supply the replacement field(s)
{ "op": "update", "id": "mem_123", "importance": 0.9 }
Defensive patterns

Strategy: validation

Validate before calling

if (params.op === "update" && params.content === undefined && params.importance === undefined) {
  throw new Error("memory_edit update needs content or importance.");
}

Type guard

function isUpdateable(p: MemoryEditParams): boolean {
  return p.op !== "update" || p.content !== undefined || p.importance !== undefined;
}

Try / catch

try {
  await memoryEditTool.execute(id, params);
} catch (err) {
  if (err instanceof Error && err.message.includes("update requires content or importance")) {
    // re-issue with at least one replacement field
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Calling memory_edit with { op: "update", id: "..." } and neither content nor importance provided (both undefined/omitted).

Common situations: 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.

Understand the failure class

Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/6a81933af4eac2b7. Report an issue: GitHub.