Conversation
闪退/强杀后 Codex 未及回写 UI 模型选择,config.toml 停留在工具写入的 隐式默认(model_list 第一条/模板值),目标任务自动继续时被静默换模型。 三层修复,各对应 issue 的一句原文: - launcher 启动对齐(「程序闪退或者强制重启…模型错的」):live config 的 model 仍为工具写入值且有未归档目标任务时改写为目标任务模型, Codex 回写的 live 值一律不动 - manager apply 对齐(「在codex++重启完codex后…被换成Astra 6 high」): apply 时把未归档目标任务模型注入 profile.model,显式配置不受影响 - backfill 阻断(超出 issue 字面范围,防修复被固化机制瓦解):切换 供应商时不再把工具写入的 model 固化进 profile,并救援值恰等于 model_list 第一条的存量污染 数据源:automation_runs(未归档,按 updated_at 取最新) join threads.model, schema 与本机真实 Codex 库核对;表缺失/缺列/库不可读一律回落旧行为。
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2264
问题
用户用某个模型跑长线目标任务(目标模式),Codex++ 重启 Codex 后目标任务自动继续,但模型被静默换成 model_list 第一条(issue 中为 Astra 6 high),无人值守一夜烧掉大量额度。
根因
三条事实叠加:
model作为模型选择的恢复源(本 PR 已实测,见验证第三节):UI 选模型后会把它回写 config;闪退/强杀时回写没来得及发生,config 停留在 Codex++ 上次写入的值;complete_relay_profile_config原回落逻辑),不是用户意图;apply_active_relay_profilehook 定义了但主流程未接线;直接重放完整 apply 又会覆盖用户 live 回写值,因此走下述轻量对齐。目标模式任务恢复继续执行时跟随当前模型选择 → 漂移发生。
修复(3 文件,+543/-3,约一半为测试)
issue 原文两句话各对应一层修复,第三层防瓦解:
profile.model;用户显式声明的默认模型优先级最高数据源:
automation_runs(未归档,archived_reason为空,按updated_at取最新)jointhreads.model。表缺失/缺列/库不可读一律静默回落旧行为。带后缀语法时写入前剥后缀(复用parse_model_suffix)。验证
单测(relay_config.rs 内嵌测试模块,伪造 sqlite 按真实 schema):
cargo test -p codex-plus-core:37 个测试组全部通过,0 回归(含 tests/relay_config.rs 全部 154 个存量测试)。L2:真实 launcher 二进制链路(沙箱
CODEX_HOME+ 真实 settings,不触碰真实~/.codex):gpt-5.6-luna)→ 启动真实 launcher 约 3 秒内 config 对齐为目标模型,诊断日志launcher.goal_thread_model_aligned留档;L3:config → Codex UI 模型通道对照(真实 Codex 26.915 桌面版,pureApi + API key 免登录,CDP 检查 UI,config 改动全程备份并已恢复现场):
model = "gpt-5.6-sol"时 UI 模型选择器显示5.6 Sol;model = "gpt-5.6-luna"并 reload → UI 变为5.6 Luna;恢复 sol 并 reload → 回到5.6 Sol。双向可逆跟随:config.toml 的 model 是 Codex 模型选择的恢复源,写对它即写对恢复任务所用的模型。验证链完整:sqlite 目标任务模型 →(L2)launcher/apply 写对 config →(L3)Codex UI 模型跟随 config → 目标模式恢复继续执行。
边界(如实)
turn/start自带params.model,与refreshCodexThreadModelBeforeTurn的设计前提),未做消耗真实额度的端到端复跑。automation_runs.status值域未采样(本机库无数据),未归档判定用archived_reason为空(列语义明确)。threads(id, model)为仓库既有已发布代码依赖;automation_runs列结构核对本机真实 Codex 库。附:测试方法学说明
MSIX/AUMID 激活方式不继承
CODEX_HOME环境变量:launcher 进程尊重沙箱 home,但被拉起的 Codex 桌面版读写真实~/.codex。端到端测试需要以「备份 + 改真实 config + 事后恢复」验证 Codex 侧行为,或改用环境继承可靠的启动方式(本 PR 的 L3 即按此操作并已恢复现场)。