can1357/oh-my-pi · error · Error

Mnemopi backend is not initialised for this session.

Error message

Mnemopi backend is not initialised for this session.

What it means

The memory_edit tool operates exclusively on the Mnemopi memory store: execute() immediately fetches session.getMnemopiSessionState() and throws this Error if it is absent. The tool is only instantiated when memory.backend === "mnemopi", so hitting this means the backend was configured but the session state was never successfully initialized (or was torn down).

Source

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

	readonly label = "Memory Edit";
	readonly description = memoryEditDescription;
	readonly parameters = memoryEditSchema;
	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}.`;

View on GitHub (pinned to 9690622007)

Solutions

  1. Check logs for the Mnemopi initialization failure and fix it (config, DB path, permissions), then restart the session.
  2. Switch memory.backend to "local" if you don't run Mnemopi (memory_edit is mnemopi-only anyway).
  3. Re-open the Mnemopi store if it was closed mid-session.
  4. If embedding, provide getMnemopiSessionState returning initialized state.

Example fix

// before: setting says mnemopi but backend init failed
"memory.backend": "mnemopi" // -> state undefined
// after: repair Mnemopi startup or fall back to a working backend
"memory.backend": "local"
Defensive patterns

Strategy: validation

Validate before calling

if (settings.get("memory.backend") === "mnemopi" && !session.getMnemopiSessionState?.()) {
  throw new Error("memory_edit requires an initialised Mnemopi backend.");
}

Type guard

function hasMnemopiState(session: ToolSession): boolean {
  return typeof session.getMnemopiSessionState === "function" &&
    Boolean(session.getMnemopiSessionState());
}

Try / catch

try {
  await memoryEditTool.execute(id, params);
} catch (err) {
  if (err instanceof Error && err.message.includes("Mnemopi backend is not initialised")) {
    // re-init Mnemopi or surface a degraded-memory-mode message
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Executing memory_edit in a session where memory.backend === "mnemopi" but getMnemopiSessionState() returns undefined/null — Mnemopi init failed at startup, the backend was closed, or a custom session object lacks the accessor.

Common situations: Mnemopi DB unavailable/locked at session start while the setting remained "mnemopi"; backend crash mid-session; SDK embedding with a session that doesn't implement getMnemopiSessionState.

Related errors


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