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

推荐订阅源

博客园 - 三生石上(FineUI控件)
月光博客
月光博客
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队
Stack Overflow Blog
Stack Overflow Blog
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
IT之家
IT之家
宝玉的分享
宝玉的分享
A
About on SuperTechFans
Vercel News
Vercel News
P
Proofpoint News Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 【当耐特】
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Visual Studio Blog
Jina AI
Jina AI
Y
Y Combinator Blog
T
Tailwind CSS Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI

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(codex): split app-server attempt seams · opencla...
steipete · 2026-05-28 · via Recent Commits to openclaw:main

@@ -0,0 +1,97 @@

1+

import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";

2+

import type { CodexAppServerClient } from "./client.js";

3+

import { retireSharedCodexAppServerClientIfCurrent } from "./shared-client.js";

4+5+

export const CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS = 5_000;

6+

export const CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS = 5_000;

7+8+

export function interruptCodexTurnBestEffort(

9+

client: CodexAppServerClient,

10+

params: {

11+

threadId: string;

12+

turnId: string;

13+

timeoutMs?: number;

14+

},

15+

): void {

16+

const requestOptions =

17+

params.timeoutMs && Number.isFinite(params.timeoutMs) && params.timeoutMs > 0

18+

? { timeoutMs: params.timeoutMs }

19+

: undefined;

20+

const requestParams = { threadId: params.threadId, turnId: params.turnId };

21+

try {

22+

const interrupt = requestOptions

23+

? client.request("turn/interrupt", requestParams, requestOptions)

24+

: client.request("turn/interrupt", requestParams);

25+

void Promise.resolve(interrupt).catch((error: unknown) => {

26+

embeddedAgentLog.debug("codex app-server turn interrupt failed during abort", { error });

27+

});

28+

} catch (error) {

29+

embeddedAgentLog.debug("codex app-server turn interrupt failed during abort", { error });

30+

}

31+

}

32+33+

export async function unsubscribeCodexThreadBestEffort(

34+

client: CodexAppServerClient,

35+

params: {

36+

threadId: string;

37+

timeoutMs: number;

38+

},

39+

): Promise<void> {

40+

try {

41+

await client.request(

42+

"thread/unsubscribe",

43+

{ threadId: params.threadId },

44+

{ timeoutMs: params.timeoutMs },

45+

);

46+

} catch (error) {

47+

embeddedAgentLog.debug("codex app-server thread unsubscribe cleanup failed", {

48+

threadId: params.threadId,

49+

error,

50+

});

51+

}

52+

}

53+54+

export async function retireCodexAppServerClientAfterTimedOutTurn(

55+

client: CodexAppServerClient,

56+

params: {

57+

threadId: string;

58+

turnId: string;

59+

reason: string;

60+

},

61+

): Promise<void> {

62+

const retiredSharedClient = retireSharedCodexAppServerClientIfCurrent(client);

63+

const detachedSharedClient = Boolean(retiredSharedClient);

64+

interruptCodexTurnBestEffort(client, {

65+

threadId: params.threadId,

66+

turnId: params.turnId,

67+

timeoutMs: CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS,

68+

});

69+

await unsubscribeCodexThreadBestEffort(client, {

70+

threadId: params.threadId,

71+

timeoutMs: CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS,

72+

});

73+

let closedClient = retiredSharedClient?.closed ?? false;

74+

if (!detachedSharedClient) {

75+

const close = (client as { close?: () => void }).close;

76+

if (typeof close === "function") {

77+

try {

78+

close.call(client);

79+

closedClient = true;

80+

} catch (error) {

81+

embeddedAgentLog.debug("codex app-server client close failed during timeout cleanup", {

82+

threadId: params.threadId,

83+

turnId: params.turnId,

84+

error,

85+

});

86+

}

87+

}

88+

}

89+

embeddedAgentLog.warn("codex app-server client retired after timed-out turn", {

90+

threadId: params.threadId,

91+

turnId: params.turnId,

92+

reason: params.reason,

93+

detachedSharedClient,

94+

closedClient,

95+

activeSharedClientLeases: retiredSharedClient?.activeLeases ?? 0,

96+

});

97+

}