←News detail

Shao MengUpdated Nov 3 10:04

Philipp Schmid on Agent tool calling shifting to Code Mode: exposing only one exec

English text is being prepared.

AI summary

Philipp Schmid proposes that Agent tool calling is converging from one JSON action per turn to Code Mode, where the model receives only one exec(code), chaining queries, filtering, modifications, and parallel operations within a TypeScript/Python sandbox, with most intermediate results not entering the context. In implementation, the tool catalog is compiled into compact type declarations, text()/image()/audio() control which outputs enter the next turn, and store/load keeps state in host memory. The article states that Pi, Factory Droid, OpenAI Codex, and others already default to or support Code Mode; after Factory switched, Terminal-Bench 4 accuracy was about +3.5 and model cost about -15%.

Why read this

AI score 68

The original article outlines the path of Agent tool calling shifting from individual JSON actions to code sandbox execution, and presents implementation trade-offs and ecosystem cases.

Topics

Tags

Quoted post

Philipp Schmid

@_philschmid

Are Agents soon going to have only 1 tool? We went from a handful of tools, to dynamic tool search, and now to collapsing everything into code mode. Wrote down how Code Mode works, why a typed JS/Python sandbox can beat raw bash, and why MCP is going to go back strong in 2027. With an a minimal example for Gemini 4 Argon. https://t.co/IsS9QfEmuD If you plan to explore code mode i can recommend testing with pi! Easily hackable and comes with strong foundation.

View original

Are Agents soon going to have only 1 tool? We went from a handful of tools, to dynamic tool search, and now to collapsing everything into code mode. Wrote down how Code Mode works, why a typed JS/Python sandbox can beat raw bash, and why MCP is going to go back strong in 2027. With an a minimal example for Gemini 4 Argon. https://t.co/IsS9QfEmuD If you plan to explore code mode i can recommend testing with pi! Easily hackable and comes with strong foundation.

View original post

Body

Agent 很快只剩一个工具:用代码把动作串完再回来

来自 @_philschmid 的分享,他发现 Agent 工具调用正在从「每轮一次 JSON 动作」收敛成 Code Mode:模型只拿到一个 exec(code),在沙箱里用 TypeScript/Python 把查、滤、改、并行全串完,中间结果大多不进上下文。 https://t.co/yp52gsX360

过去两年做 Agent,核心工作是设计工具、拆粒度、改 schema 和系统提示。Philipp 认为方向在反过来:整本工具目录浓缩成一个 exec,这就是 Code Mode。Harness 不再把几十个 JSON Schema 工具塞进模型接口,而编成紧凑的类型声明(declare namespace tools { ... });模型要做事就写一小段脚本,在隔离沙箱里 await tools. xxx(...),用 Promise.all、过滤、分支把依赖动作一次做完。

工具调用大致走过几步:模型弱时只能给少量工具;变强后又接上几十个工具或 MCP,撞上上下文上限,于是用工具搜索、按需披露;即便动态加载,标准调用仍基本是「一回合一个动作」,出结构化调用、等原始输出回写历史、再推理下一步。最近模型在「单次生成里组合依赖动作」上明显更稳,Code Mode 才站得住:调研可以一轮里查询、过滤、抽答案;多文件改动能同脚本里改完再跑校验;浏览器/电脑操作不必每个点击都回模型;并行扇出可以 await Promise.all 再喂给下一步,中间不反复挤进上下文。推动因素包括:前沿模型大量训代码、厂商开始为 Code Mode 做后训练,以及 MCP 越来越多同时给 inputSchema 和 outputSchema,模型在跑之前就知道返回类型,便于在同一脚本里把 Tool A 接到 Tool B。

实现上,表面只暴露 exec(code)。大目录不必一次全挂上,可继续用工具搜索,或在沙箱里挂全局 ALL_TOOLS 让模型用代码筛选。text() / image() / audio() 决定哪些输出进下一轮上下文;store / load 把状态放在宿主内存,避免大 JSON 每轮占 token。文中 Linear 例子:列出项目 → 并行拉 issue → 滤出未指派 → 并行归档,沙箱里可跑几十次底层 API,回模型的往往只有一行摘要。

为什么偏 JS/Python 沙箱而不是只给 bash:类型化函数直接对应 MCP/内部 API,有原生对象、Promise.all、try/catch,少受 shell 转义之苦;自定义 CLI 常逼模型先 --help、读源码摸旗标,类型契约能省这层探索税;shell 基本只有 stdout,多模态要看图还得另挂工具,而 image(screenshot) 可直接挂到下一轮;每次 tools.* 走宿主桥,可在沙箱外注入 OAuth、校验 schema、对破坏性操作暂停确认;标准工具调用几乎只能靠 prompt 历史当状态库,KV 则能跨回合省 token。

文中给了一个用 Gemini Interactions API、gemini-4-argon 的可跑伪示例:只注册 exec,脚本里列 PR 文件、按条件筛、跑安全扫描、发评论,中间文件对象和扫描原始结果不进模型,第二轮只收回一行摘要。生态上,Pi、Factory Droid、OpenAI Codex 等已默认或支持 Code Mode;Factory 把 Droid 1.0 切过去后,Terminal-Bench 4 准确率约 +3.5,模型花费约 -15%。Pydantic AI、LangChain、Cloudflare Agents SDK 等也有类似能力。作者也留了余地:未必每个 Agent 真只剩一个工具;很多为 bash 和人类可读文本优化的 CLI、Skills,接到类型化执行上未必顺,可能要回过头清点 Agent 真正需要什么。

Source

Shao Meng