Skip to content

Commit 37cf0c6

Browse files
authored
improve: reduce GPT-5.6 coding harness overhead (#114574)
* improve: reduce GPT-5.6 coding harness overhead * refactor: extract runtime parity timing helpers * fix(qa): verify native apply-patch runtime parity * fix(qa): use mock patch execution evidence * fix(qa): preserve workspace templates in full syncs * fix(qa): make rejected patch fixtures deterministic * fix(qa): prove apply-patch workspace containment * fix(qa): expose runtime prompt-cache usage * fix(codex): confine forced private QA patch turns * fix(qa): verify native patch execution and sandbox precedence * fix(qa): execute native patches and prove disk mutation * fix(codex): avoid duplicate native patch registration * perf(agents): keep code mode catalog guidance compact * fix(qa): make native Codex patch evidence deterministic * fix(qa): recognize native sandbox denial errors * fix(qa): advertise native Codex mock model capabilities * fix(qa): seed native Codex mock model catalog at startup * fix(qa): recognize native Codex patch denial results * fix(ci): repair Codex harness parity checks * fix(qa): distinguish unknown prompt-cache measurements * fix(qa): accept native Codex project patch denials * fix(ci): isolate runtime parity report contracts * fix(codex): eliminate native runtime transport overhead * fix(qa): consume runtime parity report contract * fix(qa): compare matched runtime timing captures * fix(qa): type native response delta context * fix(qa): satisfy native codex websocket lint
1 parent 6bc06ab commit 37cf0c6

48 files changed

Lines changed: 3536 additions & 321 deletions

Some content is hidden

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

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ docs/internal/
109109
tmp/
110110
IDENTITY.md
111111
USER.md
112+
# Keep packaged workspace templates visible to Git-aware remote syncs.
113+
!docs/reference/templates/IDENTITY.md
114+
!docs/reference/templates/USER.md
112115
# Exception: oc-path real-world test fixtures need to be tracked even
113116
# though the bare names match the local-untracked rule above.
114117
!extensions/oc-path/src/oc-path/tests/fixtures/real/IDENTITY.md

‎extensions/codex/src/app-server/config-runtime.ts‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import {
5858
readNumberEnv,
5959
resolveArgs,
6060
} from "./config-utils.js";
61+
import { isForcedPrivateQaCodexRuntime } from "./dynamic-tool-profile.js";
6162
import type { CodexSandboxPolicy } from "./protocol.js";
6263

6364
export function resolveCodexAppServerRuntimeOptions(
@@ -190,11 +191,17 @@ export function resolveCodexAppServerRuntimeOptions(
190191
? normalizedPolicyMode
191192
: (explicitPolicyMode ?? normalizedPolicyMode ?? defaultPolicy?.mode ?? "yolo");
192193
const serviceTier = normalizeCodexServiceTier(config.serviceTier);
193-
const resolvedSandbox =
194+
const configuredRuntimeSandbox =
194195
forcedPolicy?.sandbox ??
195196
configuredSandbox ??
196197
defaultPolicy?.sandbox ??
197198
(policyMode === "guardian" ? "workspace-write" : "danger-full-access");
199+
// Private QA may bound production yolo, but must never widen a configured
200+
// read-only sandbox or override the ordinary policy precedence.
201+
const resolvedSandbox =
202+
isForcedPrivateQaCodexRuntime(env) && configuredRuntimeSandbox === "danger-full-access"
203+
? "workspace-write"
204+
: configuredRuntimeSandbox;
198205
if (transport === "websocket" && !url) {
199206
throw new Error(
200207
"plugins.entries.codex.config.appServer.url is required when appServer.transport is websocket",
@@ -490,19 +497,23 @@ export function codexAppServerStartOptionsKey(
490497
export function codexSandboxPolicyForTurn(
491498
mode: CodexAppServerSandboxMode,
492499
cwd: string,
500+
env: NodeJS.ProcessEnv = process.env,
493501
): CodexSandboxPolicy {
494502
if (mode === "danger-full-access") {
495503
return { type: "dangerFullAccess" };
496504
}
497505
if (mode === "read-only") {
498506
return { type: "readOnly", networkAccess: false };
499507
}
508+
// Codex includes /tmp and TMPDIR in workspace-write by default. Private QA
509+
// workspaces live there, so retaining either root defeats sibling containment.
510+
const excludePrivateQaTempRoots = isForcedPrivateQaCodexRuntime(env);
500511
return {
501512
type: "workspaceWrite",
502513
writableRoots: [cwd],
503514
networkAccess: false,
504-
excludeTmpdirEnvVar: false,
505-
excludeSlashTmp: false,
515+
excludeTmpdirEnvVar: excludePrivateQaTempRoots,
516+
excludeSlashTmp: excludePrivateQaTempRoots,
506517
};
507518
}
508519

‎extensions/codex/src/app-server/config.test.ts‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { describe, expect, it, vi } from "vitest";
77
import {
88
canUseCodexModelBackedApprovalsReviewerForModel,
99
codexAppServerStartOptionsKey,
10+
codexSandboxPolicyForTurn,
1011
readCodexPluginConfig,
1112
resolveCodexAppServerRuntimeOptions,
1213
resolveCodexAppServerStartOptionsForAgent,
@@ -549,6 +550,91 @@ describe("Codex app-server config", () => {
549550
});
550551
});
551552

553+
it("confines only explicitly forced private-QA Codex runtime to workspace writes", () => {
554+
const privateQaCodexEnv = {
555+
OPENCLAW_BUILD_PRIVATE_QA: "1",
556+
OPENCLAW_QA_FORCE_RUNTIME: "codex",
557+
};
558+
const runtime = resolveRuntimeForTest({
559+
pluginConfig: {
560+
appServer: {
561+
mode: "yolo",
562+
approvalPolicy: "never",
563+
sandbox: "danger-full-access",
564+
},
565+
},
566+
env: privateQaCodexEnv,
567+
});
568+
569+
expectRuntimePolicy(runtime, {
570+
approvalPolicy: "never",
571+
sandbox: "workspace-write",
572+
approvalsReviewer: "user",
573+
});
574+
expect(codexSandboxPolicyForTurn(runtime.sandbox, "/qa/workspace", privateQaCodexEnv)).toEqual({
575+
type: "workspaceWrite",
576+
writableRoots: ["/qa/workspace"],
577+
networkAccess: false,
578+
excludeTmpdirEnvVar: true,
579+
excludeSlashTmp: true,
580+
});
581+
});
582+
583+
it("preserves an explicitly read-only sandbox for forced private-QA Codex runtime", () => {
584+
const privateQaCodexEnv = {
585+
OPENCLAW_BUILD_PRIVATE_QA: "1",
586+
OPENCLAW_QA_FORCE_RUNTIME: "codex",
587+
};
588+
const runtime = resolveRuntimeForTest({
589+
pluginConfig: {
590+
appServer: {
591+
mode: "yolo",
592+
approvalPolicy: "never",
593+
sandbox: "read-only",
594+
},
595+
},
596+
env: privateQaCodexEnv,
597+
});
598+
599+
expectRuntimePolicy(runtime, {
600+
approvalPolicy: "never",
601+
sandbox: "read-only",
602+
approvalsReviewer: "user",
603+
});
604+
expect(codexSandboxPolicyForTurn(runtime.sandbox, "/qa/workspace", privateQaCodexEnv)).toEqual({
605+
type: "readOnly",
606+
networkAccess: false,
607+
});
608+
});
609+
610+
it.each([
611+
{ label: "ordinary production", env: {} },
612+
{ label: "private build without a forced runtime", env: { OPENCLAW_BUILD_PRIVATE_QA: "1" } },
613+
{
614+
label: "forced runtime without a private build",
615+
env: { OPENCLAW_QA_FORCE_RUNTIME: "codex" },
616+
},
617+
{
618+
label: "forced private-QA OpenClaw runtime",
619+
env: { OPENCLAW_BUILD_PRIVATE_QA: "1", OPENCLAW_QA_FORCE_RUNTIME: "openclaw" },
620+
},
621+
])("preserves production yolo filesystem policy for $label", ({ env }) => {
622+
const runtime = resolveRuntimeForTest({ pluginConfig: {}, env });
623+
624+
expectRuntimePolicy(runtime, {
625+
approvalPolicy: "never",
626+
sandbox: "danger-full-access",
627+
approvalsReviewer: "user",
628+
});
629+
expect(codexSandboxPolicyForTurn("workspace-write", "/qa/workspace", env)).toEqual({
630+
type: "workspaceWrite",
631+
writableRoots: ["/qa/workspace"],
632+
networkAccess: false,
633+
excludeTmpdirEnvVar: false,
634+
excludeSlashTmp: false,
635+
});
636+
});
637+
552638
it("does not change ordinary harness connection defaults when supervision is enabled", () => {
553639
const runtime = resolveRuntimeForTest({
554640
pluginConfig: { supervision: { enabled: true } },

‎extensions/codex/src/app-server/config.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export {
55
} from "./config-contracts.js";
66
export type {
77
CodexAppServerApprovalPolicy,
8-
CodexAppServerConnectionClass,
98
CodexAppServerHomeScope,
109
CodexAppServerRuntimeOptions,
1110
CodexAppServerSandboxMode,

‎extensions/codex/src/app-server/dynamic-tool-build.test.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,15 @@ describe("Codex app-server dynamic tool build", () => {
565565
});
566566

567567
it("exposes app-server-owned tools directly for forced private QA Codex runtime", () => {
568-
const tools = ["read", "write", "get_goal", "image_generate", "message"].map((name) => ({
569-
name,
570-
}));
568+
const tools = [
569+
"read",
570+
"write",
571+
"apply_patch",
572+
"apply-patch",
573+
"get_goal",
574+
"image_generate",
575+
"message",
576+
].map((name) => ({ name }));
571577
const privateQaCodexEnv = {
572578
OPENCLAW_BUILD_PRIVATE_QA: "1",
573579
OPENCLAW_QA_FORCE_RUNTIME: "codex",

‎extensions/codex/src/app-server/dynamic-tool-profile.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
CodexAppServerConnectionClass,
66
CodexDynamicToolsLoading,
77
CodexPluginConfig,
8-
} from "./config.js";
8+
} from "./config-contracts.js";
99

1010
/** Tool names owned by Codex app-server and normally excluded from OpenClaw dynamic tools. */
1111
const CODEX_APP_SERVER_OWNED_DYNAMIC_TOOL_EXCLUDES = [
@@ -142,7 +142,11 @@ function filterCodexDynamicToolsWithOptions<T extends { name: string }>(
142142
for (const name of CODEX_NATIVE_GOAL_TOOL_EXCLUDES) {
143143
excludes.add(name);
144144
}
145-
if (!isForcedPrivateQaCodexRuntime(env)) {
145+
if (isForcedPrivateQaCodexRuntime(env)) {
146+
// Native apply_patch is registered first; advertising a second handler
147+
// makes Codex reject the duplicate before either QA patch can execute.
148+
excludes.add("apply_patch");
149+
} else {
146150
for (const name of CODEX_APP_SERVER_OWNED_DYNAMIC_TOOL_EXCLUDES) {
147151
if (options.preserveOpenClawShell && CODEX_APP_SERVER_OWNED_SHELL_TOOL_EXCLUDES.has(name)) {
148152
continue;

‎extensions/codex/src/app-server/provider-capabilities.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ describe("resolveCodexProviderWebSearchSupport", () => {
156156
const { clientFactory, request } = createClientFactory(false);
157157

158158
await expect(resolveSupport(clientFactory, " OpenAI ")).resolves.toBe("supported");
159+
expect(clientFactory).not.toHaveBeenCalled();
159160
expect(request).not.toHaveBeenCalled();
160161
});
161162

@@ -165,6 +166,16 @@ describe("resolveCodexProviderWebSearchSupport", () => {
165166
await expect(resolveSupport(clientFactory, "amazon-bedrock")).resolves.toBe("unsupported");
166167
await expect(resolveSupport(clientFactory, "custom-provider")).resolves.toBe("unsupported");
167168
await expect(resolveSupport(clientFactory, "lmstudio")).resolves.toBe("unsupported");
169+
expect(clientFactory).not.toHaveBeenCalled();
168170
expect(request).not.toHaveBeenCalled();
169171
});
172+
173+
it("does not wait for app-server startup when the override proves hosted support", async () => {
174+
const clientFactory = vi.fn(
175+
async () => await new Promise<CodexAppServerClient>(() => {}),
176+
) as unknown as CodexAppServerClientFactory;
177+
178+
await expect(resolveSupport(clientFactory, "openai")).resolves.toBe("supported");
179+
expect(clientFactory).not.toHaveBeenCalled();
180+
});
170181
});

‎extensions/codex/src/app-server/provider-capabilities.ts‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ import {
88
} from "./shared-client.js";
99
import type { CodexNativeWebSearchSupport } from "./web-search.js";
1010

11+
function resolveOverriddenProviderWebSearchSupport(
12+
modelProviderOverride: string | undefined,
13+
): CodexNativeWebSearchSupport | undefined {
14+
const provider = modelProviderOverride?.trim().toLowerCase();
15+
if (!provider) {
16+
return undefined;
17+
}
18+
// The capability RPC describes the configured provider, not a thread
19+
// override. OpenAI's hosted support is known; other overrides stay managed.
20+
return provider === "openai" ? "supported" : "unsupported";
21+
}
22+
1123
async function readConfiguredProviderWebSearchSupport(params: {
1224
client: CodexAppServerClient;
1325
timeoutMs: number;
@@ -30,15 +42,9 @@ export async function resolveCodexProviderWebSearchSupportForClient(params: {
3042
modelProviderOverride: string | undefined;
3143
signal: AbortSignal;
3244
}): Promise<CodexNativeWebSearchSupport> {
33-
const modelProviderOverride = params.modelProviderOverride?.trim().toLowerCase();
34-
if (modelProviderOverride === "openai") {
35-
return "supported";
36-
}
37-
if (modelProviderOverride) {
38-
// Codex's capability RPC only reports the configured provider, not a
39-
// thread-scoped override. Keep managed search for overrides whose hosted
40-
// capability cannot be proven from the configured-provider response.
41-
return "unsupported";
45+
const overrideSupport = resolveOverriddenProviderWebSearchSupport(params.modelProviderOverride);
46+
if (overrideSupport) {
47+
return overrideSupport;
4248
}
4349
try {
4450
return await readConfiguredProviderWebSearchSupport(params);
@@ -57,6 +63,12 @@ export async function resolveCodexProviderWebSearchSupport(params: {
5763
modelProviderOverride: string | undefined;
5864
signal: AbortSignal;
5965
}): Promise<CodexNativeWebSearchSupport> {
66+
const overrideSupport = resolveOverriddenProviderWebSearchSupport(params.modelProviderOverride);
67+
if (overrideSupport) {
68+
// Never serialize the prewarmed app-server startup behind a capability
69+
// probe whose answer is already fixed by the selected thread provider.
70+
return overrideSupport;
71+
}
6072
let client: CodexAppServerClient | undefined;
6173
try {
6274
client = await params.clientFactory({

‎extensions/codex/src/app-server/thread-binding-policy.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CodexAppServerRuntimeOptions } from "./config.js";
1+
import type { CodexAppServerConnectionClass } from "./config-contracts.js";
22
import { normalizeCodexDynamicToolName } from "./dynamic-tool-profile.js";
33
import type { CodexAppServerThreadBinding } from "./session-binding.js";
44
import type {
@@ -7,7 +7,7 @@ import type {
77
} from "./thread-lifecycle-types.js";
88

99
export function shouldRotateCodexAppServerBindingForRuntime(params: {
10-
connectionClass: CodexAppServerRuntimeOptions["connectionClass"];
10+
connectionClass: CodexAppServerConnectionClass;
1111
current?: string;
1212
binding?: string;
1313
}): boolean {

‎extensions/codex/src/app-server/thread-lifecycle.test.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,44 @@ describe("Codex app-server native code mode config", () => {
11051105
});
11061106

11071107
describe("Codex app-server turn input image sanitizing", () => {
1108+
it("excludes implicit temporary writable roots from forced private-QA Codex turns", () => {
1109+
vi.stubEnv("OPENCLAW_BUILD_PRIVATE_QA", "1");
1110+
vi.stubEnv("OPENCLAW_QA_FORCE_RUNTIME", "codex");
1111+
try {
1112+
const request = buildTurnStartParams(createAttemptParams({ provider: "openai" }), {
1113+
threadId: "thread-1",
1114+
cwd: "/tmp/qa/workspace",
1115+
appServer: createAppServerOptions() as never,
1116+
});
1117+
1118+
expect(request.sandboxPolicy).toEqual({
1119+
type: "workspaceWrite",
1120+
writableRoots: ["/tmp/qa/workspace"],
1121+
networkAccess: false,
1122+
excludeTmpdirEnvVar: true,
1123+
excludeSlashTmp: true,
1124+
});
1125+
} finally {
1126+
vi.unstubAllEnvs();
1127+
}
1128+
});
1129+
1130+
it("preserves implicit temporary writable roots for ordinary Codex turns", () => {
1131+
const request = buildTurnStartParams(createAttemptParams({ provider: "openai" }), {
1132+
threadId: "thread-1",
1133+
cwd: "/tmp/qa/workspace",
1134+
appServer: createAppServerOptions() as never,
1135+
});
1136+
1137+
expect(request.sandboxPolicy).toEqual({
1138+
type: "workspaceWrite",
1139+
writableRoots: ["/tmp/qa/workspace"],
1140+
networkAccess: false,
1141+
excludeTmpdirEnvVar: false,
1142+
excludeSlashTmp: false,
1143+
});
1144+
});
1145+
11081146
it("uses an explicit turn sandbox policy override when provided", () => {
11091147
const request = buildTurnStartParams(createAttemptParams({ provider: "openai" }), {
11101148
threadId: "thread-1",

0 commit comments

Comments
 (0)