mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
fix(planner): align recall timeout with global setting
This commit is contained in:
@@ -13,6 +13,13 @@ const _currentModuleUrl = import.meta.url;
|
|||||||
|
|
||||||
let _bmeRuntime = null;
|
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 getTrustedOrigin() { return window.location.origin; }
|
||||||
|
|
||||||
function postToIframe(iframe, payload) {
|
function postToIframe(iframe, payload) {
|
||||||
@@ -1135,7 +1142,9 @@ async function buildPlannerMessages(rawUserInput) {
|
|||||||
let plannerRecall = null;
|
let plannerRecall = null;
|
||||||
if (_bmeRuntime?.runPlannerRecallForEna) {
|
if (_bmeRuntime?.runPlannerRecallForEna) {
|
||||||
const controller = new AbortController();
|
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 {
|
try {
|
||||||
const recall = await _bmeRuntime.runPlannerRecallForEna({
|
const recall = await _bmeRuntime.runPlannerRecallForEna({
|
||||||
rawUserInput,
|
rawUserInput,
|
||||||
@@ -1148,12 +1157,15 @@ async function buildPlannerMessages(rawUserInput) {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e?.name === 'AbortError') {
|
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 {
|
} else {
|
||||||
console.warn('[Ena] BME planner recall failed:', e);
|
console.warn('[Ena] BME planner recall failed:', e);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
|
debugLog(
|
||||||
|
`[Ena] Planner recall finished in ${Date.now() - recallStartedAt}ms (source=${memorySource}, timeout=${recallTimeoutMs}ms)`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debugLog(`[Ena] Memory source: ${memorySource}`);
|
debugLog(`[Ena] Memory source: ${memorySource}`);
|
||||||
|
|||||||
7
index.js
7
index.js
@@ -3237,6 +3237,10 @@ function getConfiguredTimeoutMs(settings = getSettings()) {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPlannerRecallTimeoutMs() {
|
||||||
|
return getConfiguredTimeoutMs(getSettings());
|
||||||
|
}
|
||||||
|
|
||||||
function getEmbeddingConfig(mode = null) {
|
function getEmbeddingConfig(mode = null) {
|
||||||
const settings = getSettings();
|
const settings = getSettings();
|
||||||
return getVectorConfigFromSettings(
|
return getVectorConfigFromSettings(
|
||||||
@@ -10570,9 +10574,10 @@ async function onReembedDirect() {
|
|||||||
await initEnaPlanner({
|
await initEnaPlanner({
|
||||||
getContext,
|
getContext,
|
||||||
getExtensionPath: () => `scripts/extensions/third-party/${MODULE_NAME}`,
|
getExtensionPath: () => `scripts/extensions/third-party/${MODULE_NAME}`,
|
||||||
|
getPlannerRecallTimeoutMs,
|
||||||
isTrivialUserInput,
|
isTrivialUserInput,
|
||||||
preparePlannerRecallHandoff,
|
preparePlannerRecallHandoff,
|
||||||
runPlannerRecallForEna,
|
runPlannerRecallForEna,
|
||||||
});
|
});
|
||||||
debugLog("[ST-BME] Ena Planner module loaded");
|
debugLog("[ST-BME] Ena Planner module loaded");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user