token 消耗顶不住了,codex cli 怎么实现 GPT 主代理审核 + DeepSeek 子代理写代码?

各位老哥好,最近写代码 token 消耗实在顶不住,想换个思路降成本。

目前环境是 wsl + codex cli + cc-switch (ccs)。

我打算搞一套主从架构的工作流:

用GPT作为主代理(Main Agent),专门负责前期的任务规划、拆解,以及最后的代码审查;
把具体的脏活累活、代码实现丢给子代理(Sub-agent),走便宜大碗的 DeepSeek 或者其他模型来跑。

想请教下大家两个问题:

  1. codex cli 本身支持这种多模型/子代理玩法吗?在 codex cli 里面要怎么配置,才能让它调用不同模型,并且区分主从任务?

  2. 双中转和路由怎么解决?配合 ccs 使用时发现它好像只能挂一个中转。如果真要跑上面这种多模型协作,是不是必须在本地搞一层类似 cliproxyapi、new-api 之类的网关做统一分流?

有已经跑通类似工作流的老哥指点一下配置姿势或者踩坑经验吗,多谢了。

3 个赞

dsh支持无头运行:

dsh --profile headless --session-id <id> --json
1 个赞

可以config.toml写gpt的模型,然后在
"~\ .codex\agents\default.toml"的model写ds的模型,然后再在developer_instructions写一下你对ds模型(子代理)的使用规范,
这样就是主流程使用gpt,子代理使用ds,根目录的AGENTS.md再加上一句子代理完成后需要review以确保符合当前项目需求之类的话,就可以了
前提是ds和gpt都在一个ccs里面

4 个赞

我也想知道,佬配成功了么?我是直接告诉astra让它给我配的 :laughing:我想学习一下正经的配置文件应该咋弄

codex的v2子代理似乎看不懂非openai模型看不到主代理的命令,这个bug好像还没有修,v1用着有点别扭感觉

那deepseek映射为gpt 5.5如何?

1 个赞

DSH试了下,感觉使用起来有点别扭。

这样会造成重复的传递token造成浪费么?

1 个赞

佬试试 codeg 这个开源软件呢?它就是一个壳子,里面运行claudecode以及其他cli客户端,它就有分配子任务给其他模型的能力。

其实这就是用的codex自己的子代理功能,传递token的浪费倒是不用很在意,主要是codex的子代理并不是开发得很完善(目前处于能用状态)

任何技术问题,直接丢给 claude / chatgpt 去处理,都能给你解决好。

1 个赞

我是这样用的,很简单:对话中让它直接调 DeepSeek worker 就可以。
~/.codex/agents/deepseek-worker.toml

name = "deepseek_worker"
description = "Execution-focused DeepSeek worker for implementing scoped changes, fixing bugs, and verifying results."
model_provider = "custom"
model = "deepseek-v4-flash"
model_reasoning_effort = "high"
model_catalog_json = "$HOME/.codex/deepseek-models.json"
developer_instructions = """
Work as an execution-focused subagent on the bounded task delegated by the parent agent.

Inspect the relevant code and instructions before editing. Make the smallest coherent change that fully solves the assigned task, preserve unrelated user work, and follow all applicable AGENTS.md files. Verify changes with the most relevant available tests or checks.

Stay within the delegated scope. Do not broaden requirements, perform destructive operations, or create commits unless explicitly requested. If blocked, report the exact blocker and the evidence gathered instead of guessing.

Return a concise summary of what changed, verification performed, and any remaining risks or follow-up work. Include precise file references when useful.
"""

[model_providers.custom]
name = "DeepSeek"
base_url = "https://api.deepseek.com/"
wire_api = "responses"
requires_openai_auth = false
experimental_bearer_token = ""
11 个赞

这几天把DS4.1 Flash换成了Devin那个20刀套餐无限量的SWE-2,跑了十几个小时用量为0 :laughing:

除了慢一点没毛病,直接Token自由

我的fable告诉我是直接,换了个启动命令,然后把所有的模型映射成dsf
这样我主会话可以用claude 进入,用官方的模型
子会话用dsh映射模型,利用claude 自己的会话间交流的能力,主的操控子的

我道听途说,CODEX的子代理,可以单独设置模型,然后你可以让指挥GPT让他只用这个子代理(国模),达到省钱的目的

或者佬试试omo插件(oh-my-openagent),之前用opencode的时候用过,现在也做了codex插件了(但我没试过它的codex版本hhh,不知道支不支持多模型路由,opencode倒是支持的挺好)
他那个思路就是把agent分工成总体设计和具体代码实现,感觉和佬的这个想法挺像的,但不确定能不能省token,佬可以试试

1 个赞

或许反过来,使用顾问模式,主代理是ds,遇到需要规划的审查的问题,再使用子代理询问顾问模型(GPT6等)?

pi在这方面做的不错,也支持gpt订阅登录

只有最开始、最全局的规划,可以一开始就上GPT6来分析了

我尝试过 Astra一直看子代理的gitdiff然后分析 花费也不少

我自己用dsh写了个插件,实现了这个效果,设计用Astra mid,前端用ds4.1f,后端用Astra low

佬,可以分享吗。很是需要