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

推荐订阅源

M
MIT News - Artificial intelligence
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
阮一峰的网络日志
阮一峰的网络日志
月光博客
月光博客
博客园 - Franky
腾讯CDC
T
Tailwind CSS Blog
Recent Announcements
Recent Announcements
V
V2EX
N
Netflix TechBlog - Medium
量子位
Jina AI
Jina AI
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
G
Google Developers Blog
爱范儿
爱范儿
博客园 - 叶小钗
D
Docker
MongoDB | Blog
MongoDB | Blog
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss

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
fix: repair stale session route state in doctor · opencla...
steipete · 2026-05-05 · via Recent Commits to openclaw:main

@@ -0,0 +1,236 @@

1+

import { describe, expect, it } from "vitest";

2+

import {

3+

applySessionRouteStateRepair,

4+

resolveConfiguredDoctorSessionStateRoute,

5+

scanSessionRouteStateOwners,

6+

} from "./doctor-session-state-providers.js";

7+8+

const codexOwner = {

9+

id: "codex",

10+

label: "Codex",

11+

providerIds: ["codex", "codex-cli", "openai-codex"],

12+

runtimeIds: ["codex", "codex-cli"],

13+

cliSessionKeys: ["codex-cli"],

14+

authProfilePrefixes: ["codex:", "codex-cli:", "openai-codex:"],

15+

};

16+17+

