@@ -348,7 +348,7 @@ describe("collectCodexRouteWarnings", () => {
348348 expect ( result . cfg . agents ?. list ?. [ 0 ] ?. models ?. [ "openai-codex/gpt-5.4" ] ) . toBeUndefined ( ) ;
349349 } ) ;
350350
351- it ( "warns when Codex app-server command includes inline arguments " , ( ) => {
351+ it ( "warns without executing a custom Codex app-server command" , ( ) => {
352352 const warnings = collectCodexRouteWarnings ( {
353353 plugins : {
354354 entries : {
@@ -371,7 +371,140 @@ describe("collectCodexRouteWarnings", () => {
371371 '- plugins.entries.codex.config.appServer.command: "node C:\\Users\\me\\.openclaw\\npm\\node_modules\\@openai\\codex\\bin\\codex.js" starts with "node" and embeds "C:\\Users\\me\\.openclaw\\npm\\node_modules\\@openai\\codex\\bin\\codex.js". The command field must be only the executable path.' ,
372372 "- Remove the override to use managed Codex startup, or move script/options to plugins.entries.codex.config.appServer.args." ,
373373 ] . join ( "\n" ) ,
374+ [
375+ "- Custom Codex app-server command bypasses OpenClaw's managed exact-version binary." ,
376+ "- plugins.entries.codex.config.appServer.command: Doctor did not execute, inspect, or rewrite this command." ,
377+ "- Remove the override to use managed Codex startup, or verify the custom binary matches the Codex version bundled with this OpenClaw release." ,
378+ ] . join ( "\n" ) ,
379+ ] ) ;
380+ } ) ;
381+
382+ it ( "repairs only redundant native Codex service tiers and is idempotent" , ( ) => {
383+ const command = "node -e process.exit(99)" ;
384+ const original = {
385+ plugins : { entries : { codex : { enabled : true , config : { appServer : { command } } } } } ,
386+ agents : {
387+ defaults : {
388+ params : { temperature : 0.7 } ,
389+ models : {
390+ "openai/gpt-5.6-sol" : {
391+ params : { fastMode : true , serviceTier : "priority" , temperature : 0.2 } ,
392+ agentRuntime : { id : "codex" } ,
393+ } ,
394+ "openai/gpt-5.6-terra" : {
395+ params : { fast_mode : "on" , service_tier : "PRIORITY" } ,
396+ agentRuntime : { id : "codex" } ,
397+ } ,
398+ } ,
399+ } ,
400+ } ,
401+ } ;
402+
403+ const repaired = maybeRepairCodexRoutes ( original ) ;
404+
405+ expect ( repaired . changes ) . toStrictEqual ( [
406+ "Removed redundant agents.defaults.models.openai/gpt-5.6-sol.params.serviceTier; fastMode already selects native priority." ,
407+ "Removed redundant agents.defaults.models.openai/gpt-5.6-terra.params.service_tier; fastMode already selects native priority." ,
374408 ] ) ;
409+ expect ( repaired . cfg . agents ?. defaults ?. models ) . toEqual ( {
410+ "openai/gpt-5.6-sol" : {
411+ params : { fastMode : true , temperature : 0.2 } ,
412+ agentRuntime : { id : "codex" } ,
413+ } ,
414+ "openai/gpt-5.6-terra" : {
415+ params : { fast_mode : "on" } ,
416+ agentRuntime : { id : "codex" } ,
417+ } ,
418+ } ) ;
419+ expect ( repaired . cfg . plugins ?. entries ?. codex ?. config ) . toEqual ( {
420+ appServer : { command } ,
421+ } ) ;
422+ expect ( repaired . warnings . join ( "\n" ) ) . toContain (
423+ "Custom Codex app-server command bypasses OpenClaw's managed exact-version binary." ,
424+ ) ;
425+ expect ( repaired . warnings . join ( "\n" ) ) . toContain ( "agents.defaults.params.temperature" ) ;
426+ expect ( repaired . warnings . join ( "\n" ) ) . toContain (
427+ "agents.defaults.models.openai/gpt-5.6-sol.params.temperature" ,
428+ ) ;
429+ expect ( original . agents . defaults . models [ "openai/gpt-5.6-sol" ] . params ) . toHaveProperty (
430+ "serviceTier" ,
431+ ) ;
432+
433+ const second = maybeRepairCodexRoutes ( repaired . cfg ) ;
434+ expect ( second . cfg ) . toBe ( repaired . cfg ) ;
435+ expect ( second . changes ) . toStrictEqual ( [ ] ) ;
436+ expect ( second . warnings ) . toStrictEqual ( repaired . warnings ) ;
437+ } ) ;
438+
439+ it ( "preserves and reports authored params across effective Codex sources" , ( ) => {
440+ const original = {
441+ agents : {
442+ defaults : {
443+ model : "openai/gpt-5.6-sol" ,
444+ params : { temperature : 0.7 } ,
445+ models : {
446+ "openai/gpt-5.6-sol" : {
447+ params : {
448+ fastMode : true ,
449+ fast_mode : false ,
450+ serviceTier : "priority" ,
451+ temperature : 0.2 ,
452+ } ,
453+ agentRuntime : { id : "codex" } ,
454+ } ,
455+ "openai/gpt-5.6-openclaw" : {
456+ params : { fastMode : true , serviceTier : "priority" } ,
457+ agentRuntime : { id : "openclaw" } ,
458+ } ,
459+ } ,
460+ } ,
461+ entries : {
462+ coder : { params : { topP : 0.8 } } ,
463+ worker : {
464+ models : {
465+ "openai/gpt-5.6-sol" : { agentRuntime : { id : "openclaw" } } ,
466+ } ,
467+ } ,
468+ } ,
469+ } ,
470+ } ;
471+
472+ const result = maybeRepairCodexRoutes ( original ) ;
473+
474+ expect ( result . cfg ) . toBe ( original ) ;
475+ expect ( result . changes ) . toStrictEqual ( [ ] ) ;
476+ expect ( result . warnings . join ( "\n" ) ) . toContain (
477+ "agents.defaults.models.openai/gpt-5.6-sol.params.serviceTier" ,
478+ ) ;
479+ expect ( result . warnings . join ( "\n" ) ) . toContain (
480+ "agents.defaults.models.openai/gpt-5.6-sol.params.temperature" ,
481+ ) ;
482+ expect ( result . warnings . join ( "\n" ) ) . toContain ( "agents.defaults.params.temperature" ) ;
483+ expect ( result . warnings . join ( "\n" ) ) . toContain ( "agents.entries.coder.params.topP" ) ;
484+ expect ( result . warnings . join ( "\n" ) ) . not . toContain ( "gpt-5.6-openclaw.params.serviceTier" ) ;
485+ } ) ;
486+
487+ it ( "canonicalizes and repairs a redundant legacy tier in one pass" , ( ) => {
488+ const result = maybeRepairCodexRoutes ( {
489+ agents : {
490+ defaults : {
491+ models : {
492+ "openai-codex/gpt-5.6-sol" : {
493+ params : { fastMode : true , serviceTier : "priority" } ,
494+ agentRuntime : { id : "codex" } ,
495+ } ,
496+ } ,
497+ } ,
498+ } ,
499+ } ) ;
500+
501+ expect ( result . cfg . agents ?. defaults ?. models ?. [ "openai-codex/gpt-5.6-sol" ] ) . toBeUndefined ( ) ;
502+ expect ( result . cfg . agents ?. defaults ?. models ?. [ "openai/gpt-5.6-sol" ] ?. params ) . toEqual ( {
503+ fastMode : true ,
504+ } ) ;
505+ expect ( result . changes ) . toContain (
506+ "Removed redundant agents.defaults.models.openai/gpt-5.6-sol.params.serviceTier; fastMode already selects native priority." ,
507+ ) ;
375508 } ) ;
376509
377510 it ( "warns when Codex runtime routes are configured while the Codex plugin is disabled" , ( ) => {
0 commit comments