

















@@ -11,6 +11,7 @@ import * as modelSelectionModule from "../agents/model-selection.js";
1111import { runEmbeddedPiAgent } from "../agents/pi-embedded.js";
1212import { BASE_THINKING_LEVELS } from "../auto-reply/thinking.shared.js";
1313import * as runtimeSnapshotModule from "../config/runtime-snapshot.js";
14+import { loadSessionStore } from "../config/sessions/store-load.js";
1415import { clearSessionStoreCacheForTest } from "../config/sessions/store.js";
1516import type { OpenClawConfig } from "../config/types.openclaw.js";
1617import {
@@ -23,7 +24,7 @@ import type { PluginProviderRegistration } from "../plugins/registry.js";
2324import { resetPluginRuntimeStateForTest, setActivePluginRegistry } from "../plugins/runtime.js";
2425import type { RuntimeEnv } from "../runtime.js";
2526import { createTestRegistry } from "../test-utils/channel-plugins.js";
26-import { agentCommand, agentCommandFromIngress } from "./agent.js";
27+import { agentCommand, agentCommandFromIngress, testing as agentCommandTesting } from "./agent.js";
2728import { createThrowingTestRuntime } from "./test-runtime-config-helpers.js";
28292930const configIoMocks = vi.hoisted(() => ({
@@ -710,6 +711,34 @@ describe("agentCommand", () => {
710711});
711712});
712713714+it("borrows session lookup data without returning cached mutable store objects", async () => {
715+await withTempHome(async (home) => {
716+const store = path.join(home, "sessions.json");
717+const sessionKey = "agent:main:cache-borrow";
718+writeSessionStoreSeed(store, {
719+[sessionKey]: {
720+sessionId: "session-cache-borrow",
721+updatedAt: Date.now(),
722+thinkingLevel: "low",
723+},
724+});
725+mockConfig(home, store, { models: {} });
726+727+const prepared = await agentCommandTesting.prepareAgentCommandExecution(
728+{
729+message: "prepare only",
730+ sessionKey,
731+},
732+runtime,
733+);
734+const cached = loadSessionStore(store, { clone: false });
735+736+expect(prepared.sessionStore).not.toBe(cached);
737+expect(prepared.sessionEntry).not.toBe(cached[sessionKey]);
738+expect(prepared.sessionStore?.[sessionKey]).toBe(prepared.sessionEntry);
739+});
740+});
741+713742it("passes resolved session-id resume files to embedded runs", async () => {
714743await withTempHome(async (home) => {
715744const resumeStore = path.join(home, "sessions-resume.json");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。