can1357/oh-my-pi · error · TypeError
Plugin must implement onConsolidate
Error message
Plugin must implement onConsolidate
What it means
MnemopiPlugin's onConsolidate is a throwing stub that subclasses must override; the host calls it when working memories are consolidated into a summary. This TypeError means the plugin received a consolidation event without implementing the hook.
Source
Thrown at packages/mnemopi/src/core/plugins.ts:43
this.enabled = (ctor.prototype.enabled as boolean | undefined) ?? this.enabled;
}
initialize(): void {
this.initialized = true;
}
shutdown(): void {
this.initialized = false;
}
onRemember(_memory: MemoryDict): void {
throw new TypeError("Plugin must implement onRemember");
}
onRecall(_memory: MemoryDict): void {
throw new TypeError("Plugin must implement onRecall");
}
onConsolidate(_summary: MemoryDict): void {
throw new TypeError("Plugin must implement onConsolidate");
}
onInvalidate(_memoryId: string): void {
throw new TypeError("Plugin must implement onInvalidate");
}
toDict(): Record<string, unknown> {
return {
name: this.name,
version: this.version,
enabled: this.enabled,
initialized: this.initialized,
config: this.config,
};
}
}
function previewContent(content: unknown, maxLen = 80): string {
const text = typeof content === "string" ? content : "";
if (text.length <= maxLen) return text;View on GitHub (pinned to 9690622007)
Solutions
- Override onConsolidate(summary: MemoryDict): void in the plugin subclass
- Add an empty override if consolidation summaries don't matter to the plugin
- Check that the plugin class hierarchy actually extends the version of MnemopiPlugin you think it does (duplicate installs can cause base-class stubs to win)
Example fix
// before
class MyPlugin extends MnemopiPlugin { /* no onConsolidate */ }
// after
class MyPlugin extends MnemopiPlugin { override onConsolidate(s: MemoryDict): void { /* ... */ } } Defensive patterns
Strategy: type-guard
Validate before calling
function implementsOnConsolidate(p: MnemopiPlugin): boolean {
return p.onConsolidate !== MnemopiPlugin.prototype.onConsolidate;
}
if (!implementsOnConsolidate(plugin)) throw new Error(`plugin ${plugin.name} must override onConsolidate`); Type guard
function overridesOnConsolidate<P extends MnemopiPlugin>(p: P): p is P & { onConsolidate(s: MemoryDict): void } {
return p.onConsolidate !== MnemopiPlugin.prototype.onConsolidate;
} Try / catch
try {
host.consolidate(summary);
} catch (err) {
if (err instanceof TypeError && err.message === "Plugin must implement onConsolidate") {
logger.error(`plugin ${plugin.name} lacks onConsolidate; excluding from consolidation runs`);
} else throw err;
} Prevention
- Implement every hook, even if consolidation is a no-op for your plugin
- Exercise a consolidation run in plugin CI so missing overrides surface before production
- Use `override` keyword for compile-time protection
- Watch for duplicate MnemopiPlugin copies in node_modules that break prototype identity
When it happens
Trigger: A registered plugin subclass lacking an onConsolidate override, triggered during a memory-consolidation run when the host calls plugin.onConsolidate(summary).
Common situations: Plugins written before consolidation events existed; a plugin that implemented the other three hooks but forgot this one; calling the stub via super.onConsolidate() from a partial override.
Related errors
- Plugin must implement onRemember
- Plugin must implement onRecall
- Plugin must implement onInvalidate
- MnemopiPlugin is abstract
- Destination option ${key} must be a string
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/68d214fc7eef30c9.
Report an issue: GitHub.