Skip to content

Commit b721cff

Browse files
authored
fix(inference): simplify lifecycle and preserve Codex tool identity (#117298)
1 parent aab7321 commit b721cff

49 files changed

Lines changed: 923 additions & 1893 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎extensions/codex/src/app-server/attempt-client-cleanup.ts‎

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
*/
44
import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
55
import { CodexAppServerRpcError, type CodexAppServerClient } from "./client.js";
6-
import {
7-
clearSharedCodexAppServerClientIfCurrent,
8-
clearSharedCodexAppServerClientIfCurrentAndUnclaimed,
9-
retireSharedCodexAppServerClientIfCurrent,
10-
} from "./shared-client.js";
6+
import { retireSharedCodexAppServerClientIfCurrent } from "./shared-client.js";
117
import { getCodexAppServerTurnRouter } from "./turn-router.js";
128

139
/** Timeout for best-effort app-server turn interruption during cleanup. */
@@ -72,30 +68,12 @@ export async function closeCodexStartupClientBestEffort(
7268
if (!client) {
7369
return;
7470
}
75-
const unclaimedSharedClient = clearSharedCodexAppServerClientIfCurrentAndUnclaimed(client);
76-
if (unclaimedSharedClient.closed) {
77-
await closeClientAndWaitIfAvailable(client);
78-
return;
79-
}
80-
if (unclaimedSharedClient.found) {
81-
const retired = retireSharedCodexAppServerClientIfCurrent(client);
82-
if (retired?.closed) {
83-
await closeClientAndWaitIfAvailable(client);
84-
}
85-
return;
86-
}
8771
const retiredSharedClient = retireSharedCodexAppServerClientIfCurrent(client);
88-
if (retiredSharedClient) {
89-
if (retiredSharedClient.closed) {
90-
await closeClientAndWaitIfAvailable(client);
91-
}
92-
return;
93-
}
94-
if (clearSharedCodexAppServerClientIfCurrent(client)) {
72+
// Detached entries retain every ordinary and native lease; only isolated or
73+
// already-closed shared clients may be joined without aborting sibling turns.
74+
if (!retiredSharedClient || retiredSharedClient.closed) {
9575
await closeClientAndWaitIfAvailable(client);
96-
return;
9776
}
98-
await closeClientAndWaitIfAvailable(client);
9977
}
10078

10179
/** Sends a bounded turn interrupt and waits for Codex to confirm terminal abort handling. */

‎extensions/codex/src/app-server/attempt-turn-watches.test.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ describe("Codex app-server attempt turn watches", () => {
5353
return true;
5454
},
5555
onTimeout: (timeout) => timeouts.push(timeout),
56-
onMarkTimedOut: vi.fn(),
5756
onAbort: (reason) => abortController.abort(reason),
5857
onCompleted: () => {
5958
completed = true;
6059
},
61-
onResolveCompletion: vi.fn(),
6260
onRecordEvent: (name, fields) => events.push({ name, fields }),
6361
onAttemptProgress: (reason) => progress.push(reason),
6462
onProgressDiagnostic: (reason) => diagnostics.push(reason),

0 commit comments

Comments
 (0)