配置档与临时覆盖
用独立 profile 文件组织场景配置,处理旧配置迁移,并理解命令行 TOML 引号。
This page has not been translated into English yet. The original Chinese version is shown below.
当日常编码、只读调查和集中评审需要不同设置时,可以把差异存成 profile。共享默认值仍留在 ~/.codex/config.toml,profile 只写不同的键。
建立并选择配置档
在 ~/.codex/deep-review.config.toml 写入顶层配置:
model_reasoning_effort = "medium"
approval_policy = "on-request"启动时选择它:
codex --profile deep-review
codex exec --profile deep-review "review this change"profile 名可使用字母、数字、连字符和下划线。文件中的键直接位于顶层,不再嵌套到 [profiles.deep-review]。profile 覆盖用户配置,但低于受信任项目配置和 CLI 覆盖;推理强度是否适用取决于模型。
迁移旧格式
官方说明从 Codex 0.134.0 起,--profile 不再读取 config.toml 内的 [profiles.profile-name],顶层 profile = "profile-name" 选择器也不再支持。把表内设置移到 ~/.codex/profile-name.config.toml,删除旧表与旧选择器,再用 --profile 选择。
只改一次运行
有专用参数时优先用专用参数,如 --model。任意配置键可以用 -c 或 --config 覆盖,支持点分隔的嵌套键:
codex --config 'model_reasoning_effort="medium"'
codex --config 'mcp_servers.context7.enabled=false'第二例仅适用于你已配置该名称的 MCP server。值首先按 TOML 解析,无法解析时才作为字符串处理。外层 shell 引号和内层 TOML 引号用途不同,含空格或数组时尤其要保留完整参数。
遇到覆盖不生效,用 /debug-config 检查生效层;组织 requirements 限制的值,不能通过提高个人配置优先级绕过。