Skip to content

Commit a8d33f2

Browse files
authored
Fix context-engine compaction ownership for Codex sessions (#91590)
* fix(agents): keep context-engine compaction primary * fix(codex): request native compaction after context engines * test: cover 90496 compaction and reset edge cases * fix(codex): guard secondary native compaction binding * fix(codex): keep native compaction hint internal * fix(codex): wait for active native turns before resume
1 parent 6c045c5 commit a8d33f2

14 files changed

Lines changed: 1423 additions & 84 deletions

File tree

extensions/codex/harness.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
*/
44
import type {
55
AgentHarness,
6+
AgentHarnessCompactParams,
7+
AgentHarnessCompactResult,
68
ContextEngineHostCapability,
79
} from "openclaw/plugin-sdk/agent-harness-runtime";
810
import type {
@@ -25,6 +27,12 @@ const CODEX_APP_SERVER_CONTEXT_ENGINE_HOST_CAPABILITIES = [
2527
/** Public model-listing types exposed for Codex app-server catalog callers. */
2628
export type { CodexAppServerListModelsOptions, CodexAppServerModel, CodexAppServerModelListResult };
2729

30+
type CodexAppServerAgentHarness = AgentHarness & {
31+
compactAfterContextEngine?(
32+
params: AgentHarnessCompactParams,
33+
): Promise<AgentHarnessCompactResult | undefined>;
34+
};
35+
2836
/**
2937
* Creates the Codex app-server harness used for attempts, side questions,
3038
* compaction, reset, and disposal.
@@ -41,7 +49,7 @@ export function createCodexAppServerAgentHarness(options?: {
4149
id.trim().toLowerCase(),
4250
),
4351
);
44-
return {
52+
const harness: CodexAppServerAgentHarness = {
4553
id: options?.id ?? "codex",
4654
label: options?.label ?? "Codex agent harness",
4755
contextEngineHostCapabilities: CODEX_APP_SERVER_CONTEXT_ENGINE_HOST_CAPABILITIES,
@@ -80,6 +88,13 @@ export function createCodexAppServerAgentHarness(options?: {
8088
pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
8189
});
8290
},
91+
compactAfterContextEngine: async (params) => {
92+
const { maybeCompactCodexAppServerSession } = await import("./src/app-server/compact.js");
93+
return maybeCompactCodexAppServerSession(params, {
94+
pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
95+
allowNonManualNativeRequest: true,
96+
});
97+
},
8398
reset: async (params) => {
8499
if (params.sessionFile) {
85100
const { clearCodexAppServerBinding } = await import("./src/app-server/session-binding.js");
@@ -92,4 +107,5 @@ export function createCodexAppServerAgentHarness(options?: {
92107
await clearSharedCodexAppServerClientAndWait();
93108
},
94109
};
110+
return harness;
95111
}

0 commit comments

Comments
 (0)