describe("doctor session state provider routes", () => {

18+

it("preserves raw configured CLI runtimes before harness policy normalization", () => {

19+

expect(

20+

resolveConfiguredDoctorSessionStateRoute({

21+

cfg: {

22+

agents: {

23+

defaults: {

24+

model: { primary: "openai/gpt-5.5" },

25+

agentRuntime: { id: "codex-cli" },

26+

},

27+

},

28+

},

29+

sessionKey: "agent:main:telegram:direct:1",

30+

env: {},

31+

}),

32+

).toMatchObject({

33+

defaultProvider: "openai",

34+

configuredModelRefs: ["openai/gpt-5.5"],

35+

runtime: "codex-cli",

36+

});

37+

});

38+39+

it("lets environment CLI runtime overrides reach plugin-owned scanners", () => {

40+

expect(

41+

resolveConfiguredDoctorSessionStateRoute({

42+

cfg: {

43+

agents: {

44+

defaults: {

45+

model: { primary: "openai/gpt-5.5" },

46+

agentRuntime: { id: "pi" },

47+

},

48+

},

49+

},

50+

sessionKey: "agent:main:telegram:direct:1",

51+

env: { OPENCLAW_AGENT_RUNTIME: "codex-cli" },

52+

}),

53+

).toMatchObject({

54+

runtime: "codex-cli",

55+

});

56+

});

57+58+

it("clears auto-created route state when current route no longer uses the owner", () => {

59+

const sessionKey = "agent:main:telegram:direct:1";

60+

const entry: Record<string, unknown> = {

61+

sessionId: "sess-stale-codex",

62+

updatedAt: 1,

63+

providerOverride: "openai-codex",

64+

modelOverride: "gpt-5.4",

65+

modelOverrideSource: "auto",

66+

modelProvider: "openai-codex",

67+

model: "gpt-5.4",

68+

contextTokens: 1_050_000,

69+

systemPromptReport: { source: "run" },

70+

fallbackNoticeSelectedModel: "github-copilot/gpt-5-mini",

71+

fallbackNoticeActiveModel: "openai-codex/gpt-5.4",

72+

fallbackNoticeReason: "rate-limit",

73+

agentHarnessId: "codex",

74+

authProfileOverride: "openai-codex:default",

75+

authProfileOverrideSource: "auto",

76+

authProfileOverrideCompactionCount: 2,

77+

cliSessionBindings: {

78+

"codex-cli": { sessionId: "codex-session-1" },

79+

"claude-cli": { sessionId: "claude-session-1" },

80+

},

81+

cliSessionIds: {

82+

"codex-cli": "codex-session-1",

83+

"claude-cli": "claude-session-1",

84+

},

85+

};

86+87+

const scan = scanSessionRouteStateOwners({

88+

owners: [codexOwner],

89+

store: { [sessionKey]: entry },

90+

routes: {

91+

[sessionKey]: {

92+

defaultProvider: "github-copilot",

93+

configuredModelRefs: ["github-copilot/gpt-5-mini"],

94+

runtime: "pi",

95+

},

96+

},

97+

});

98+99+

expect(scan.manualReview).toEqual([]);

100+

expect(scan.repairs).toEqual([

101+

{

102+

key: sessionKey,

103+

ownerId: "codex",

104+

ownerLabel: "Codex",

105+

cliSessionKeys: ["codex-cli"],

106+

reasons: [

107+

"auto model override",

108+

"runtime model state",

109+

"pinned runtime",

110+

"CLI session binding",

111+

"auto auth profile override",

112+

],

113+

},

114+

]);

115+116+

expect(applySessionRouteStateRepair({ entry, repair: scan.repairs[0], now: 123 })).toBe(true);

117+

expect(entry).toMatchObject({

118+

sessionId: "sess-stale-codex",

119+

updatedAt: 123,

120+

cliSessionBindings: {

121+

"claude-cli": { sessionId: "claude-session-1" },

122+

},

123+

cliSessionIds: {

124+

"claude-cli": "claude-session-1",

125+

},

126+

});

127+

expect(entry.providerOverride).toBeUndefined();

128+

expect(entry.modelOverride).toBeUndefined();

129+

expect(entry.modelOverrideSource).toBeUndefined();

130+

expect(entry.modelProvider).toBeUndefined();

131+

expect(entry.model).toBeUndefined();

132+

expect(entry.contextTokens).toBeUndefined();

133+

expect(entry.systemPromptReport).toBeUndefined();

134+

expect(entry.agentHarnessId).toBeUndefined();

135+

expect(entry.authProfileOverride).toBeUndefined();

136+

expect(entry.authProfileOverrideSource).toBeUndefined();

137+

expect(entry.authProfileOverrideCompactionCount).toBeUndefined();

138+

expect(entry.fallbackNoticeActiveModel).toBeUndefined();

139+

});

140+141+

it("leaves explicit user owner model choices for manual review", () => {

142+

const sessionKey = "agent:main:telegram:direct:2";

143+

const entry: Record<string, unknown> = {

144+

sessionId: "sess-user-codex",

145+

updatedAt: 1,

146+

providerOverride: "openai-codex",

147+

modelOverride: "gpt-5.4",

148+

modelOverrideSource: "user",

149+

modelProvider: "openai-codex",

150+

model: "gpt-5.4",

151+

agentHarnessId: "codex",

152+

cliSessionBindings: {

153+

"codex-cli": { sessionId: "codex-session-2" },

154+

},

155+

};

156+157+

const scan = scanSessionRouteStateOwners({

158+

owners: [codexOwner],

159+

store: { [sessionKey]: entry },

160+

routes: {

161+

[sessionKey]: {

162+

defaultProvider: "github-copilot",

163+

configuredModelRefs: ["github-copilot/gpt-5-mini"],

164+

runtime: "pi",

165+

},

166+

},

167+

});

168+169+

expect(scan.repairs).toEqual([]);

170+

expect(scan.manualReview).toEqual([

171+

{

172+

key: sessionKey,

173+

ownerLabel: "Codex",

174+

message: `${sessionKey} (openai-codex/gpt-5.4, user)`,

175+

},

176+

]);

177+

});

178+179+

it("keeps owner state when owner remains in the configured route", () => {

180+

const sessionKey = "agent:main:telegram:direct:3";

181+

const entry: Record<string, unknown> = {

182+

sessionId: "sess-configured-codex",

183+

updatedAt: 1,

184+

providerOverride: "openai-codex",

185+

modelOverride: "gpt-5.4",

186+

modelOverrideSource: "auto",

187+

modelProvider: "openai-codex",

188+

model: "gpt-5.4",

189+

agentHarnessId: "codex",

190+

cliSessionBindings: {

191+

"codex-cli": { sessionId: "codex-session-3" },

192+

},

193+

};

194+195+

const scan = scanSessionRouteStateOwners({

196+

owners: [codexOwner],

197+

store: { [sessionKey]: entry },

198+

routes: {

199+

[sessionKey]: {

200+

defaultProvider: "github-copilot",

201+

configuredModelRefs: ["github-copilot/gpt-5-mini", "openai-codex/gpt-5.4"],

202+

runtime: "pi",

203+

},

204+

},

205+

});

206+207+

expect(scan).toEqual({ repairs: [], manualReview: [] });

208+

});

209+210+

it("keeps owner CLI state when owner runtime is still configured", () => {

211+

const sessionKey = "agent:main:telegram:direct:4";

212+

const entry: Record<string, unknown> = {

213+

sessionId: "sess-codex-cli",

214+

updatedAt: 1,

215+

modelProvider: "codex-cli",

216+

model: "gpt-5.5",

217+

cliSessionBindings: {

218+

"codex-cli": { sessionId: "codex-cli-session" },

219+

},

220+

};

221+222+

const scan = scanSessionRouteStateOwners({

223+

owners: [codexOwner],

224+

store: { [sessionKey]: entry },

225+

routes: {

226+

[sessionKey]: {

227+

defaultProvider: "openai",

228+

configuredModelRefs: ["openai/gpt-5.5"],

229+

runtime: "codex-cli",

230+

},

231+

},

232+

});

233+234+

expect(scan).toEqual({ repairs: [], manualReview: [] });

235+

});

236+

});