
























@@ -73,6 +73,11 @@ export const CODEX_CODE_MODE_THREAD_CONFIG: JsonObject = {
7373"features.code_mode_only": true,
7474};
757576+export const CODEX_CODE_MODE_DISABLED_THREAD_CONFIG: JsonObject = {
77+"features.code_mode": false,
78+"features.code_mode_only": false,
79+};
80+7681const CODEX_LIGHTWEIGHT_CONTEXT_THREAD_CONFIG: JsonObject = {
7782project_doc_max_bytes: 0,
7883};
@@ -87,6 +92,7 @@ export async function startOrResumeThread(params: {
8792developerInstructions?: string;
8893config?: JsonObject;
8994finalConfigPatch?: JsonObject;
95+nativeCodeModeEnabled?: boolean;
9096mcpServersFingerprint?: string;
9197mcpServersFingerprintEvaluated?: boolean;
9298pluginThreadConfig?: CodexPluginThreadConfigProvider;
@@ -246,6 +252,7 @@ export async function startOrResumeThread(params: {
246252appServer: params.appServer,
247253developerInstructions: params.developerInstructions,
248254config: resumeConfig,
255+nativeCodeModeEnabled: params.nativeCodeModeEnabled,
249256}),
250257),
251258);
@@ -341,6 +348,7 @@ export async function startOrResumeThread(params: {
341348appServer: params.appServer,
342349developerInstructions: params.developerInstructions,
343350 config,
351+nativeCodeModeEnabled: params.nativeCodeModeEnabled,
344352}),
345353),
346354);
@@ -539,6 +547,7 @@ export function buildThreadStartParams(
539547appServer: CodexAppServerRuntimeOptions;
540548developerInstructions?: string;
541549config?: JsonObject;
550+nativeCodeModeEnabled?: boolean;
542551},
543552): CodexThreadStartParams {
544553const modelProvider = resolveCodexAppServerModelProvider({
@@ -557,7 +566,9 @@ export function buildThreadStartParams(
557566sandbox: options.appServer.sandbox,
558567 ...(options.appServer.serviceTier ? { serviceTier: options.appServer.serviceTier } : {}),
559568serviceName: "OpenClaw",
560-config: buildCodexRuntimeThreadConfigForRun(params, options.config),
569+config: buildCodexRuntimeThreadConfigForRun(params, options.config, {
570+nativeCodeModeEnabled: options.nativeCodeModeEnabled,
571+}),
561572developerInstructions: options.developerInstructions ?? buildDeveloperInstructions(params),
562573dynamicTools: options.dynamicTools,
563574experimentalRawEvents: true,
@@ -573,6 +584,7 @@ export function buildThreadResumeParams(
573584appServer: CodexAppServerRuntimeOptions;
574585developerInstructions?: string;
575586config?: JsonObject;
587+nativeCodeModeEnabled?: boolean;
576588},
577589): CodexThreadResumeParams {
578590const modelProvider = resolveCodexAppServerModelProvider({
@@ -590,24 +602,34 @@ export function buildThreadResumeParams(
590602approvalsReviewer: options.appServer.approvalsReviewer,
591603sandbox: options.appServer.sandbox,
592604 ...(options.appServer.serviceTier ? { serviceTier: options.appServer.serviceTier } : {}),
593-config: buildCodexRuntimeThreadConfigForRun(params, options.config),
605+config: buildCodexRuntimeThreadConfigForRun(params, options.config, {
606+nativeCodeModeEnabled: options.nativeCodeModeEnabled,
607+}),
594608developerInstructions: options.developerInstructions ?? buildDeveloperInstructions(params),
595609persistExtendedHistory: true,
596610};
597611}
598612599-export function buildCodexRuntimeThreadConfig(config: JsonObject | undefined): JsonObject {
600-const runtimeConfig = mergeCodexThreadConfigs(config, CODEX_CODE_MODE_THREAD_CONFIG) ?? {
601- ...CODEX_CODE_MODE_THREAD_CONFIG,
613+export function buildCodexRuntimeThreadConfig(
614+config: JsonObject | undefined,
615+options: { nativeCodeModeEnabled?: boolean } = {},
616+): JsonObject {
617+const codeModeConfig =
618+options.nativeCodeModeEnabled === false
619+ ? CODEX_CODE_MODE_DISABLED_THREAD_CONFIG
620+ : CODEX_CODE_MODE_THREAD_CONFIG;
621+const runtimeConfig = mergeCodexThreadConfigs(config, codeModeConfig) ?? {
622+ ...codeModeConfig,
602623};
603624return runtimeConfig;
604625}
605626606627function buildCodexRuntimeThreadConfigForRun(
607628params: EmbeddedRunAttemptParams,
608629config: JsonObject | undefined,
630+options: { nativeCodeModeEnabled?: boolean } = {},
609631): JsonObject {
610-const runtimeConfig = buildCodexRuntimeThreadConfig(config);
632+const runtimeConfig = buildCodexRuntimeThreadConfig(config, options);
611633if (params.bootstrapContextMode !== "lightweight") {
612634return runtimeConfig;
613635}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。