

















@@ -762,16 +762,17 @@ export function resolveDeletedAgentIdFromSessionKey(
762762return agentId;
763763}
764764765-export function loadSessionEntry(sessionKey: string, opts?: { agentId?: string }) {
765+export function loadSessionEntry(sessionKey: string, opts?: { agentId?: string; clone?: boolean }) {
766766const cfg = getRuntimeConfig();
767767const key = normalizeOptionalString(sessionKey) ?? "";
768768const target = resolveGatewaySessionStoreTarget({
769769 cfg,
770770 key,
771+ ...(opts?.clone === false ? { clone: false } : {}),
771772 ...(opts?.agentId ? { agentId: opts.agentId } : {}),
772773});
773774const storePath = target.storePath;
774-const store = loadSessionStore(storePath);
775+const store = loadSessionStore(storePath, opts?.clone === false ? { clone: false } : undefined);
775776const freshestMatch = resolveFreshestSessionStoreMatchFromStoreKeys(store, target.storeKeys);
776777const legacyKey = freshestMatch?.key !== target.canonicalKey ? freshestMatch?.key : undefined;
777778return {
@@ -1148,6 +1149,7 @@ function resolveGatewaySessionStoreLookup(params: {
11481149key: string;
11491150canonicalKey: string;
11501151agentId: string;
1152+clone?: boolean;
11511153initialStore?: Record<string, SessionEntry>;
11521154}): {
11531155storePath: string;
@@ -1160,8 +1162,9 @@ function resolveGatewaySessionStoreLookup(params: {
11601162agentId: params.agentId,
11611163storePath: resolveStorePath(params.cfg.session?.store, { agentId: params.agentId }),
11621164};
1165+const loadOptions = params.clone === false ? { clone: false } : undefined;
11631166let selectedStorePath = fallback.storePath;
1164-let selectedStore = params.initialStore ?? loadSessionStore(fallback.storePath);
1167+let selectedStore = params.initialStore ?? loadSessionStore(fallback.storePath, loadOptions);
11651168let selectedMatch = findFreshestStoreMatch(selectedStore, ...scanTargets);
11661169let selectedUpdatedAt = selectedMatch?.entry.updatedAt ?? Number.NEGATIVE_INFINITY;
11671170@@ -1170,7 +1173,7 @@ function resolveGatewaySessionStoreLookup(params: {
11701173if (!candidate) {
11711174continue;
11721175}
1173-const store = loadSessionStore(candidate.storePath);
1176+const store = loadSessionStore(candidate.storePath, loadOptions);
11741177const match = findFreshestStoreMatch(store, ...scanTargets);
11751178if (!match) {
11761179continue;
@@ -1196,6 +1199,7 @@ function resolveGatewaySessionStoreLookup(params: {
11961199function resolveExplicitDeletedLegacyMainStoreTarget(params: {
11971200cfg: OpenClawConfig;
11981201key: string;
1202+clone?: boolean;
11991203scanLegacyKeys?: boolean;
12001204}): {
12011205agentId: string;
@@ -1232,11 +1236,12 @@ function resolveExplicitDeletedLegacyMainStoreTarget(params: {
12321236match: { entry: SessionEntry; key: string };
12331237}
12341238| undefined;
1239+const loadOptions = params.clone === false ? { clone: false } : undefined;
12351240for (const target of resolveAllAgentSessionStoreTargetsSync(params.cfg)) {
12361241if (target.agentId !== legacyAgentId) {
12371242continue;
12381243}
1239-const store = loadSessionStore(target.storePath);
1244+const store = loadSessionStore(target.storePath, loadOptions);
12401245const match = findFreshestStoreMatch(store, ...lookupSeeds);
12411246if (!match) {
12421247continue;
@@ -1274,6 +1279,7 @@ export function resolveGatewaySessionStoreTarget(params: {
12741279cfg: OpenClawConfig;
12751280key: string;
12761281agentId?: string;
1282+clone?: boolean;
12771283scanLegacyKeys?: boolean;
12781284store?: Record<string, SessionEntry>;
12791285}): {
@@ -1286,6 +1292,7 @@ export function resolveGatewaySessionStoreTarget(params: {
12861292const explicitDeletedMainTarget = resolveExplicitDeletedLegacyMainStoreTarget({
12871293cfg: params.cfg,
12881294 key,
1295+clone: params.clone,
12891296scanLegacyKeys: params.scanLegacyKeys,
12901297});
12911298if (explicitDeletedMainTarget) {
@@ -1306,6 +1313,7 @@ export function resolveGatewaySessionStoreTarget(params: {
13061313 key,
13071314 canonicalKey,
13081315 agentId,
1316+clone: params.clone,
13091317initialStore: params.store,
13101318});
13111319此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。