fix(memory): close local embedding providers on timeout (#84048)

Summary:
- The branch adds a close lifecycle for local memory embedding providers, scoped memory search/index teardown for one agent, Active Memory timeout cleanup, focused tests, and a changelog entry.
- Reproducibility: yes. The linked issue gives a concrete OpenClaw 2026.5.18 Telegram Active Memory timeout pa ... current-main source inspection confirms there is no timeout cleanup for that local embedding provider path.

Automerge notes:
- PR branch already contained follow-up commit before automerge: fix(memory): close local embedding providers on timeout

Validation:
- ClawSweeper review passed for head 8e2e369b5c.
- Required merge gates passed before the squash merge.

Prepared head SHA: 8e2e369b5c
Review: https://github.com/openclaw/openclaw/pull/84048#issuecomment-4485705481

Co-authored-by: brokemac79 <martin_cleary@yahoo.co.uk>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com>
Approved-by: hxy91819
Co-authored-by: hxy91819 <8814856+hxy91819@users.noreply.github.com>
This commit is contained in:
clawsweeper[bot]
2026-05-19 09:19:09 +00:00
committed by GitHub
parent aef93881af
commit 1c1c75df72
25 changed files with 750 additions and 33 deletions

View File

@@ -45,6 +45,7 @@ vi.mock("./memory-state.js", () => ({
let getActiveMemorySearchManager: typeof import("./memory-runtime.js").getActiveMemorySearchManager;
let resolveActiveMemoryBackendConfig: typeof import("./memory-runtime.js").resolveActiveMemoryBackendConfig;
let closeActiveMemorySearchManager: typeof import("./memory-runtime.js").closeActiveMemorySearchManager;
let closeActiveMemorySearchManagers: typeof import("./memory-runtime.js").closeActiveMemorySearchManagers;
function createMemoryAutoEnableFixture() {
@@ -67,6 +68,7 @@ function createMemoryRuntimeFixture() {
return {
getMemorySearchManager: vi.fn(async () => ({ manager: null, error: "no index" })),
resolveMemoryBackendConfig: vi.fn(() => ({ backend: "builtin" as const })),
closeMemorySearchManager: vi.fn(async () => {}),
};
}
@@ -147,6 +149,7 @@ describe("memory runtime auto-enable loading", () => {
({
getActiveMemorySearchManager,
resolveActiveMemoryBackendConfig,
closeActiveMemorySearchManager,
closeActiveMemorySearchManagers,
} = await import("./memory-runtime.js"));
resolveRuntimePluginRegistryMock.mockReset();
@@ -343,4 +346,18 @@ describe("memory runtime auto-enable loading", () => {
] as const)("$name", async ({ config, setup }) => {
await expectCloseMemoryRuntimeCase({ config, setup });
});
it("delegates scoped cleanup to the loaded memory runtime without reloading plugins", async () => {
const runtime = createMemoryRuntimeFixture();
const cfg = { plugins: {} };
getMemoryRuntimeMock.mockReturnValue(runtime);
await closeActiveMemorySearchManager({ cfg: cfg as never, agentId: "main" });
expect(runtime.closeMemorySearchManager).toHaveBeenCalledWith({
cfg,
agentId: "main",
});
expectNoMemoryRuntimeBootstrap();
});
});