惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
Stack Overflow Blog
Stack Overflow Blog
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
DataBreaches.Net
GbyAI
GbyAI
Microsoft Security Blog
Microsoft Security Blog
博客园_首页
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Engineering at Meta
Engineering at Meta
IT之家
IT之家
MongoDB | Blog
MongoDB | Blog
The GitHub Blog
The GitHub Blog
月光博客
月光博客
U
Unit 42
Hugging Face - Blog
Hugging Face - Blog
博客园 - 叶小钗
腾讯CDC
B
Blog RSS Feed
博客园 - Franky
爱范儿
爱范儿

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor: route boot session mapping through accessor (#9...
jalehman · 2026-06-24 · via Recent Commits to openclaw:main

@@ -18,8 +18,7 @@ import {

1818

resolveMainSessionKey,

1919

} from "../config/sessions/main-session.js";

2020

import { resolveStorePath } from "../config/sessions/paths.js";

21-

import { loadSessionStore, updateSessionStore } from "../config/sessions/store.js";

22-

import type { SessionEntry } from "../config/sessions/types.js";

21+

import { preserveTemporarySessionMapping } from "../config/sessions/session-accessor.js";

2322

import type { OpenClawConfig } from "../config/types.openclaw.js";

2423

import { formatErrorMessage } from "../infra/errors.js";

2524

import { createSubsystemLogger } from "../logging/subsystem.js";

@@ -33,14 +32,6 @@ function generateBootSessionId(): string {

3332

return `boot-${ts}-${suffix}`;

3433

}

353436-

type SessionMappingSnapshot = {

37-

storePath: string;

38-

sessionKey: string;

39-

canRestore: boolean;

40-

hadEntry: boolean;

41-

entry?: SessionEntry;

42-

};

43-4435

const log = createSubsystemLogger("gateway/boot");

4536

const BOOT_FILENAME = "BOOT.md";

4637

@@ -101,68 +92,6 @@ async function loadBootFile(

10192

}

10293

}

10394104-

function snapshotSessionMapping(params: {

105-

cfg: OpenClawConfig;

106-

sessionKey: string;

107-

}): SessionMappingSnapshot {

108-

const agentId = resolveAgentIdFromSessionKey(params.sessionKey);

109-

const storePath = resolveStorePath(params.cfg.session?.store, { agentId });

110-

try {

111-

const store = loadSessionStore(storePath, { skipCache: true });

112-

const entry = store[params.sessionKey];

113-

if (!entry) {

114-

return {

115-

storePath,

116-

sessionKey: params.sessionKey,

117-

canRestore: true,

118-

hadEntry: false,

119-

};

120-

}

121-

return {

122-

storePath,

123-

sessionKey: params.sessionKey,

124-

canRestore: true,

125-

hadEntry: true,

126-

entry: structuredClone(entry),

127-

};

128-

} catch (err) {

129-

log.debug("boot: could not snapshot session mapping", {

130-

sessionKey: params.sessionKey,

131-

error: String(err),

132-

});

133-

return {

134-

storePath,

135-

sessionKey: params.sessionKey,

136-

canRestore: false,

137-

hadEntry: false,

138-

};

139-

}

140-

}

141-142-

async function restoreSessionMapping(

143-

snapshot: SessionMappingSnapshot,

144-

): Promise<string | undefined> {

145-

if (!snapshot.canRestore) {

146-

return undefined;

147-

}

148-

try {

149-

await updateSessionStore(

150-

snapshot.storePath,

151-

(store) => {

152-

if (snapshot.hadEntry && snapshot.entry) {

153-

store[snapshot.sessionKey] = snapshot.entry;

154-

return;

155-

}

156-

delete store[snapshot.sessionKey];

157-

},

158-

{ activeSessionKey: snapshot.sessionKey },

159-

);

160-

return undefined;

161-

} catch (err) {

162-

return formatErrorMessage(err);

163-

}

164-

}

165-16695

export async function runBootOnce(params: {

16796

cfg: OpenClawConfig;

16897

deps: CliDeps;

@@ -193,39 +122,49 @@ export async function runBootOnce(params: {

193122

const sessionKey = resolveBootSessionKey(mainSessionKey);

194123

const message = buildBootPrompt(result.content ?? "");

195124

const sessionId = generateBootSessionId();

196-

const mappingSnapshot = snapshotSessionMapping({

197-

cfg: params.cfg,

198-

sessionKey,

199-

});

125+

const agentId = resolveAgentIdFromSessionKey(sessionKey);

126+

const storePath = resolveStorePath(params.cfg.session?.store, { agentId });

200127201-

// Register the boot prompt for the message-tool echo guard so the

202-

// tool layer can drop fallback-model echoes that copy substantial

203-

// BOOT.md content without preserving the wrapper markers above.

204-

// Always cleared in finally so a failed run does not leave a stale

205-

// entry that mis-fires on an unrelated subsequent run reusing the

206-

// same session key. Refs #53732.

207-

setBootEchoContextForSession(sessionKey, message);

208-

let agentFailure: string | undefined;

209-

try {

210-

await agentCommand(

211-

{

212-

message,

213-

sessionKey,

214-

sessionId,

215-

deliver: false,

216-

suppressPromptPersistence: true,

217-

},

218-

bootRuntime,

219-

params.deps,

220-

);

221-

} catch (err) {

222-

agentFailure = formatErrorMessage(err);

223-

log.error(`boot: agent run failed: ${agentFailure}`);

224-

} finally {

225-

clearBootEchoContextForSession(sessionKey);

128+

const mappingPreservation = await preserveTemporarySessionMapping(

129+

{ storePath, sessionKey },

130+

async () => {

131+

// Register the boot prompt for the message-tool echo guard so the

132+

// tool layer can drop fallback-model echoes that copy substantial

133+

// BOOT.md content without preserving the wrapper markers above.

134+

// Always cleared in finally so a failed run does not leave a stale

135+

// entry that mis-fires on an unrelated subsequent run reusing the

136+

// same session key. Refs #53732.

137+

setBootEchoContextForSession(sessionKey, message);

138+

try {

139+

await agentCommand(

140+

{

141+

message,

142+

sessionKey,

143+

sessionId,

144+

deliver: false,

145+

suppressPromptPersistence: true,

146+

},

147+

bootRuntime,

148+

params.deps,

149+

);

150+

return undefined;

151+

} catch (err) {

152+

const failure = formatErrorMessage(err);

153+

log.error(`boot: agent run failed: ${failure}`);

154+

return failure;

155+

} finally {

156+

clearBootEchoContextForSession(sessionKey);

157+

}

158+

},

159+

);

160+

const agentFailure = mappingPreservation.result;

161+

if (mappingPreservation.snapshotFailure) {

162+

log.debug("boot: could not snapshot session mapping", {

163+

sessionKey,

164+

error: mappingPreservation.snapshotFailure,

165+

});

226166

}

227-228-

const mappingRestoreFailure = await restoreSessionMapping(mappingSnapshot);

167+

const mappingRestoreFailure = mappingPreservation.restoreFailure;

229168

if (mappingRestoreFailure) {

230169

log.error(`boot: failed to restore session mapping: ${mappingRestoreFailure}`);

231170

}