diff --git a/ena-planner/ena-planner.js b/ena-planner/ena-planner.js index 6a6d7bd..7f588ed 100644 --- a/ena-planner/ena-planner.js +++ b/ena-planner/ena-planner.js @@ -13,6 +13,13 @@ const _currentModuleUrl = import.meta.url; let _bmeRuntime = null; +function getPlannerRecallTimeoutMs() { + const timeoutMs = Number(_bmeRuntime?.getPlannerRecallTimeoutMs?.()); + return Number.isFinite(timeoutMs) && timeoutMs > 0 + ? timeoutMs + : VECTOR_RECALL_TIMEOUT_MS; +} + function getTrustedOrigin() { return window.location.origin; } function postToIframe(iframe, payload) { @@ -1135,7 +1142,9 @@ async function buildPlannerMessages(rawUserInput) { let plannerRecall = null; if (_bmeRuntime?.runPlannerRecallForEna) { const controller = new AbortController(); - const timeoutId = setTimeout(() => controller.abort(), VECTOR_RECALL_TIMEOUT_MS); + const recallTimeoutMs = getPlannerRecallTimeoutMs(); + const recallStartedAt = Date.now(); + const timeoutId = setTimeout(() => controller.abort(), recallTimeoutMs); try { const recall = await _bmeRuntime.runPlannerRecallForEna({ rawUserInput, @@ -1148,12 +1157,15 @@ async function buildPlannerMessages(rawUserInput) { } } catch (e) { if (e?.name === 'AbortError') { - console.warn(`[Ena] BME recall timed out (> ${Math.floor(VECTOR_RECALL_TIMEOUT_MS / 1000)}s)`); + console.warn(`[Ena] BME recall timed out (> ${Math.floor(recallTimeoutMs / 1000)}s)`); } else { console.warn('[Ena] BME planner recall failed:', e); } } finally { clearTimeout(timeoutId); + debugLog( + `[Ena] Planner recall finished in ${Date.now() - recallStartedAt}ms (source=${memorySource}, timeout=${recallTimeoutMs}ms)`, + ); } } debugLog(`[Ena] Memory source: ${memorySource}`); diff --git a/index.js b/index.js index 36d9926..9c6bdaf 100644 --- a/index.js +++ b/index.js @@ -3237,6 +3237,10 @@ function getConfiguredTimeoutMs(settings = getSettings()) { })(); } +function getPlannerRecallTimeoutMs() { + return getConfiguredTimeoutMs(getSettings()); +} + function getEmbeddingConfig(mode = null) { const settings = getSettings(); return getVectorConfigFromSettings( @@ -10570,9 +10574,10 @@ async function onReembedDirect() { await initEnaPlanner({ getContext, getExtensionPath: () => `scripts/extensions/third-party/${MODULE_NAME}`, + getPlannerRecallTimeoutMs, isTrivialUserInput, preparePlannerRecallHandoff, - runPlannerRecallForEna, + runPlannerRecallForEna, }); debugLog("[ST-BME] Ena Planner module loaded"); } catch (error) {