@@ -263,6 +263,9 @@ export function applyFastSessionDefaults(
263263 } ;
264264}
265265
266+ /**
267+ * Resolves reasoning settings by layering transformed config with body/provider overrides.
268+ */
266269function resolveReasoningConfig (
267270 modelName : string ,
268271 modelConfig : ConfigOptions ,
@@ -283,6 +286,9 @@ function resolveReasoningConfig(
283286 return getReasoningConfig ( modelName , mergedConfig ) ;
284287}
285288
289+ /**
290+ * Picks effective text verbosity with body/provider values taking precedence.
291+ */
286292function resolveTextVerbosity (
287293 modelConfig : ConfigOptions ,
288294 body : RequestBody ,
@@ -296,6 +302,9 @@ function resolveTextVerbosity(
296302 ) ;
297303}
298304
305+ /**
306+ * Resolves include fields and always preserves encrypted reasoning continuity payloads.
307+ */
299308function resolveInclude ( modelConfig : ConfigOptions , body : RequestBody ) : string [ ] {
300309 const providerOpenAI = body . providerOptions ?. openai ;
301310 const base =
@@ -310,6 +319,9 @@ function resolveInclude(modelConfig: ConfigOptions, body: RequestBody): string[]
310319 return include ;
311320}
312321
322+ /**
323+ * Parses a collaboration mode token from env/config text.
324+ */
313325function parseCollaborationMode ( value : string | undefined ) : CollaborationMode | undefined {
314326 if ( ! value ) return undefined ;
315327 const normalized = value . trim ( ) . toLowerCase ( ) ;
@@ -318,6 +330,9 @@ function parseCollaborationMode(value: string | undefined): CollaborationMode |
318330 return undefined ;
319331}
320332
333+ /**
334+ * Extracts plain text from mixed message-content payloads.
335+ */
321336function extractMessageText ( content : unknown ) : string {
322337 if ( typeof content === "string" ) return content ;
323338 if ( ! Array . isArray ( content ) ) return "" ;
@@ -332,6 +347,9 @@ function extractMessageText(content: unknown): string {
332347 . join ( "\n" ) ;
333348}
334349
350+ /**
351+ * Detects active collaboration mode using explicit env overrides first, then prompt hints.
352+ */
335353function detectCollaborationMode ( body : RequestBody ) : CollaborationMode {
336354 const envMode =
337355 parseCollaborationMode ( process . env . CODEX_COLLABORATION_MODE ) ??
@@ -362,6 +380,9 @@ function detectCollaborationMode(body: RequestBody): CollaborationMode {
362380 return "unknown" ;
363381}
364382
383+ /**
384+ * Removes tools that are only valid in plan mode when the request is not in plan mode.
385+ */
365386function sanitizePlanOnlyTools ( tools : unknown , mode : CollaborationMode ) : unknown {
366387 if ( ! Array . isArray ( tools ) || mode === "plan" ) return tools ;
367388
@@ -385,6 +406,9 @@ function sanitizePlanOnlyTools(tools: unknown, mode: CollaborationMode): unknown
385406 return filtered ;
386407}
387408
409+ /**
410+ * Collects runtime tool names from either direct tool entries or function-wrapped definitions.
411+ */
388412function extractRuntimeToolNames ( tools : unknown ) : string [ ] {
389413 if ( ! Array . isArray ( tools ) ) return [ ] ;
390414
@@ -516,6 +540,10 @@ export function getReasoningConfig(
516540 // for better coding assistance unless user explicitly requests "none".
517541 // - Canonical GPT-5 Codex defaults to high in stable Codex.
518542 // - Legacy GPT-5.3/5.2 Codex aliases default to xhigh for backward compatibility.
543+ // - Legacy lightweight aliases (gpt-5-mini / gpt-5-nano) intentionally keep a
544+ // minimal default based on the original alias, even though normalization maps
545+ // them to gpt-5.4 which supports higher efforts. Explicit xhigh requests are
546+ // still honored below via supportsRequestedXhigh.
519547 const defaultEffort : ReasoningConfig [ "effort" ] = isCodexMini
520548 ? "medium"
521549 : isGpt5Codex
@@ -557,7 +585,7 @@ export function getReasoningConfig(
557585 }
558586
559587 // Normalize "minimal" to "low" for Codex families
560- // Codex CLI presets are low/medium/high (or xhigh for Codex Max / GPT-5.3/5.2 Codex)
588+ // Codex CLI presets are low/medium/high (or xhigh for Codex Max / GPT-5.3/5.2 Codex)
561589 if ( isCodex && effort === "minimal" ) {
562590 effort = "low" ;
563591 }
0 commit comments