Perplexity Lets Its Agents Write the Code That Runs Their Tools

Human Verified

Share to: , and

A robot hand reaches toward a laptop whose screen sends glowing streams of code to search, database, calendar and file icons, illustrating Perplexity's Agent API Code Mode letting a model write programs that call tools in parallel.

Perplexity has added Code Mode to its Agent API, letting the model write a JavaScript program that calls its tools instead of calling them one at a time. The company documented the feature on 1 December, presenting it as a new way for agents to orchestrate many tools at once.

How Code Mode works

Developers switch Code Mode on by adding one object to the tools array of an Agent API request, then marking each tool the program may call. The model writes a program instead of naming tools one by one, and Perplexity runs it. The response carries the code and its output.

Perplexity’s worked example asks for the latest releases of Python, Node.js, Go and Rust in one table. The model writes a single program that searches all four sites in parallel, then hands the model only the filtered results. Four searches that once took four turns now happen inside one program.

What changes for developers

Three things change at once. A program can fan out one call per item in a list, running them in parallel. It can feed one call’s result into the next. And it can filter raw tool output, sending the model only the data it needs instead of whole web pages.

The programs run inside strict limits. They cannot import modules, fetch the web directly, or keep variables between programs; they reach outside data only through tools. A program pauses when it hits a custom function or an MCP tool needing approval, and a failed program leaves the overall response standing.

Perplexity has published no speed, token-use or task-success figures for Code Mode yet, so its gains are a design claim for now, not a measured one. The Python and TypeScript libraries have no types for it yet, and the documentation states no price. Developers must send plain HTTP requests instead.

Code Mode works with streaming, background runs, stored responses and structured outputs, and it carries across turns through previous response IDs. Perplexity also ships a cookbook recipe that builds a release watchlist with it. The feature is live now for Agent API users, with no sign-up mentioned in the documentation.

Why It Matters

Every single tool call has taxed agent builders: one model turn per call, and every result dumped into context. Code Mode attacks both costs at once, moving orchestration into code the model writes itself. That is the difference between an agent that chats with tools and one that programs them.

The move also sharpens Perplexity’s pitch as the model-neutral agent platform of choice. Its Agent API already routes work across rival frontier models, and Code Mode adds programmatic orchestration on top of it. Rivals offer their own agent tooling, and the contest now turns on whose orchestration developers trust most.

Background

Code Mode caps a November for Perplexity’s developer platform, which shipped three new APIs in two days plus a Time Machine for searching the past web. The company says its API business grew 4.3 times over the past year. The name echoes Claude Code’s Code Mode, a separate coding-agent feature.

Source: Perplexity’s Code Mode guide and Perplexity changelog.

Share to: , and

Faheem R. Khattak

Senior automation engineer and AI marketing journo covering LLMs, algorithms, analytics, core updates, Bing search, and technical SEO.

0 Comments

Leave a Reply

Optional Take Tag:

🛡️ Spam protection: Honeypot + Time-Trap Active

This site uses Akismet to reduce spam. Learn how your comment data is processed.