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

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
人人都是产品经理
人人都是产品经理
Engineering at Meta
Engineering at Meta
小众软件
小众软件
I
InfoQ
有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Martin Fowler
Martin Fowler
月光博客
月光博客
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
V
Visual Studio Blog
博客园 - 叶小钗
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
GbyAI
GbyAI
P
Proofpoint News Feed
Apple Machine Learning Research
Apple Machine Learning Research

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 gateway timeout embedded fallback session lock (#7454...
HemantSudars · 2026-04-30 · via Recent Commits to openclaw:main

@@ -10,6 +10,15 @@ import type { agentCommand as AgentCommand } from "./agent.js";

10101111

const loadConfig = vi.hoisted(() => vi.fn());

1212

const callGateway = vi.hoisted(() => vi.fn());

13+

const isGatewayTransportError = vi.hoisted(() =>

14+

vi.fn((value: unknown) => {

15+

if (!(value instanceof Error) || value.name !== "GatewayTransportError") {

16+

return false;

17+

}

18+

const kind = (value as { kind?: unknown }).kind;

19+

return kind === "closed" || kind === "timeout";

20+

}),

21+

);

1322

const agentCommand = vi.hoisted(() => vi.fn());

14231524

const runtime: RuntimeEnv = {

@@ -78,9 +87,24 @@ function mockLocalAgentReply(text = "local") {

7887

});

7988

}

808990+

function createGatewayTimeoutError() {

91+

const err = new Error("gateway timeout after 90000ms");

92+

err.name = "GatewayTransportError";

93+

return Object.assign(err, {

94+

kind: "timeout",

95+

timeoutMs: 90_000,

96+

connectionDetails: {

97+

url: "ws://127.0.0.1:18789",

98+

urlSource: "local loopback",

99+

message: "Gateway target: ws://127.0.0.1:18789",

100+

},

101+

});

102+

}

103+81104

vi.mock("../config/config.js", () => ({ getRuntimeConfig: loadConfig, loadConfig }));

82105

vi.mock("../gateway/call.js", () => ({

83106

callGateway,

107+

isGatewayTransportError,

84108

randomIdempotencyKey: () => "idem-1",

85109

}));

86110

vi.mock("./agent.js", () => ({ agentCommand }));

@@ -182,6 +206,73 @@ describe("agentCliCommand", () => {

182206

});

183207

});

184208209+

it("uses a fresh embedded session when gateway agent times out", async () => {

210+

await withTempStore(async () => {

211+

callGateway.mockRejectedValue(createGatewayTimeoutError());

212+

mockLocalAgentReply();

213+214+

await agentCliCommand(

215+

{

216+

message: "hi",

217+

sessionId: "locked-session",

218+

runId: "locked-run",

219+

},

220+

runtime,

221+

);

222+223+

expect(callGateway).toHaveBeenCalledTimes(1);

224+

expect(agentCommand).toHaveBeenCalledTimes(1);

225+

const fallbackOpts = agentCommand.mock.calls[0]?.[0] as {

226+

sessionId?: string;

227+

sessionKey?: string;

228+

runId?: string;

229+

resultMetaOverrides?: unknown;

230+

};

231+

expect(fallbackOpts.sessionId).toMatch(/^gateway-fallback-/);

232+

expect(fallbackOpts.sessionId).not.toBe("locked-session");

233+

expect(fallbackOpts.sessionKey).toBe(`agent:main:explicit:${fallbackOpts.sessionId}`);

234+

expect(fallbackOpts.runId).toBe(fallbackOpts.sessionId);

235+

expect(fallbackOpts.resultMetaOverrides).toMatchObject({

236+

transport: "embedded",

237+

fallbackFrom: "gateway",

238+

fallbackReason: "gateway_timeout",

239+

fallbackSessionId: fallbackOpts.sessionId,

240+

fallbackSessionKey: fallbackOpts.sessionKey,

241+

});

242+

expect(runtime.error).toHaveBeenCalledWith(

243+

expect.stringContaining(

244+

"Gateway agent timed out; running embedded agent with fresh session",

245+

),

246+

);

247+

expect(runtime.log).toHaveBeenCalledWith("local");

248+

});

249+

});

250+251+

it("keeps timeout fallback from replacing the routed conversation session key", async () => {

252+

await withTempStore(async () => {

253+

callGateway.mockRejectedValue(createGatewayTimeoutError());

254+

mockLocalAgentReply();

255+256+

await agentCliCommand(

257+

{

258+

message: "hi",

259+

to: "+1555",

260+

},

261+

runtime,

262+

);

263+264+

const fallbackOpts = agentCommand.mock.calls[0]?.[0] as {

265+

sessionId?: string;

266+

sessionKey?: string;

267+

to?: string;

268+

};

269+

expect(fallbackOpts.to).toBe("+1555");

270+

expect(fallbackOpts.sessionId).toMatch(/^gateway-fallback-/);

271+

expect(fallbackOpts.sessionKey).toBe(`agent:main:explicit:${fallbackOpts.sessionId}`);

272+

expect(fallbackOpts.sessionKey).not.toBe("agent:main:+1555");

273+

});

274+

});

275+185276

it("passes fallback metadata into JSON embedded fallback output", async () => {

186277

await withTempStore(async () => {

187278

callGateway.mockRejectedValue(new Error("gateway not connected"));