mitsuhiko:给 Agent 一段 JavaScript,替代上千条工具定义
mitsuhiko 在 AI Engineer Code Summit 讲了个很实用的思路:与其塞一堆工具定义,不如让 Agent 直接跑 JavaScript 组合工具调用。工具多的 Agent 项目能省不少 token,做智能体开发的人都该看看。
Armin Ronacher(mitsuhiko)在 AI Engineer Code Summit 上提出:不要把上千条工具定义塞进上下文窗口,而是给 Agent 一个可运行 JavaScript 的执行环境。Agent 可以在代码里直接组合多个工具调用,写成带逻辑的工作流,而不是逐条发起工具调用。
这种做法的好处是减少上下文占用,并让 Agent 能用循环、条件判断等编程结构处理复杂任务,相当于把 MCP/工具调用从“一问一答”变成“写脚本”。
对开发者来说,这提供了一种替代传统 function calling 模式的思路:工具面越大、越复杂,代码执行方案省下的 token 和调用轮次就越多,适合构建工具数量多的 Agent 系统。
Thousands of tool definitions in the context window? @mitsuhiko of @earendilworks makes the case for giving agents JavaScript to run, so they can compose tool calls into a workflow. From AI Engineer Code Summit.
This report is categorized under AITOP's "How-to" desk, focusing on US frontier AI labs and Silicon Valley technology leaders. Within our cross-regional analytical framework, it directly maps to AI developer toolchains, coding agents, and engineering workflows. Key entities and technical topics under continuous tracking include mitsuhiko, MCP and tools, agents, prompt engineering.
Source attribution: curated from AI Engineer (@aiDotEngineer).