Skip to content

fix(codex): 进程级关闭低额度切 luna 的模型 nudge 弹窗 - #1367

Merged
deepcoldy merged 2 commits into
masterfrom
fix/codex-suppress-rate-limit-model-nudge
Sep 11, 2026
Merged

deepcoldy merged 2 commits into
masterfrom
fix/codex-suppress-rate-limit-model-nudge

Conversation

@DeepColds

Copy link
Copy Markdown
Collaborator

改了什么

Codex CLI 0.151+ 在主额度用量 ≥90%(剩余 <10%,上游常量 RATE_LIMIT_SWITCH_PROMPT_THRESHOLD = 90.0,见 codex-rs/tui/src/chatwidget/rate_limits.rs)时,TUI 会弹出 "Approaching rate limits:Switch to gpt-5.6-luna for lower credit usage?" 选择框,三个选项中第一项 "Switch to gpt-5.6-luna" 是默认选中项,裸回车即确认(同时把模型与 reasoning effort 切到 luna 预设)。

botmux 传统粘贴链路是「bracketed paste 正文 + ~200ms 后补 Enter」。弹窗存在时该 Enter 被弹窗消费,线上观测到两种表现:

  1. 模型被静默切换:Enter 确认了默认项,会话在 luna + 被覆盖的 effort 上继续执行;
  2. submit_unconfirmed:Enter 被模态框吞掉,正文留在 composer 未提交,消息实际未执行。

属于 #1281 记录的「抢 Enter 的弹窗家族」之一(该 issue 已明确列出额度 <10% 切 luna 确认框)。

修复:codex 适配器的两条 TUI 启动形态均在启动参数注入进程级 config 覆盖:

-c notice.hide_rate_limit_model_nudge=true
  • 该键是上游官方配置(config.schema.json 顶层 [notice] 表;等价于在弹窗选一次 "Keep current model (never show again)",上游 edit.rs 持久化到同一键路径),只作用于本次进程,不写用户全局 config.toml;
  • 普通 TUI 分支:消除弹窗本身,粘贴 Enter 不再有模态框可消费;
  • --remote RPC viewer 分支:viewer 自身仍是 TUI、会渲染该弹窗。botmux 虽不向 viewer 注入按键(不可能误确认),但模态框会盖住 pane、干扰屏幕状态检测与 Web 终端人工查看,故与既有的 check_for_update_on_startup=false 同样在 viewer 上关闭;
  • app-server / runner(codex-app 等)是 headless 链路,TUI notice 不会渲染,不加;
  • traex 适配器不动:其传统分支本就没有同类注入,且该 nudge 是 openai codex TUI 的功能。

wrapper 兼容(影响面重点)

src/setup/cli-selection.ts 的 botmux 注入参数白名单 isBotmuxCodexConfigValue 同步加入新值:

  • aiden 网关 1.8.38+ 直接拒收透传的裸 -c,新值若不进白名单会导致经 aiden 的 codex 启动失败(白名单命中后按既有策略剥离,该路径本就无法传递此类覆盖);
  • cjadk 依赖同一白名单把 -c 改写成 --config 透传;
  • ttadk 等裸透传网关原样转发,直接生效。

影响面评估

  • 跨 CLI:仅改动 codex 适配器与 codex wrapper 白名单;白名单是「botmux 注入特征」精确匹配,用户自带的 -c key=val 不受影响;traex 及其余 20+ CLI 不涉及。
  • 跨会话类型:新建会话生效;已存在的旧会话 resume 时也带新参数(参数在每次 buildArgs 时构造)。
  • 行为变化:botmux 管理的 codex 不再弹出低额度切模型提示。额度状态用户仍可在 codex 内 /status、以及 botmux 自身的额度/限流结构化通知中看到;不影响 codex 真正耗尽额度后的报错与 botmux 的额度耗尽交接(quota fallback)链路。
  • 对旧版 codex(不含该配置键的版本):codex 对未知 -c 配置键宽松忽略(与既有注入项同一机制),不会启动失败。

测试验证

  • node_modules/.bin/tsc --noEmit 通过;
  • vitest run test/cli-adapters.test.ts test/cli-selection.test.ts test/write-input.test.ts:669 passed;
  • vitest run codex 相关其余 7 个测试文件(rpc-lifecycle / hook-trust / startup-readiness / read-isolation / effort-wiring / trigger-user-shell-env / cli-usage-limit):143 passed;
  • 实测 codex 0.151.0:[notice] hide_rate_limit_model_nudge=true 配置可被完整加载(正常进入运行阶段),配置路径与官方 config.schema.json 及上游持久化代码一致;
  • 新增测试覆盖:普通 TUI 与 resume 参数位置、--remote viewer 参数位置(位于 thread id 之前)、aiden 剥离、cjadk -c→--config 改写,并更新全部既有 buildArgs 快照。

Refs #1281

🤖 Generated with Claude Code

Codex 0.151+ 在主额度用量 ≥90%(剩余<10%,上游
RATE_LIMIT_SWITCH_PROMPT_THRESHOLD=90.0)时弹出
"Switch to <luna> for lower credit usage?" 选择框,第一项
"Switch to <luna>" 是默认选中项。传统粘贴链路在 bracketed
paste 后补的提交 Enter 会被该弹窗消费:要么确认切换(模型与
reasoning effort 被静默降级),要么 Enter 被吞导致消息未执行
(submit_unconfirmed),即 issue #1281 记录的弹窗家族之一。

- codex 适配器两条 TUI 启动形态(普通 TUI 与 --remote RPC
  viewer)均注入 -c notice.hide_rate_limit_model_nudge=true,
  等价于弹窗的 "Keep current model (never show again)",
  进程级覆盖、不写用户全局 config;app-server/runner 无 TUI
  弹窗,不加。
- wrapper 白名单 isBotmuxCodexConfigValue 同步该值,否则
  aiden 网关拒收裸 -c 启动失败、cjadk 无法完成 -c→--config
  改写。

Co-Authored-By: Claude Code <[email protected]>
stripWrapperUnsafeArgs 的枚举注释只写了 session 环境与启动更新选择器,
补上 #1367 新增的 notice.hide_rate_limit_model_nudge=true。纯注释,无行为变化。

Co-Authored-By: Claude Code <[email protected]>

@deepcoldy deepcoldy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审通过:0 阻断,可合。上游真实性、旧版安全、反变异、影响面均已独立验证,CI 13/13 全绿。N1 留 backlog,N2 已修复。

@deepcoldy
deepcoldy merged commit ba70056 into master Sep 11, 2026
22 of 23 checks passed
@deepcoldy
deepcoldy deleted the fix/codex-suppress-rate-limit-model-nudge branch September 11, 2026 09:28
@github-actions

Copy link
Copy Markdown

🚀 Released in v3.22.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants