AI资讯大全AIPPXP.CN搜索 ↗
微软官方 · Agent 省钱插件

Microsoft's Official Open-Source TokenEconomizer: Without Changing a Single Line of Code in the Agent, Actual Coding Costs Are Reduced by 30.9%微软官方开源 TokenEconomizer:不改 Agent 一行代码,实测编码成本直降 30.9%

Presented by UC Berkeley in collaboration with Microsoft Research: Learn three techniques from your past sessions – micro-skills to remember repository rules, eliminate tools that have never been used, and stop failure loops that go round and round. SWE-Bench tested 277 real-world tasks, and all 30 "repository × model" combinations were cheaper, with a slight increase in task success rate. Supports Claude Code, Codex, GitHub Copilot CLI, and Pi.

UC Berkeley 联手微软研究院出品:从你跑过的历史会话里学三招——微技能记住仓库规矩、裁掉从没用的工具、拦住原地打转的失败循环。SWE-Bench 277 个真实任务实测,30 个「仓库×模型」组合全部更便宜,任务成功率还略有提升。支持 Claude Code、Codex、GitHub Copilot CLI、Pi。

2026-11-13 更新 · 免费
微软官方开源 TokenEconomizer:不改 Agent 一行代码,实测编码成本直降 30.9%

Why is your coding agent so expensive?为什么你的编码 Agent 这么费钱

In each round of conversation, the Agent has to pay the "hidden bill" again: the system prompts, the definitions of each tool that has been loaded, and the entire context up to that point. And a large amount of the content in these bills is duplicative work – in the same repository, every time a session is opened, it has to rediscover the build commands, reread the useless tool instructions, and step into the same pitfalls it encountered last time.

What's worse is the "failure loop": the same error keeps recurring, the Agent goes round in circles, and tokens are burned with each loop. This is how the quota is used up by developers who heavily use Claude Code/Codex in a few projects.

中文

每一轮对话,Agent 都要重新付一遍「隐性账单」:系统提示词、已加载的每个工具定义、以及到目前为止的全部上下文。而这些账单里大量内容是重复劳动——同一个仓库里,每开一次会话它都重新摸索一遍构建命令、重新读一遍没用的工具说明、重新踩一遍上次踩过的坑。

更糟的是「失败循环」:同样的报错反复出现,Agent 在原地打转,每一圈都在烧 token。固定在几个项目里重度使用 Claude Code / Codex 的开发者,额度就是这么被吃掉的。

Three money-saving mechanisms, all reversible三招省钱机制,全部可逆

Micro-skills: Extracting "repository facts" from recurring failures across conversations and regular reviews of models – for example, that this project must use python -m pytest instead of bare pytest – and only injecting these facts into the beginning of subsequent conversations after they have been confirmed by three conversations, and automatically discarding them if they are disproven.

Tool pruning: The definition of each tool is charged for each request. If a tool has not been used for several consecutive sessions, it will no longer be loaded in the next session (implemented through the Agent's own settings file), and it can be restored at any time with a single command.

Loop guard: When the same error occurs repeatedly in the same round, the classifier, which has previously learned "how long a normal round in this repository should take", confirms a deadlock with over 70% confidence. It then sends the Agent a reminder to "try a different approach", limited to once per round. If the deadlock persists, it explicitly prompts you to press Esc to stop – it will never terminate the task for you.

中文

微技能(Micro-skills):从跨会话重复出现的失败和模型定期回顾中提炼「仓库事实」——比如这个项目必须用 python -m pytest 而不是裸 pytest——同一事实被三次会话印证后才注入到后续会话开头,被证伪就自动丢弃。

工具裁剪(Tool pruning):每个工具的定义都随每次请求计费。某个工具跨会话连续多次从未被使用,下次会话就不再加载它(通过 Agent 自己的设置文件实现),一条命令随时恢复。

失败循环拦截(Loop guard):同一轮里反复出现相同报错时,先学过「这个仓库一轮正常要跑多久」的判定器以 70% 以上置信度确认卡死后,给 Agent 塞一句「换个思路」的提醒,每轮最多一次;仍然卡住则明确提示你按 Esc 停止——它永远不会替你掐断任务。

三招省钱机制,全部可逆

Measured data: All 30 combinations, without exception, are more energy-efficient.实测数据:30 个组合无一例外全部更省

The paper ran five sets of "Agent × Model" combinations on 277 real-world tasks in SWE-Bench: the average cost was reduced by 18.4%–30.9%, and all 30 "Repository × Combination" units were cheaper than not installing them, with the task pass rate for 4 of the sets also slightly increasing. Switching to a web development test set can save 16%–21%, and even if each task is a security audit scenario for a brand-new repository, savings of 6%–20% can still be achieved.

Costs are calculated accurately based on cached pricing, including the costs of models called by the plugin itself – no numbers are embellished.

中文

论文在 SWE-Bench 的 277 个真实任务上跑了五组「Agent×模型」组合:平均成本降低 18.4%–30.9%,30 个「仓库×组合」单元全部比不装更便宜,其中 4 组的任务通过率还略有提升。换成 Web 开发测试集能省 16%–21%,即使每个任务都是全新仓库的安全审计场景也能省 6%–20%。

成本按缓存定价如实计算,连插件自己调用的模型费用都算在内——没有美化数字。

实测数据:30 个组合无一例外全部更省

Getting Started and Privacy上手与隐私

Python 3.10+ is required, and the plugin itself has zero third-party dependencies. After installation, write code as usual. Use /tokeneconomizer:status to check what it has learned and how much each session costs at any time. It is recommended to run config set history_import=on --global immediately after installation to make historical sessions useful as well.

Privacy is impeccable: Everything it learns exists only in your local ~/.tokeneconomizer directory, no API key is required, and you use your Agent's original login method. If any part of the plugin goes wrong, the session continues as usual, as if it had never been installed.

中文

需要 Python 3.10+,插件本身零第三方依赖。装好后照常写代码,用 /tokeneconomizer:status 随时查看它学到了什么、每次会话花了多少钱;建议安装后立刻执行 config set history_import=on --global,让历史会话也派上用场。

隐私方面无可挑剔:它学到的所有东西只存在你本机的 ~/.tokeneconomizer 目录,不需要任何 API Key,用你 Agent 本来的登录方式;插件任何部分出错时,会话照常进行,就像没装过一样。

usage hint使用提示

The directory after extraction must be retained (the plugin runs from the cloned directory). After installation, remember to run /tokeneconomizer:toolprune refresh-catalog once. For an illustrated installation guide, see "Install Microsoft's official TokenEconomizer in three minutes" on this site.

中文

解压后目录要保留(插件从克隆目录运行),装完记得跑一次 /tokeneconomizer:toolprune refresh-catalog。图文安装教程见本站《三分钟装上微软官方 TokenEconomizer》。

资源下载 · Download

⬇ Download · 点击下载:TokenEconomizer 完整插件源码包(Claude Code / Codex / Copilot CLI / Pi)

Apache-2.0 许可 · UC Berkeley + 微软研究院出品 · 需 Python 3.10+ · 学习数据仅存本机

0阅读0 条评论

阅读与点赞数据保存在你的浏览器本地,欢迎留下你的想法。

评论 文明发言,让讨论更有价值

正能量公益广告今日正能量学一点,用一点;今天种下的种子,会长成明天的能力。去免费下载专区 →广告