File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -296,18 +296,18 @@ function stripExistingModelProvider(content: string): string {
296296}
297297
298298/**
299- * Drop ROOT-level `model_context_window` / `model_auto_compact_token_limit` overrides (keys before
300- * the first table header). Codex treats these root keys as a global override that wins over the
301- * per-model catalog values, so a stale `model_context_window = 1000000` makes every model (e.g.
302- * gpt-5.5) report a 1M window. Stripping them on (re)injection lets the catalog drive context size .
299+ * Drop ROOT-level `model_context_window` overrides (keys before the first table header). Codex
300+ * treats this root key as a global override that wins over the per-model catalog values, so a stale
301+ * `model_context_window = 1000000` makes every model (e.g. gpt-5.5) report a 1M window. User-owned
302+ * compaction limits do not alter the advertised context window and must survive reinjection .
303303 */
304304export function stripRootContextWindowOverrides ( content : string ) : string {
305305 const lines = content . split ( "\n" ) ;
306306 const firstTable = lines . findIndex ( l => / ^ \s * \[ / . test ( l ) ) ;
307307 return lines
308308 . filter ( ( line , i ) => {
309309 const isRoot = firstTable === - 1 || i < firstTable ;
310- return ! isRoot || ! / ^ \s * m o d e l _ (?: c o n t e x t _ w i n d o w | a u t o _ c o m p a c t _ t o k e n _ l i m i t ) \s * = / . test ( line ) ;
310+ return ! isRoot || ! / ^ \s * m o d e l _ c o n t e x t _ w i n d o w \s * = / . test ( line ) ;
311311 } )
312312 . join ( "\n" ) ;
313313}
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ describe("Codex config injection", () => {
6060 'model_provider = "opencodex"' ,
6161 "model_context_window = 1000000" ,
6262 "model_auto_compact_token_limit = 900000" ,
63+ 'model_auto_compact_token_limit_scope = "total"' ,
6364 'model = "gpt-5.5"' ,
6465 "" ,
6566 "[model_providers.opencodex]" ,
@@ -68,9 +69,10 @@ describe("Codex config injection", () => {
6869 "" ,
6970 ] . join ( "\n" ) ) ;
7071
71- // Root-level overrides (before the first table header) are removed .
72+ // Only the stale root context-window override is removed. Compaction is a user-owned limit .
7273 expect ( cleaned ) . not . toMatch ( / ^ m o d e l _ c o n t e x t _ w i n d o w = 1 0 0 0 0 0 0 $ / m) ;
73- expect ( cleaned ) . not . toMatch ( / ^ m o d e l _ a u t o _ c o m p a c t _ t o k e n _ l i m i t = 9 0 0 0 0 0 $ / m) ;
74+ expect ( cleaned ) . toContain ( "model_auto_compact_token_limit = 900000" ) ;
75+ expect ( cleaned ) . toContain ( 'model_auto_compact_token_limit_scope = "total"' ) ;
7476 // Non-context-window root keys are untouched.
7577 expect ( cleaned ) . toContain ( 'model_provider = "opencodex"' ) ;
7678 expect ( cleaned ) . toContain ( 'model = "gpt-5.5"' ) ;
You can’t perform that action at this time.
0 commit comments