mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:40:44 +00:00
fix(hooks): stop memory-core runtime config fallback
This commit is contained in:
@@ -1470,6 +1470,74 @@ describe("gateway startup reconciliation", () => {
|
||||
clearInternalHooks();
|
||||
}
|
||||
});
|
||||
|
||||
it("does not fall back to startup plugin config when live memory-core config is removed", async () => {
|
||||
clearInternalHooks();
|
||||
const logger = createLogger();
|
||||
const harness = createCronHarness();
|
||||
const onMock = vi.fn();
|
||||
const runtimeLoadConfig = vi.fn(
|
||||
() =>
|
||||
({
|
||||
agents: {
|
||||
list: [{ id: "main", default: true }],
|
||||
},
|
||||
}) as OpenClawConfig,
|
||||
);
|
||||
const api: DreamingPluginApiTestDouble = {
|
||||
config: {
|
||||
plugins: {
|
||||
entries: {
|
||||
"memory-core": {
|
||||
config: {
|
||||
dreaming: {
|
||||
enabled: true,
|
||||
frequency: "15 4 * * *",
|
||||
timezone: "UTC",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig,
|
||||
pluginConfig: {},
|
||||
logger,
|
||||
runtime: {
|
||||
config: {
|
||||
loadConfig: runtimeLoadConfig,
|
||||
},
|
||||
},
|
||||
on: onMock,
|
||||
};
|
||||
|
||||
try {
|
||||
registerShortTermPromotionDreamingForTest(api);
|
||||
await triggerGatewayStart(onMock, {
|
||||
config: api.config,
|
||||
getCron: () => harness.cron,
|
||||
});
|
||||
|
||||
const sessionKey = "agent:main:main";
|
||||
enqueueSystemEvent(constants.DREAMING_SYSTEM_EVENT_TEXT, {
|
||||
sessionKey,
|
||||
contextKey: "cron:memory-dreaming",
|
||||
});
|
||||
|
||||
const beforeAgentReply = getBeforeAgentReplyHandler(onMock);
|
||||
const result = await beforeAgentReply(
|
||||
{ cleanedBody: constants.DREAMING_SYSTEM_EVENT_TEXT },
|
||||
{ trigger: "heartbeat", workspaceDir: ".", sessionKey },
|
||||
);
|
||||
|
||||
expect(runtimeLoadConfig).toHaveBeenCalled();
|
||||
expect(result).toEqual({
|
||||
handled: true,
|
||||
reason: "memory-core: short-term dreaming disabled",
|
||||
});
|
||||
} finally {
|
||||
clearInternalHooks();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("short-term dreaming trigger", () => {
|
||||
|
||||
@@ -664,11 +664,14 @@ export function registerShortTermPromotionDreaming(api: OpenClawPluginApi): void
|
||||
}): Promise<ShortTermPromotionDreamingConfig> => {
|
||||
const startupCfg =
|
||||
params.reason === "startup" ? (params.startupConfig ?? api.config) : resolveCurrentConfig();
|
||||
const pluginConfig =
|
||||
params.reason === "runtime"
|
||||
? resolveMemoryCorePluginConfig(startupCfg)
|
||||
: (resolveMemoryCorePluginConfig(startupCfg) ??
|
||||
resolveMemoryCorePluginConfig(api.config) ??
|
||||
api.pluginConfig);
|
||||
const config = resolveShortTermPromotionDreamingConfig({
|
||||
pluginConfig:
|
||||
resolveMemoryCorePluginConfig(startupCfg) ??
|
||||
resolveMemoryCorePluginConfig(api.config) ??
|
||||
api.pluginConfig,
|
||||
pluginConfig,
|
||||
cfg: startupCfg,
|
||||
});
|
||||
if (params.reason === "startup") {
|
||||
|
||||
@@ -51,6 +51,11 @@ const BUNDLED_LIVE_CONFIG_HOOK_GUARDS = {
|
||||
'resolvePluginConfigObject(api.runtime.config.loadConfig(), "active-memory")',
|
||||
"api.runtime.config.loadConfig()",
|
||||
],
|
||||
"extensions/memory-core/src/dreaming.ts": [
|
||||
'params.reason === "runtime"',
|
||||
"resolveMemoryCorePluginConfig(startupCfg)",
|
||||
"api.runtime.config?.loadConfig?.() ?? api.config",
|
||||
],
|
||||
"extensions/memory-lancedb/index.ts": [
|
||||
'resolvePluginConfigObject(runtimeConfig, "memory-lancedb")',
|
||||
"api.runtime.config?.loadConfig?.()",
|
||||
|
||||
Reference in New Issue
Block a user