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 learn tool persists lessons through the memory backend configured in memory.backend. When that setting is "mnemopi", the tool requires a live Mnemopi session state obtained from session.getMnemopiSessionState(). If the accessor is absent or returns falsy, the session's Mnemopi backend was never initialized, so the lesson cannot be stored and the tool throws this plain Error rather than silently dropping it.
Source
Thrown at packages/coding-agent/src/tools/learn.ts:58
readonly summary = "Capture a reusable lesson to memory (and optionally a managed skill)";
constructor(private readonly session: ToolSession) {}
static createIf(session: ToolSession): LearnTool | null {
if (!session.settings.get("autolearn.enabled")) return null;
const backend = session.settings.get("memory.backend");
if (backend !== "hindsight" && backend !== "mnemopi" && backend !== "local") return null;
return new LearnTool(session);
}
async execute(_id: string, params: LearnParams): Promise<AgentToolResult> {
// 1) Persist or queue the lesson to long-term memory (mirrors MemoryRetainTool).
const backend = this.session.settings.get("memory.backend");
let memoryMessage = "Lesson stored";
if (backend === "mnemopi") {
const state = this.session.getMnemopiSessionState?.();
if (!state) {
throw new Error("Mnemopi backend is not initialised for this session.");
}
const id = state.rememberScoped(params.memory, {
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 thanView on GitHub (pinned to 9690622007)
Solutions
- Check session logs for Mnemopi initialization errors and fix the underlying startup failure (config, DB path, service availability).
- Set memory.backend to "local" or "hindsight" if you do not actually run Mnemopi.
- Restart the session so the Mnemopi backend initializes cleanly.
- If embedding, ensure getMnemopiSessionState is implemented and returns initialized state before tools run.
Example fix
// before: settings claim mnemopi but backend never came up "memory.backend": "mnemopi" // Mnemopi init failed at startup -> tool throws // after: align the setting with the running backend "memory.backend": "local" // or fix Mnemopi startup so state exists
Defensive patterns
Strategy: validation
Validate before calling
if (settings.get("memory.backend") === "mnemopi" && !session.getMnemopiSessionState?.()) {
throw new Error("Fix memory.backend or Mnemopi startup before calling learn.");
} Type guard
function hasMnemopiState(session: ToolSession): boolean {
return typeof session.getMnemopiSessionState === "function" &&
Boolean(session.getMnemopiSessionState());
} Try / catch
try {
await learnTool.execute(id, params);
} catch (err) {
if (err instanceof Error && err.message.includes("Mnemopi backend is not initialised")) {
// fall back to local backend or re-init mnemopi
} else {
throw err;
}
} Prevention
- Keep memory.backend aligned with a backend that actually initializes at startup.
- Check session startup logs for Mnemopi errors before enabling learn.
- Prefer "local" when Mnemopi is optional in your deployment.
When it happens
Trigger: Executing the learn tool in a session where memory.backend === "mnemopi" but getMnemopiSessionState() returns undefined/null — e.g. the Mnemopi backend failed to start, was disabled after startup, or the tool was invoked through a session object lacking the accessor.
Common situations: memory.backend switched to "mnemopi" in settings without the Mnemopi service/database being available at session start; Mnemopi initialization failed (bad config, missing binary/DB) but the setting remained; embedding the SDK and constructing a ToolSession without wiring the Mnemopi state.
Related errors
- Mnemopi backend is not initialised for this session.
- Hindsight backend is not initialised for this session.
- No model configured
- No session - local:// unavailable
- Model registry is unavailable for inspect_image.
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/4764f069d40976f5.
Report an issue: GitHub.