MixCode 是一个早期实验项目,探索一种更省钱的 AI Agent 工作流:让顶级模型负责规划和验收,让更便宜的模型或子 Agent 负责执行。
MixCode is an early experiment in cost-aware AI agent workflows: premium models plan and review, while cheaper models or sub-agents handle execution.
这不是成熟产品,也不是 Claude Code、OpenCode、Cursor、Aider 或 Goose 的替代品。它只是围绕一个真实问题的小实验:AI Agent 的每一步,都必须用最贵的模型吗?
This is not a finished product, and it is not a replacement for Claude Code, OpenCode, Cursor, Aider, or Goose. It is a small experiment around a practical question: do AI agents need premium models for every step?
现在大模型越来越多,也越来越强。但一个问题也越来越明显:真正好用的顶级模型很贵。
Large language models are getting more powerful, but the best models are still expensive.
在很多 AI Agent 工作流里,一个顶级模型会负责所有事情:理解需求、阅读代码、制定计划、修改文件、运行测试、修复错误、总结结果。这当然可能效果很好,但成本也会快速上升。
In many AI agent workflows, one premium model handles everything: understanding the task, reading the codebase, planning the solution, editing files, running tests, fixing errors, and summarizing the result. This can work well, but it can also become expensive quickly.
我想探索的是:能不能让最贵、最强的模型只负责最关键的判断环节,把边界清楚的执行任务交给更便宜的模型?
The question I want to explore is: can the most capable models focus on the judgment-heavy steps, while cheaper models handle bounded execution tasks?
MixCode 的基本思路很简单:
The core idea is simple:
用户任务 / User task
-> 顶级模型规划和拆任务 / Premium model plans and decomposes
-> 便宜模型或子 Agent 执行 / Cheaper models or sub-agents execute
-> 顶级模型验收和整合 / Premium model reviews and integrates
-> 最终结果和成本记录 / Final result and cost record
换句话说:
In short:
贵模型做判断 / Premium model makes decisions
便宜模型做执行 / Cheaper model implements
贵模型做验收 / Premium model reviews
这个项目不是想证明某个答案已经正确,而是想把这个问题变成可以讨论、可以验证、可以改进的实验。
This project is not claiming that this architecture is already correct. The goal is to make the idea discussable, testable, and improvable.
假设用户说:
Suppose the user asks:
帮我修复这个 TypeScript 项目里的一个 bug,并补充测试。
Fix a TypeScript bug in this project and add tests.
传统方式可能是全程使用一个顶级模型。
A traditional approach might use one premium model for the whole process.
MixCode 想尝试的是:
MixCode explores another workflow:
1. 顶级模型阅读需求和代码结构,制定修改计划
A premium model reads the task and creates an implementation plan
2. 便宜模型根据明确计划修改代码
A cheaper model implements the bounded change
3. 本地运行 build / test
The local build / test command is run
4. 顶级模型查看 diff 和测试结果
A premium model reviews the diff and test output
5. 如果不合格,再让执行模型继续修
If the result is not good enough, the implementer is asked to fix it
6. 输出最终结果和成本记录
The final result and cost record are returned
这不一定总是更好。真正要验证的是:对某些任务来说,是否可以在质量还能接受的情况下,减少昂贵模型的 token 消耗?
This will not always be better. The real hypothesis is narrower: for some tasks, can we reduce premium-model token usage while preserving acceptable quality?
MixCode 现在是一个很早期的 TypeScript CLI 原型。
MixCode is currently a very early TypeScript CLI prototype.
已经有的部分:
Already present:
- 基础模型 provider 配置 / Basic model provider configuration
- OpenAI、Anthropic、OpenAI-compatible 的初步接入 / Initial OpenAI, Anthropic, and OpenAI-compatible support
- 基础成本记录 / Basic cost tracking
- Thinker / Worker 的初步结构 / Early Thinker / Worker structure
run、init、costCLI 命令 /run,init, andcostCLI commands
还没有完整做好的部分:
Still missing or under development:
- planner -> worker -> reviewer 的完整闭环 / The full planner -> worker -> reviewer loop
- worker 结果回传给高级模型 review / Sending worker results back to the premium model for review
- 每一步的模型、token、成本、耗时日志 / Structured logs for model, tokens, cost, and duration
- 不同模型组合的效果对比 / Experiments comparing different model combinations
- 和现有 Agent 工具的集成可能性 / Possible integrations with existing agent tools
环境要求:
Requirements:
- Node.js 20+
- 至少一个顶级模型 API key 和一个便宜 worker 模型 API key / API keys for at least one premium model and one cheaper worker model
npm install
npm run build
npm run init然后编辑本地配置:
Then edit your local config:
open ~/.mixcode/mixcode.json请不要提交真实 API key。文档和示例里只使用明显占位符。
Never commit real API keys. Documentation examples should use obvious placeholders only.
thinker:
name: claude-opus
provider: anthropic
model: claude-opus-4-7
apiKey: sk-ant-...
inputPricePerM: 5.0
outputPricePerM: 25.0
workers:
- name: deepseek
provider: openai-compatible
model: deepseek-v3
apiKey: sk-...
baseUrl: https://api.deepseek.com/v1
inputPricePerM: 0.28
outputPricePerM: 0.42试运行:
Try a dry run:
npm run dev -- run --dry-run "Write a palindrome function and add tests"真正执行:
Run an actual task:
npm run dev -- run "Write a palindrome function and add tests"注意:当前原型还不代表完整 planner / worker / reviewer 闭环已经跑通。
Note: the current prototype does not yet represent a complete planner / worker / reviewer loop.
- AI Agent 的成本会不会越来越成为实际问题? / Will AI agent cost become a bigger practical problem?
- 哪些任务适合交给便宜模型执行? / Which tasks are safe to delegate to cheaper models?
- 哪些环节应该保留给顶级模型? / Which steps should stay under premium-model control?
- planner / implementer / reviewer 这种分工是否可行? / Is the planner / implementer / reviewer pattern useful?
- 能否比较不同模型组合的成本和质量? / Can we compare cost and quality across model combinations?
- 这个方向更适合独立工具,还是现有 Agent 工具的插件或工作流? / Should this be a standalone tool, or a workflow/plugin for existing agent tools?
欢迎参与,但这个项目还很早期。最有价值的贡献不是“大而全”的功能,而是清楚的问题、真实场景、小实验和聚焦的代码改进。
Contributions are welcome, but the project is still early. The most useful contributions are clear questions, real use cases, small experiments, and focused code changes.
你可以:
You can:
- 开 issue 讨论这个方向是否成立 / Open an issue and discuss whether this workflow makes sense
- 提供真实使用场景 / Share real use cases
- 提供 benchmark 任务 / Contribute benchmark tasks
- 改进 planner -> worker -> reviewer 闭环 / Improve the planner -> worker -> reviewer loop
- 补充模型配置和价格信息 / Add model configuration and pricing information
- 讨论和 OpenCode、Aider、Goose 等工具的集成 / Discuss integrations with OpenCode, Aider, Goose, or similar tools
MIT