fix(codex): keep native effort config canonical

This commit is contained in:
Dallin Romney
2026-08-20 20:38:19 -07:00
parent 39e800e8be
commit e5abc7b7ee
2 changed files with 19 additions and 33 deletions
@@ -1,6 +1,5 @@
import type { EmbeddedRunAttemptParamsV2 as EmbeddedRunAttemptParams } from "openclaw/plugin-sdk/agent-harness-runtime";
import {
readCodexSupportedReasoningEfforts,
resolveCodexAppServerReasoningEffort,
type CodexReasoningEffort,
} from "./reasoning-effort.js";
@@ -148,15 +147,3 @@ export function resolveReasoningEffort(
supportedReasoningEfforts,
});
}
/** Resolve effort from the selected catalog row carried by an attempt. */
export function resolveAttemptReasoningEffort(
params: EmbeddedRunAttemptParams,
modelId: string,
): CodexReasoningEffort | null {
return resolveReasoningEffort(
params.thinkLevel,
modelId,
readCodexSupportedReasoningEfforts(params.model?.compat),
);
}
@@ -206,22 +206,20 @@ export function buildThreadStartParams(
personality: CODEX_NATIVE_PERSONALITY_NONE,
serviceName: "OpenClaw",
...(ringZeroActive ? { baseInstructions: CODEX_RING_ZERO_BASE_INSTRUCTIONS } : {}),
config: {
...buildCodexRuntimeThreadConfigForRun(params, options.config, {
nativeCodeModeEnabled: options.nativeCodeModeEnabled,
nativeProviderWebSearchSupport: options.nativeProviderWebSearchSupport,
nativeCodeModeOnlyEnabled: options.nativeCodeModeOnlyEnabled,
directOnlyToolNamespaces: resolveDirectOnlyToolNamespaces(options.dynamicTools),
webSearchAllowed: options.webSearchAllowed,
appServer: options.appServer,
hostSystemAgentActive: options.hostSystemAgentActive,
restrictedToolSurfaceInheritedMcpServerNames:
options.restrictedToolSurfaceInheritedMcpServerNames,
shellEnvironment: options.shellEnvironment,
disableLoginShell: options.disableLoginShell,
}),
...(options.reasoningEffort && { model_reasoning_effort: options.reasoningEffort }),
},
config: buildCodexRuntimeThreadConfigForRun(params, options.config, {
nativeCodeModeEnabled: options.nativeCodeModeEnabled,
nativeProviderWebSearchSupport: options.nativeProviderWebSearchSupport,
nativeCodeModeOnlyEnabled: options.nativeCodeModeOnlyEnabled,
directOnlyToolNamespaces: resolveDirectOnlyToolNamespaces(options.dynamicTools),
webSearchAllowed: options.webSearchAllowed,
appServer: options.appServer,
hostSystemAgentActive: options.hostSystemAgentActive,
restrictedToolSurfaceInheritedMcpServerNames:
options.restrictedToolSurfaceInheritedMcpServerNames,
shellEnvironment: options.shellEnvironment,
disableLoginShell: options.disableLoginShell,
reasoningEffort: options.reasoningEffort,
}),
...resolveCodexThreadEnvironmentSelection(options),
developerInstructions:
options.developerInstructions ??
@@ -256,6 +254,7 @@ export function buildThreadResumeParams(
restrictedToolSurfaceInheritedMcpServerNames?: readonly string[];
shellEnvironment?: Readonly<Record<string, string>>;
disableLoginShell?: boolean;
reasoningEffort?: string | null;
preserveNativeModel?: boolean;
},
): CodexThreadResumeParams {
@@ -482,6 +481,7 @@ export function buildCodexRuntimeThreadConfigForRun(
params.authoredContextTokenCap === undefined
? undefined
: { model_context_window: params.authoredContextTokenCap },
options.reasoningEffort ? { model_reasoning_effort: options.reasoningEffort } : undefined,
) ?? baseConfig;
const contextConfig =
params.bootstrapContextMode !== "lightweight"
@@ -719,12 +719,11 @@ function hasNonEmptyJsonValue(value: JsonValue): boolean {
return true;
}
export function resolveCodexThreadApprovalsReviewer(
export const resolveCodexThreadApprovalsReviewer = (
appServer: CodexAppServerRuntimeOptions,
config?: JsonObject,
): CodexAppServerRuntimeOptions["approvalsReviewer"] {
return config?.approvals_reviewer === "user" ? "user" : appServer.approvalsReviewer;
}
): CodexAppServerRuntimeOptions["approvalsReviewer"] =>
config?.approvals_reviewer === "user" ? "user" : appServer.approvalsReviewer;
export function codexThreadSandboxOrPermissions(
appServer: Pick<CodexAppServerRuntimeOptions, "networkProxy" | "sandbox">,