can1357/oh-my-pi · error · Error
Hindsight backend is not initialised for this session.
Error message
Hindsight backend is not initialised for this session.
What it means
For any memory.backend other than "mnemopi" or "local" (i.e. hindsight), the learn tool requires a live Hindsight session state from session.getHindsightSessionState(). If the accessor is missing or returns falsy, the Hindsight backend was not initialized for this session, so the lesson cannot be queued and the tool throws this Error.
Source
Thrown at packages/coding-agent/src/tools/learn.ts:92
});
// 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";
}
// 2) Optionally mint/enhance a managed skill. A failure here is surfaced
// as a partial outcome — the lesson is already stored or queued.
if (params.skill) {
// A managed skill resolves below any authored skill of the same name, so
// minting one under a claimed name writes a file that never surfaces. The
// lesson is already stored/queued; refuse the skill rather than report a
// false "Created" (mirrors ManageSkillTool).
let safeSkillName: string | undefined;
try {
safeSkillName = sanitizeSkillName(params.skill.name);
} catch {
safeSkillName = undefined;
}View on GitHub (pinned to 9690622007)
Solutions
- Fix Hindsight initialization (check startup logs for connection/config errors) and restart the session.
- Set memory.backend to "local" or "mnemopi" if Hindsight is not actually deployed.
- If embedding, implement getHindsightSessionState and return initialized state before tools execute.
Example fix
// before: hindsight configured but service down "memory.backend": "hindsight" // getHindsightSessionState() -> undefined // after: use a backend that is actually running "memory.backend": "local"
Defensive patterns
Strategy: validation
Validate before calling
if (settings.get("memory.backend") === "hindsight" && !session.getHindsightSessionState?.()) {
throw new Error("Hindsight is configured but not initialised; fix startup or switch backends.");
} Type guard
function hasHindsightState(session: ToolSession): boolean {
return typeof session.getHindsightSessionState === "function" &&
Boolean(session.getHindsightSessionState());
} Try / catch
try {
await learnTool.execute(id, params);
} catch (err) {
if (err instanceof Error && err.message.includes("Hindsight backend is not initialised")) {
// re-init hindsight or fall back to local backend
} else {
throw err;
}
} Prevention
- Verify the Hindsight service is reachable before sessions start.
- Remove stale memory.backend values when decommissioning Hindsight.
- Wire getHindsightSessionState when embedding the SDK.
When it happens
Trigger: Executing learn with memory.backend set to "hindsight" (or the tool reached via the else-branch default) while getHindsightSessionState() returns undefined — Hindsight failed/never initialized, was disabled, or the session object lacks the accessor.
Common situations: Hindsight service unavailable or misconfigured at session start while the setting still says hindsight; config migration left a stale backend value; SDK embedding without Hindsight wiring.
Related errors
- Mnemopi backend is not initialised for this session.
- Mnemopi 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/f7b4d20d0343e46d.
Report an issue: GitHub.