can1357/oh-my-pi · error · Error

Mnemopi did not store the lesson (no memory id returned).

Error message

Mnemopi did not store the lesson (no memory id returned).

What it means

When the mnemopi backend is active, learn calls state.rememberScoped() to persist the lesson. rememberScoped returns undefined when the retain fails internally (closed database, disk error). The tool deliberately fails loudly with this Error instead of reporting success, because a silently dropped lesson would otherwise still trigger downstream skill minting and a false "Lesson stored" message.

Source

Thrown at packages/coding-agent/src/tools/learn.ts:79

				source: "coding-agent-learn",
				importance: 0.8,
				metadata: {
					session_id: state.sessionId,
					cwd: state.session.sessionManager.getCwd(),
					context: params.context ?? null,
					tool: "learn",
				},
				scope: "bank",
				extract: true,
				extractEntities: true,
				veracity: "tool",
				memoryType: "fact",
			});
			// rememberScoped returns undefined when the retain failed (closed DB /
			// disk error); mirror mnemopiBackend.save and fail loudly rather than
			// reporting (and minting a skill for) a lesson that was silently dropped.
			if (!id) {
				throw new Error("Mnemopi did not store the lesson (no memory id returned).");
			}
		} else if (backend === "local") {
			const result = await localBackend.save?.(
				{ agentDir: this.session.settings.getAgentDir(), cwd: this.session.settings.getCwd() },
				{ content: params.memory, context: params.context, source: "coding-agent-learn", importance: 0.8 },
			);
			if (!result || result.stored === 0) {
				throw new Error("Lesson was empty after sanitization; nothing stored.");
			}
		} else {
			const state = this.session.getHindsightSessionState?.();
			if (!state) {
				throw new Error("Hindsight backend is not initialised for this session.");
			}
			state.enqueueRetain(params.memory, params.context);
			memoryMessage = "Lesson queued for retention";
		}

View on GitHub (pinned to 9690622007)

Solutions

  1. Inspect the Mnemopi logs/diagnostics for the underlying write failure (closed DB, disk error).
  2. Free disk space or fix permissions on the Mnemopi database directory.
  3. Restart the session to reopen the Mnemopi database, then retry the learn call.
  4. If the store is unrecoverable, switch memory.backend to "local" so lessons persist to learned.md instead.

Example fix

// before: DB directory not writable, rememberScoped returns undefined
$ ls -ld ~/.mnemopi # owned by root
// after: fix ownership/permissions so writes succeed
$ sudo chown -R $USER ~/.mnemopi
Defensive patterns

Strategy: try-catch

Validate before calling

const dir = path.join(settings.getAgentDir(), "mnemopi");
fs.accessSync(dir, fs.constants.W_OK); // throws early if the store dir is unwritable

Type guard

function storedLesson(id: string | undefined): id is string {
  return typeof id === "string" && id.length > 0;
}

Try / catch

try {
  await learnTool.execute(id, params);
} catch (err) {
  if (err instanceof Error && err.message.includes("no memory id returned")) {
    // check Mnemopi DB health/disk, reopen store, then retry
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Calling the learn tool with memory.backend === "mnemopi" while the Mnemopi store cannot write: the database handle is closed, the disk is full or unwritable, or the underlying retain operation errors and returns no memory id.

Common situations: Mnemopi SQLite database file deleted/locked or on a full disk; backend shut down mid-session; permissions changed on the DB directory so inserts fail.

Related errors


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