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

推荐订阅源

MongoDB | Blog
MongoDB | Blog
J
Java Code Geeks
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
DataBreaches.Net
腾讯CDC
GbyAI
GbyAI
I
InfoQ
博客园 - Franky
G
Google Developers Blog
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
Vercel News
Vercel News
博客园_首页
MyScale Blog
MyScale Blog
Martin Fowler
Martin Fowler
N
Netflix TechBlog - Medium
V
V2EX
T
The Blog of Author Tim Ferriss
M
MIT News - Artificial intelligence
雷峰网
雷峰网
H
Hackread – Cybersecurity News, Data Breaches, AI and More
大猫的无限游戏
大猫的无限游戏
The GitHub Blog
The GitHub Blog

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(codex): bound app-server timeout fallout · openclaw/o...
steipete · 2026-05-27 · via Recent Commits to openclaw:main

File tree

  • extensions/codex/src

    • app-server

    • migration

  • src/agents/pi-embedded-runner/run

Original file line numberDiff line numberDiff line change

@@ -22,3 +22,13 @@ export const defaultCodexAppServerClientFactory: CodexAppServerClientFactory = (

2222

import("./shared-client.js").then(({ getSharedCodexAppServerClient }) =>

2323

getSharedCodexAppServerClient({ startOptions, authProfileId, agentDir, config }),

2424

);

25+
26+

export const defaultLeasedCodexAppServerClientFactory: CodexAppServerClientFactory = (

27+

startOptions,

28+

authProfileId,

29+

agentDir,

30+

config,

31+

) =>

32+

import("./shared-client.js").then(({ getLeasedSharedCodexAppServerClient }) =>

33+

getLeasedSharedCodexAppServerClient({ startOptions, authProfileId, agentDir, config }),

34+

);

Original file line numberDiff line numberDiff line change

@@ -74,10 +74,13 @@ async function withCodexAppServerModelClient<T>(

7474

): Promise<T> {

7575

const timeoutMs = options.timeoutMs ?? 2500;

7676

const useSharedClient = options.sharedClient !== false;

77-

const { createIsolatedCodexAppServerClient, getSharedCodexAppServerClient } =

78-

await import("./shared-client.js");

77+

const {

78+

createIsolatedCodexAppServerClient,

79+

getLeasedSharedCodexAppServerClient,

80+

releaseLeasedSharedCodexAppServerClient,

81+

} = await import("./shared-client.js");

7982

const client = useSharedClient

80-

? await getSharedCodexAppServerClient({

83+

? await getLeasedSharedCodexAppServerClient({

8184

startOptions: options.startOptions,

8285

timeoutMs,

8386

authProfileId: options.authProfileId,

@@ -94,7 +97,9 @@ async function withCodexAppServerModelClient<T>(

9497

try {

9598

return await run({ client, timeoutMs });

9699

} finally {

97-

if (!useSharedClient) {

100+

if (useSharedClient) {

101+

releaseLeasedSharedCodexAppServerClient(client);

102+

} else {

98103

client.close();

99104

}

100105

}

Original file line numberDiff line numberDiff line change

@@ -5,7 +5,11 @@ const sharedClientMocks = vi.hoisted(() => ({

55

getSharedCodexAppServerClient: vi.fn(),

66

}));

77
8-

vi.mock("./shared-client.js", () => sharedClientMocks);

8+

vi.mock("./shared-client.js", () => ({

9+

...sharedClientMocks,

10+

getLeasedSharedCodexAppServerClient: sharedClientMocks.getSharedCodexAppServerClient,

11+

releaseLeasedSharedCodexAppServerClient: vi.fn(),

12+

}));

913
1014

const { requestCodexAppServerJson } = await import("./request.js");

1115
Original file line numberDiff line numberDiff line change

@@ -9,7 +9,8 @@ import type {

99

import { resolveCodexAppServerDirectSandboxBypassBlock } from "./sandbox-guard.js";

1010

import {

1111

createIsolatedCodexAppServerClient,

12-

getSharedCodexAppServerClient,

12+

getLeasedSharedCodexAppServerClient,

13+

releaseLeasedSharedCodexAppServerClient,

1314

} from "./shared-client.js";

1415

import { withTimeout } from "./timeout.js";

1516

@@ -63,7 +64,7 @@ export async function requestCodexAppServerJson<T = JsonValue | undefined>(param

6364

return await withTimeout(

6465

(async () => {

6566

const client = await (

66-

params.isolated ? createIsolatedCodexAppServerClient : getSharedCodexAppServerClient

67+

params.isolated ? createIsolatedCodexAppServerClient : getLeasedSharedCodexAppServerClient

6768

)({

6869

startOptions: params.startOptions,

6970

timeoutMs,

@@ -81,6 +82,8 @@ export async function requestCodexAppServerJson<T = JsonValue | undefined>(param

8182

// underlying codex binary, so the unref'd close() path can leave

8283

// the child running and keep the parent's event loop alive.

8384

await client.closeAndWait({ exitTimeoutMs: 2_000, forceKillDelayMs: 250 });

85+

} else {

86+

releaseLeasedSharedCodexAppServerClient(client);

8487

}

8588

}

8689

})(),

Original file line numberDiff line numberDiff line change

@@ -4160,7 +4160,7 @@ describe("runCodexAppServerAttempt", () => {

41604160

});

41614161

});

41624162
4163-

it("interrupts but keeps the app-server client alive when a turn timeout fires", async () => {

4163+

it("unsubscribes and closes the app-server client when the active turn goes idle past the attempt timeout", async () => {

41644164

const close = vi.fn();

41654165

const request = vi.fn(async (method: string) => {

41664166

if (method === "thread/start") {

@@ -4204,7 +4204,14 @@ describe("runCodexAppServerAttempt", () => {

42044204

},

42054205

{ timeoutMs: 5_000 },

42064206

);

4207-

expect(close).not.toHaveBeenCalled();

4207+

expect(request).toHaveBeenCalledWith(

4208+

"thread/unsubscribe",

4209+

{

4210+

threadId: "thread-1",

4211+

},

4212+

{ timeoutMs: 5_000 },

4213+

);

4214+

expect(close).toHaveBeenCalledTimes(1);

42084215

expect(queueActiveRunMessageForTest("session-1", "after timeout")).toBe(false);

42094216

});

42104217

@@ -5562,9 +5569,13 @@ describe("runCodexAppServerAttempt", () => {

55625569

),

55635570

{ interval: 1 },

55645571

);

5565-

expect(warn).not.toHaveBeenCalledWith(

5572+

expect(warn).toHaveBeenCalledWith(

55665573

"codex app-server client retired after timed-out turn",

5567-

expect.anything(),

5574+

expect.objectContaining({

5575+

reason: "turn_completion_idle_timeout",

5576+

threadId: "thread-1",

5577+

turnId: "turn-1",

5578+

}),

55685579

);

55695580

});

55705581