mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-31 13:08:38 +00:00
perf(gateway): avoid cloning live switch store reads
This commit is contained in:
@@ -398,12 +398,13 @@ describe("live model switch", () => {
|
||||
|
||||
describe("shouldSwitchToLiveModel", () => {
|
||||
it("returns the persisted selection when liveModelSwitchPending is true and model differs", async () => {
|
||||
const sessionEntry = {
|
||||
liveModelSwitchPending: true,
|
||||
providerOverride: "openai",
|
||||
modelOverride: "gpt-5.4",
|
||||
};
|
||||
state.loadSessionStoreMock.mockReturnValue({
|
||||
main: {
|
||||
liveModelSwitchPending: true,
|
||||
providerOverride: "openai",
|
||||
modelOverride: "gpt-5.4",
|
||||
},
|
||||
main: sessionEntry,
|
||||
});
|
||||
|
||||
const { shouldSwitchToLiveModel } = await loadModule();
|
||||
@@ -431,15 +432,20 @@ describe("live model switch", () => {
|
||||
const result = shouldSwitchToLiveModel(makeShouldSwitchParams());
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
expect(state.loadSessionStoreMock).toHaveBeenCalledWith("/tmp/session-store.json", {
|
||||
skipCache: true,
|
||||
clone: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("returns undefined when liveModelSwitchPending is true but models match", async () => {
|
||||
const sessionEntry = {
|
||||
liveModelSwitchPending: true,
|
||||
providerOverride: "anthropic",
|
||||
modelOverride: "claude-opus-4-6",
|
||||
};
|
||||
state.loadSessionStoreMock.mockReturnValue({
|
||||
main: {
|
||||
liveModelSwitchPending: true,
|
||||
providerOverride: "anthropic",
|
||||
modelOverride: "claude-opus-4-6",
|
||||
},
|
||||
main: sessionEntry,
|
||||
});
|
||||
|
||||
const { shouldSwitchToLiveModel } = await loadModule();
|
||||
|
||||
@@ -159,7 +159,7 @@ export function shouldSwitchToLiveModel(params: {
|
||||
const storePath = resolveStorePath(cfg.session?.store, {
|
||||
agentId: params.agentId?.trim(),
|
||||
});
|
||||
const entry = loadSessionStore(storePath, { skipCache: true })[sessionKey];
|
||||
const entry = loadSessionStore(storePath, { skipCache: true, clone: false })[sessionKey];
|
||||
if (!entry?.liveModelSwitchPending) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user