mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:20:43 +00:00
fix(hooks): avoid stale active-memory startup fallback
This commit is contained in:
@@ -365,6 +365,27 @@ describe("active-memory plugin", () => {
|
||||
expect(runEmbeddedPiAgent).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("fails closed when the live active-memory plugin entry is removed", async () => {
|
||||
configFile = {
|
||||
plugins: {
|
||||
entries: {},
|
||||
},
|
||||
};
|
||||
|
||||
const result = await hooks.before_prompt_build(
|
||||
{ prompt: "what wings should i order after active memory is removed?", messages: [] },
|
||||
{
|
||||
agentId: "main",
|
||||
trigger: "user",
|
||||
sessionKey: "agent:main:live-config-removed",
|
||||
messageProvider: "webchat",
|
||||
},
|
||||
);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
expect(runEmbeddedPiAgent).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not run for agents that are not explicitly targeted", async () => {
|
||||
const result = await hooks.before_prompt_build(
|
||||
{ prompt: "what wings should i order?", messages: [] },
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
resolveAgentWorkspaceDir,
|
||||
} from "openclaw/plugin-sdk/agent-runtime";
|
||||
import {
|
||||
resolveLivePluginConfigObject,
|
||||
resolvePluginConfigObject,
|
||||
resolveSessionStoreEntry,
|
||||
updateSessionStore,
|
||||
@@ -1883,11 +1884,15 @@ export default definePluginEntry({
|
||||
};
|
||||
warnDeprecatedModelFallbackPolicy(api.pluginConfig);
|
||||
const refreshLiveConfigFromRuntime = () => {
|
||||
const livePluginConfig =
|
||||
resolvePluginConfigObject(api.runtime.config.loadConfig(), "active-memory") ??
|
||||
api.pluginConfig;
|
||||
config = normalizePluginConfig(livePluginConfig);
|
||||
warnDeprecatedModelFallbackPolicy(livePluginConfig);
|
||||
const livePluginConfig = resolveLivePluginConfigObject(
|
||||
api.runtime.config?.loadConfig,
|
||||
"active-memory",
|
||||
api.pluginConfig as Record<string, unknown>,
|
||||
);
|
||||
config = normalizePluginConfig(livePluginConfig ?? { enabled: false });
|
||||
if (livePluginConfig) {
|
||||
warnDeprecatedModelFallbackPolicy(livePluginConfig);
|
||||
}
|
||||
};
|
||||
api.registerCommand({
|
||||
name: "active-memory",
|
||||
|
||||
Reference in New Issue
Block a user