From 5131e27a165e565d3ab46814b369404023193e6d Mon Sep 17 00:00:00 2001 From: mobilebarn Date: Fri, 27 Mar 2026 23:31:12 +1100 Subject: [PATCH] fix(openclaw-plugin): resolve sessionKey in memory_store without contextEngineRef memory_store failed with "Either sessionKey or sessionId is required" when sessionKey was passed but contextEngineRef was null (either because registerContextEngine was unavailable or the factory hadn't been called yet). Fall back to mapSessionKeyToOVSessionId directly so session mapping works regardless of context engine state. --- examples/openclaw-plugin/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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." }],