feat(codex): declare gpt-5.6 context window for Claude Code takeover

- Update Codex OAuth presets to the gpt-5.6 family (haiku -> gpt-5.6-luna)
  and bump the custom Codex template default model
- Inject CLAUDE_CODE_MAX_CONTEXT_TOKENS / CLAUDE_CODE_AUTO_COMPACT_WINDOW
  (372000, the ChatGPT Codex catalog window with a ~353K effective budget,
  openai/codex#31860) into effective live settings so Claude Code stops
  assuming a 200K window and compacts before the upstream rejects the prompt
- Gate the injected defaults on every configured model being gpt-5.6*:
  gpt-5.5's upstream catalog oscillates between 272K and 372K and must not
  inherit them; explicit user values always win
- Strip the injected values on switch-away backfill (mirror-inverse of the
  injection conditions) so program defaults never harden into per-provider
  explicit values, and keep both keys out of the shared common-config snippet
This commit is contained in:
Jason
2026-07-12 23:20:55 +08:00
parent f15184edb0
commit 5c39dfbfbe
6 changed files with 458 additions and 6 deletions
+13
View File
@@ -722,6 +722,8 @@ mod tests {
"ANTHROPIC_BASE_URL": "https://example.com",
"ANTHROPIC_MODEL": "claude-x",
"CLAUDE_CODE_SUBAGENT_MODEL": "gpt-5.4-mini",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "400000",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "400000",
// 可共享、非机密配置(复数 _TOKENS 不应被误剥)
"ENABLE_TOOL_SEARCH": "true",
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "8192"
@@ -767,6 +769,12 @@ mod tests {
assert!(env
.and_then(|e| e.get("CLAUDE_CODE_SUBAGENT_MODEL"))
.is_none());
assert!(env
.and_then(|e| e.get("CLAUDE_CODE_MAX_CONTEXT_TOKENS"))
.is_none());
assert!(env
.and_then(|e| e.get("CLAUDE_CODE_AUTO_COMPACT_WINDOW"))
.is_none());
// 可共享的非机密配置必须保留(含复数 _TOKENS 不被误剥)
assert_eq!(
@@ -2935,6 +2943,11 @@ impl ProviderService {
"ANTHROPIC_DEFAULT_FABLE_MODEL",
"ANTHROPIC_DEFAULT_FABLE_MODEL_NAME",
"CLAUDE_CODE_SUBAGENT_MODEL",
// Context limits follow the actual upstream model. Sharing these
// across providers can cap GPT/Kimi to the wrong window and make
// Claude Code compact too early or miss the upstream limit.
"CLAUDE_CODE_MAX_CONTEXT_TOKENS",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW",
"ANTHROPIC_BASE_URL",
];