Perplexity Agent API 推出 Code Mode:用 JavaScript 脚本替代逐轮工具调用
做智能体的朋友可以看看这个:Perplexity 给 Agent API 加了 Code Mode,模型直接写一段 JS 并行跑工具,只把有用的结果塞回上下文,省 token 也省轮次。比起一轮一个 JSON 调用,多工具编排会顺很多,适合正在搭多工具工作流的开发者。
Perplexity 在其 Agent API 中新增 Code Mode(programmatic_tool_calling)功能,由 CEO Arav Srinivas 在 X 上发布。新模式改变了智能体调用工具的方式:模型不再每轮以一条 JSON 指令调用一个工具,而是编写一段 JavaScript 脚本,一次性并行执行多个工具。
工作机制上,脚本运行后可以处理工具输出的中间结果,只把模型真正需要的部分返回到上下文窗口,从而减少逐轮 JSON 调用造成的上下文膨胀。这对需要串联多个工具、处理大量返回数据的智能体工作流尤其有效。
Perplexity 的 Agent API 此前主要面向搜索类智能体开发者,这次更新属于开发者工具层面的能力增强,与 Anthropic、OpenAI 等厂商在智能体工具调用效率上的探索方向一致。开发者若在构建多工具编排场景,可以关注这一新接口。
We added Code Mode (programmatic_tool_calling) to the Perplexity Agent API. Instead of calling tools one JSON turn at a time, the model writes a short JavaScript script that runs tools in parallel, processes the outputs, and returns only what it needs back into the context.
This report is categorized under AITOP's "Products" 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 Perplexity, Agent API, MCP and tools, coding assistants.
Source attribution: curated from Aravind Srinivas (@AravSrinivas). Cross-source corroboration: 11 independent sources have covered this development (including Perplexity, Claude Code: GitHub Releases, IT之家), confirming industry-wide signal strength.