diff --git a/examples/openclaw-plugin/index.ts b/examples/openclaw-plugin/index.ts index 7374d190..04587c22 100644 --- a/examples/openclaw-plugin/index.ts +++ b/examples/openclaw-plugin/index.ts @@ -26,7 +26,7 @@ import { resolvePythonCommand, prepareLocalPort, } from "./process-manager.js"; -import { createMemoryOpenVikingContextEngine } from "./context-engine.js"; +import { createMemoryOpenVikingContextEngine, mapSessionKeyToOVSessionId } from "./context-engine.js"; import type { ContextEngineWithSessionMapping } from "./context-engine.js"; type PluginLogger = { @@ -263,6 +263,12 @@ const contextEnginePlugin = { sessionId = await contextEngineRef.resolveOVSession(sessionKeyIn); usedMappedSession = true; } + if (!sessionId && sessionKeyIn) { + // Fallback: resolve directly without contextEngineRef (covers cases + // where registerContextEngine is unavailable or factory not yet called) + sessionId = mapSessionKeyToOVSessionId(sessionKeyIn); + usedMappedSession = true; + } if (!sessionId) { return { content: [{ type: "text", text: "Either sessionKey or sessionId is required to store memory." }],