V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
apibox
V2EX  ›  程序员

[分享] Codex + GPT 5.4 火力全开配置调优

  •  5
     
  •   apibox · Mar 14 · 6968 views
    This topic created in 45 days ago, the information mentioned may be changed or developed.

    自从 OpenAI 出来 gpt-5.4 模型后 Codex 的使用确实有了极大的提升,我个人调整配置后开发同一个需求对比使用 Claude Code + Claude Opus 4.6 还更快一点完成。

    本来从 gpt-5.3-codex 的默认配置直接使用,但发现上下文一下就不够了,对于大一点的工程来说 特别难受。

    后来查了下网上的资料,说 gpt-5.4 的 1M 上下文的能力要自己主动配置开启,晕。

    下面放出我自己使用 Codex 的一些配置,算是抛砖引玉,不一定是最佳实践,有不同的欢迎指正。

    打开 ~/.codex/config.toml 文件

    project_doc_fallback_filenames = ["CLAUDE.md"] # agents.md 找不到,则找 claude.md ,和 Claude Code 使用同一份约束
    
    model = "gpt-5.4"
    review_model = "gpt-5.4" # 默认 "gpt-5.2-codex"
    
    model_provider = "apibox" # 改成你自己的中转站名
    model_reasoning_effort = "xhigh" # 思考强度超高
    
    model_context_window = 1000000 # 模型上下文窗口大小,默认 1000000 ( 1M ) for gpt-5.4
    model_auto_compact_token_limit = 500000 # for gpt-5.4 虽然是 1M ,但是有效注意力不够,不建议开的太高
    
    
    [model_providers.apibox]
    name = "OpenAI" # 如果用的是中转站,建议把名字改成 OpenAI (注意大小写)命中缓存,省 token
    base_url = "apibox.cc/v1" # 改成你自己的中转站 API 地址哦
    wire_api = "responses" 
    requires_openai_auth = true
    
    [features]
    shell_tool = true # 启用 shell 工具。默认: true
    apply_patch_freeform = true # 通过自由格式编辑路径包含 apply_patch (影响默认工具集)。默认: false
    shell_snapshot = true # 启用 shell 快照功能。默认: false
    undo = true # 启用 undo 功能。默认: true
    unified_exec = true # 使用统一 PTY 执行工具
    multi_agent = true
    steer = true
    prevent_idle_sleep = true
    child_agents_md = true
    
    memories = true # 开启记忆
    sqlite = true # 可配可不配,随意
    fast_mode = true # 必开,完全不同的体验,当然也会让 gpt-5.4 用量变 2 倍
    
    [memories] # 强烈建议用新模型来总结 memories
    consolidation_model = "gpt-5.4"
    extract_model = "gpt-5.4"
    # generate_memories = true # 默认 true
    # use_memories = true # 默认 true ,表示把 memory_summary.md 注入 developer instructions
    max_raw_memories_for_consolidation = 512
    max_unused_days = 30 # 默认 30
    max_rollout_age_days = 45 # 默认 30
    # max_rollouts_per_startup = 16 # 默认 16
    # min_rollout_idle_hours = 6 # 默认 6
    

    小技巧:

    model_auto_compact_token_limit 这个配置可以动态调整 当你的工程的会话上下文特别大的时候,你有不想开新的会话时。你可以先把这个配置改大,然后重新开启 VS Code 或者 cli ,这样就不会触发压缩了,可以继续聊下去。

    Supplement 1  ·  5 days ago

    更新下:

    有些童鞋注册了我们的 APIBox 中转站,直接复制了我发的这个 Codex 优化配置,但是出现了报错,是因为 base_url 之前教程里面写的不对,现更新下这里:

    base_url = "https://api.apibox.cc/v1"
    

    PS:APIBox V 站专属公测活动还在进行中,有需要的童鞋欢迎回帖领取: https://www.v2ex.com/t/1207704

    27 replies    2026-04-28 12:06:54 +08:00
    AAAmos
        1
    AAAmos  
       Mar 14
    学习了
    lizhenda
        2
    lizhenda  
       Mar 14
    这个配置看起来更全一些,不改之前默认是 258K ,一下就触发压缩了,用的很蛋疼。奥特曼说 gpt 5.4 1M 上下文还以为是骗人的。感谢分享!
    songunity
        3
    songunity  
       Mar 14
    问下,windows 下一直需要权限,需要怎么设置呢
    apibox
        4
    apibox  
    OP
       Mar 14
    @songunity 我是在 VS Code 中使用,在 Codex 对话框下面有个权限设置,可以选择 [完全访问权限] 这就就不会一直询问了。
    gpt5
        5
    gpt5  
       Mar 15
    有点没明白,你不是说了“默认 1000000”,为啥还要特意设置呢?
    wisej
        6
    wisej  
       Mar 15
    @gpt5 codex app 里默认还是 256k ,可能 api 的话默认 1M 了吧
    apibox
        7
    apibox  
    OP
       Mar 15
    @gpt5 额,默认 1000000 有歧义,要设置了才会是 1M ,是说 gpt-5.4 支持 1M 的意思
    iorilu
        8
    iorilu  
       Mar 15
    不错, 我设置了, 回头写点代码看看效果
    apibox
        9
    apibox  
    OP
       Mar 15
    @iorilu 配置有哪里可以调整欢迎发出来一起讨论~
    infinityv
        10
    infinityv  
       Mar 15
    @apibox 我是在 vscode 的插件中而不是直接终端起的 codex 也不是 codex app; 这个配置对插件生效吗?
    apibox
        11
    apibox  
    OP
       Mar 15
    @infinityv 生效的呢,对 VSCode 插件和 cli 一同生效。但配置修改记得重启 VSCode 或者重载窗口。
    abcgoodwei
        12
    abcgoodwei  
       Mar 15
    这样会导致 token 燃烧吗?这比默认配置消耗高不少吧
    MrVito
        13
    MrVito  
       Mar 15
    我比较关心这个有效注意力,是否有相关的测试或者数据支持?
    apibox
        14
    apibox  
    OP
       Mar 15
    @abcgoodwei 当然,保底 2 倍消耗 [:dog]
    yimouleng
        15
    yimouleng  
       Mar 16
    明天试试
    Paracosm
        16
    Paracosm  
       Mar 16
    我试了一下感觉 token 消耗的超级快
    apibox
        17
    apibox  
    OP
       Mar 16
    @Paracosm 是的,网速好的情况下消耗飞快,也算是提效了。
    aker91
        18
    aker91  
       Mar 17
    我中等强度使用 codex ,之前从未到达限额,按照这个配置,20 分钟不到触发了限额,不建议用
    apibox
        19
    apibox  
    OP
       Mar 17
    @aker91 可以改其中一些配置,比如说关掉 Fast Mode ,上面的配置不是盲目拷贝就用呀,可以根据自己的情况调整
    aker91
        20
    aker91  
       Mar 18
    @apibox #19 我本来就一直用 fast mode ,这个配置中就是更改了上下文限制和 memories ,个人认为基本没用,现在有 subagent ,可以把网络搜索,命令行,代码搜索之类的分离出去,上下文基本是够的。memories 添乱的时候可能有用的时候还多
    另外现在 team 试用账号额度充足,完全没必要用中转站
    lizhenda
        21
    lizhenda  
       Mar 24   ❤️ 1
    加上这个配置,gpt-5.4 的回答就不会啰嗦了,建议加上

    # Communication style for supported models. Allowed values: none | friendly | pragmatic
    personality = "pragmatic"
    apibox
        22
    apibox  
    OP
       Mar 25
    @lizhenda #21 很棒哦!
    lancelot1016
        23
    lancelot1016  
       Mar 28
    优秀的帖子顶起来
    apibox
        24
    apibox  
    OP
       Mar 28
    @lancelot1016 哈哈,感谢,我们的中转站内测了,有兴趣可以来试试。
    地址: https://api.apibox.cc/
    站内介绍帖子: https://www.v2ex.com/t/1201876
    superkite
        25
    superkite  
       2 days ago
    256k 压缩一些不关键的上下文信息也够用了,改成 1m 上下文用到后面 token 消耗会很快吧,具体贵多少有人算过吗
    apibox
        26
    apibox  
    OP
       1 day ago
    @superkite 目前 Codex 使用 gpt-5.5 模型时,即使在配置里面设置了 1M 上下文也是无效的,需要等官方放开。
    256k 配合压缩做些小任务其实也是够的,gpt-5.5 有人说消耗是 5.4 的 3 倍,我的感受不明显,不确定这说法是否正确。
    superkite
        27
    superkite  
       1 day ago
    @apibox 这几天用下来的体感 5.5 消耗差不多是 5.4 的 3-5 倍
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5391 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 08:26 · PVG 16:26 · LAX 01:26 · JFK 04:26
    ♥ Do have faith in what you're doing.