@@ -13,7 +13,7 @@ import { CODEX_REASONING_LEVELS, codexEffortRank, configuredReasoningEfforts, mo
1313import { getModelMetadata , getModelMetadataCaseInsensitive , listModelMetadata , resolveMetadataProvider } from "../../generated/model-metadata" ;
1414import { enrichProviderFromRegistry , shouldCaseFoldMetadataModelId } from "../../providers/derive" ;
1515import { getProviderRegistryEntry } from "../../providers/registry" ;
16- import { applyProviderContextCap , providerContextCap } from "../../providers/context-cap" ;
16+ import { applyProviderContextCap , clampAutoCompactTokenLimit , providerContextCap } from "../../providers/context-cap" ;
1717import { routedSlug , slugEquals , slugsEquivalent } from "../../providers/slug-codec" ;
1818import { identifyRoutedModel } from "../../adapters/identity" ;
1919import { filterCursorConfiguredModelsByLiveDiscovery } from "../../adapters/cursor/discovery" ;
@@ -134,11 +134,23 @@ export const NATIVE_GPT56_CONTEXT_WINDOW = 922_000;
134134 */
135135export const NATIVE_GPT56_MAX_INPUT_TOKENS = 922_000 ;
136136
137- export const NATIVE_OPENAI_CONTEXT_OVERRIDES : Record < string , { contextWindow ?: number ; maxContextWindow ?: number ; maxInputTokens ?: number } > = {
137+ export interface NativeOpenAiContextOverride {
138+ contextWindow ?: number ;
139+ maxContextWindow ?: number ;
140+ /** Measured hard input ceiling. This is admission authority, not compaction policy. */
141+ maxInputTokens ?: number ;
142+ /** Model-specific soft budget exposed to Codex as auto_compact_token_limit. */
143+ autoCompactTokenLimit ?: number ;
144+ }
145+
146+ export const NATIVE_OPENAI_CONTEXT_OVERRIDES : Record < string , NativeOpenAiContextOverride > = {
138147 "gpt-5.5" : { contextWindow : 272_000 , maxContextWindow : 272_000 } ,
139148 "gpt-5.4" : { contextWindow : 1_000_000 , maxContextWindow : 1_000_000 } ,
140149 "gpt-5.3-codex-spark" : { contextWindow : 100_000 , maxContextWindow : 100_000 } ,
141- "gpt-5.6-sol" : { contextWindow : NATIVE_GPT56_CONTEXT_WINDOW , maxContextWindow : NATIVE_GPT56_CONTEXT_WINDOW , maxInputTokens : NATIVE_GPT56_MAX_INPUT_TOKENS } ,
150+ // Sol keeps the measured 922k hard input ceiling but compacts at the explicit 900k soft budget
151+ // used by long-running ChatGPT/Codex sessions. Terra, Luna, and Daybreak retain the family
152+ // fallback (922k) until an operator supplies their independent per-model soft budgets.
153+ "gpt-5.6-sol" : { contextWindow : NATIVE_GPT56_CONTEXT_WINDOW , maxContextWindow : NATIVE_GPT56_CONTEXT_WINDOW , maxInputTokens : NATIVE_GPT56_MAX_INPUT_TOKENS , autoCompactTokenLimit : 900_000 } ,
142154 "gpt-5.6-terra" : { contextWindow : NATIVE_GPT56_CONTEXT_WINDOW , maxContextWindow : NATIVE_GPT56_CONTEXT_WINDOW , maxInputTokens : NATIVE_GPT56_MAX_INPUT_TOKENS } ,
143155 "gpt-5.6-luna" : { contextWindow : NATIVE_GPT56_CONTEXT_WINDOW , maxContextWindow : NATIVE_GPT56_CONTEXT_WINDOW , maxInputTokens : NATIVE_GPT56_MAX_INPUT_TOKENS } ,
144156 // Daybreak Blue borrows Sol's capability metadata and rides the same family contract.
@@ -255,6 +267,30 @@ export function nativeOpenAiMaxInputTokens(slug: string, limits?: NativeContextL
255267 return window === undefined ? narrowed : Math . min ( narrowed , window ) ;
256268}
257269
270+ /** Effective native soft budget. User configuration may lower, but never raise, the model default. */
271+ export function nativeOpenAiAutoCompactTokenLimit (
272+ slug : string ,
273+ limits ?: NativeContextLimitsInput ,
274+ configuredLimit ?: number ,
275+ ) : number | undefined {
276+ const contextWindow = nativeOpenAiContextWindow ( slug , limits ) ;
277+ if ( contextWindow === undefined ) return undefined ;
278+ const nativeDefault = NATIVE_OPENAI_CONTEXT_OVERRIDES [ slug ] ?. autoCompactTokenLimit ;
279+ const positiveConfigured = typeof configuredLimit === "number" && configuredLimit > 0
280+ ? configuredLimit
281+ : undefined ;
282+ const softLimit = nativeDefault === undefined
283+ ? positiveConfigured
284+ : positiveConfigured === undefined
285+ ? nativeDefault
286+ : Math . min ( nativeDefault , positiveConfigured ) ;
287+ return clampAutoCompactTokenLimit (
288+ contextWindow ,
289+ nativeOpenAiMaxInputTokens ( slug , limits ) ,
290+ softLimit ,
291+ ) ;
292+ }
293+
258294export function nativeInputModalities ( slug : string ) : string [ ] {
259295 const upstream = PINNED_NATIVE_CAPABILITY_ENTRIES . get ( slug ) ;
260296 if ( Array . isArray ( upstream ?. input_modalities ) && upstream ! . input_modalities ! . length > 0 ) {
@@ -365,7 +401,9 @@ export function desktopVisibleNativeSlugs(
365401 ] ) ;
366402}
367403
368- export function nativeModelRows ( config : Pick < OcxConfig , "disabledModels" | "combos" | "providerContextCaps" | "providers" > ) : Array < { slug : string ; disabled : boolean ; contextWindow ?: number ; maxInputTokens ?: number } > {
404+ export function nativeModelRows (
405+ config : Pick < OcxConfig , "disabledModels" | "combos" | "providerContextCaps" | "providers" > ,
406+ ) : Array < { slug : string ; disabled : boolean ; contextWindow ?: number ; maxInputTokens ?: number ; autoCompactTokenLimit ?: number } > {
369407 const disabled = disabledNativeSlugs ( config ) ;
370408 const shadowed = configuredNativeAliasSlugs ( config ) ;
371409 // Both user levers, not just the cap: a per-model window set from the dashboard has to show
@@ -374,11 +412,17 @@ export function nativeModelRows(config: Pick<OcxConfig, "disabledModels" | "comb
374412 return NATIVE_OPENAI_MODELS . filter ( slug => ! shadowed . has ( slug ) ) . map ( slug => {
375413 const contextWindow = nativeOpenAiContextWindow ( slug , limits ) ;
376414 const maxInputTokens = nativeOpenAiMaxInputTokens ( slug , limits ) ;
415+ const autoCompactTokenLimit = nativeOpenAiAutoCompactTokenLimit (
416+ slug ,
417+ limits ,
418+ config . providers ?. [ OPENAI_CODEX_PROVIDER_ID ] ?. modelAutoCompactTokenLimits ?. [ slug ] ,
419+ ) ;
377420 return {
378421 slug,
379422 disabled : disabled . has ( slug ) ,
380423 ...( contextWindow !== undefined ? { contextWindow } : { } ) ,
381424 ...( maxInputTokens !== undefined ? { maxInputTokens } : { } ) ,
425+ ...( autoCompactTokenLimit !== undefined ? { autoCompactTokenLimit } : { } ) ,
382426 } ;
383427 } ) ;
384428}
0 commit comments