AI News
AI News AgentToolingPerplexity3 min read

Perplexity brings Code Mode to its Agent API

Perplexity is bringing Code Mode to its Agent API so models can coordinate searches, files and external tools through scripts. In its tests, the system improved quality, reduced the cost per task and shortened longer research sessions in particular.

Perplexity has added Code Mode to its Agent API, allowing its AI agents to coordinate searches and other tools through a script instead of asking the model to make a new decision after every call.

The difference matters when a task involves extensive research. In the traditional system, the agent searches, receives the data, returns to the model and decides what to do next. That cycle repeats dozens of times and fills the context window with information that may never be used.

With Code Mode, the model writes a small program that can launch calls in parallel, filter results, remove duplicates and keep only what is needed. The rest can be stored outside the context, for example in working files.

One interface for multiple tools

The scripts run as JavaScript in an integrated environment based on QuickJS WebAssembly, with no need to start a separate container. From the same program, the agent can use:

  • Web search and page reading.
  • People searches and financial data.
  • MCP servers, a standard for connecting external tools.
  • File or shell commands within the isolated environment.

This makes it possible to build multistage research workflows. For example, the agent can search for information in parallel, keep the relevant documents, save them and then analyze them without putting all the raw data into the conversation.

Code Mode is available at the high, xhigh and ultra effort levels, and is enabled through the programmatic_tool_calling option in custom requests. The latest models at those levels use it by default.

Higher quality and lower costs in testing

Perplexity measured the system on WANDR, its evaluation for broad and in-depth research tasks. The test used the first 100 tasks from a set of 500 and kept the prompt, search tools and evaluation system fixed.

First, the company compared newer models with their November 5 configurations. It then enabled Code Mode on those same models:

  • Sol-6.2 at the xhigh level rose from 76.5% to 80.5%, while the average cost fell to $3.85 per task.
  • The combination of Opus 5.5 and three instances of Sol-6.2 at ultra reached 89.4%, at a cost of $10.30 per task.
  • At the high level, Code Mode reached 47.7% at $0.38 per task, a 2.9-point improvement over direct calls.

These are benchmark results, not a guarantee for every application. Performance will depend on the available tools, the type of task and the model selected.

It also cuts long waits

Large research tasks can get stuck while several searches or commands finish. To avoid this, exec returns partial output after 10 seconds and keeps the script running in the background. The agent can continue with another part of the work and retrieve the result later through exec_wait.

In paired tests with the same budget, this system reduced the median duration from 28.9 to 25.3 minutes. In the slowest runs, the 95th percentile fell from 97.3 to 57.5 minutes, while the maximum duration dropped from 174.2 to 75.6 minutes.

For you, the change is most noticeable if you use the API for research, financial analysis or tasks that combine many sources. The agent can use fewer reasoning calls, work with more data without saturating its context and finish sooner when there are multiple branches to investigate.

Perplexity expects to expand Code Mode to more levels as models make fewer mistakes when writing and running scripts. The direction is clear: agents will not just call tools one at a time. They will start programming how to use them together.