AI Models & Platforms

Perplexity Adds Code Mode to Agent API for Parallel Tool Calls

Aiden Cross
Add Unite.AI to your preferred sources on Google
AI-generated illustration
Key PointsCode Mode cuts benchmark cost by up to 53% by running tools as parallel JavaScript…
View more
  • Code Mode cuts benchmark cost by up to 53% by running tools as parallel JavaScript programs.
  • Programs execute in an embedded QuickJS runtime that filters payloads before results reach the model context.
  • Background execution lets scripts return partial output after 10 seconds so agents avoid idle blocking.

Perplexity introduced Code Mode in its Agent API on December 2, 2026, reporting higher research scores and benchmark cost reductions of up to 53% against its earlier presets. The feature lets models replace repeated tool-call round-trips with JavaScript programs that run enabled tools in parallel and filter results.

Code Mode, formally identified in requests as programmatic_tool_calling, runs scripts inside an embedded QuickJS WebAssembly runtime within the agent loop. A single program can execute tool calls in parallel, branch on results, remove duplicates and filter raw payloads before selected output returns to the model’s context. Enabled tools are exposed through one typed tools.* interface, including web search, URL fetching, people and finance search, MCP servers, and sandbox file or shell tools.

The approach extends Perplexity’s earlier Search as Code retrieval system, which ran Python against pplx_sdk inside a Linux sandbox container. Code Mode does not require booting that container or working within a separate Python search library.

The announcement’s simplified finance trajectory illustrates the operational change: the model batches quarterly segment and earnings-transcript calls across six tickers, saves raw payloads to disk and emits compact summaries instead of streaming large filings into context.

WANDR Scores and Costs

Perplexity evaluated the changes on the first 100 of the 500 tasks in WANDR, short for Wide ANd Deep Research. The benchmark requires agents to discover broad collections of entities and support each collected record with evidence. Its grader re-fetches cited pages and checks whether the pages and selected excerpts support the submitted claims.

The launch experiments report soft recall, a measure of quality-adjusted completion against the requested volume that gives partial credit for incomplete records and counts any shortfall as zero. Perplexity’s sequential results separate the model upgrade from the subsequent execution change:

Effort level Configuration Soft recall Average cost per task
xhigh November 5, 2026 preset 76.5% $7.30
xhigh Sol-6.2 78.7% $5.57
xhigh Sol-6.2 + Code Mode 80.5% $3.85
ultra November 5 preset 85.9% $21.71
ultra Opus 5.5 + 3 Sol-6.2 88.5% $12.12
ultra Opus 5.5 + 3 Sol-6.2 + Code Mode 89.4% $10.30

The first two configurations for each effort level show newer reasoning models improving scores and costs before Code Mode was enabled. The third adds Code Mode with those same models. Every experiment held the prompt, agent harness, search backend and grading pipeline fixed, varying only model generation, execution mode or cell scheduling. Costs are averages under each configuration.

Perplexity attributed the mid-tier improvement to better model coding: high plus Code Mode reached 47.7% soft recall at $0.38 per task, 2.9 percentage points above baseline, without hand-crafted research workflows or prompts. Earlier experiments at high and lower effort levels had scored worse and cost more than direct tool calling as models made syntax mistakes, misread tool outputs and spent additional steps recovering from script errors.

Background Execution and Latency

Long fan-out or sandbox jobs can otherwise block the entire agent loop. Perplexity said exec returns partial output after 10 seconds while the script continues in the background, allowing the agent to pursue other research branches before collecting results with exec_wait or cancelling a stalled script.

In paired WANDR runs at identical spend, Perplexity reported median duration falling 12.5%, from 28.9 to 25.3 minutes. The 95th percentile fell 40.9%, from 97.3 to 57.5 minutes, while maximum duration fell 56.6%, from 174.2 to 75.6 minutes. The larger reductions at the tail follow from the mechanism: work that would have left the whole loop idle can overlap with other research.

Setup and Execution Limits

Enabling the feature requires a programmatic_tool_calling object in the tools array of a POST /v1/agent request and programmatic in the allowed_callers array of each tool a script may call. The Code Mode documentation allows a tool to be programmatic-only, available through both direct and programmatic calls, or direct-only. Programs use await tools.<name>(args), Promise.all for parallel calls and text(value) to return selected data.

Programs cannot import modules, use process or fetch, obtain external data except through tools, or retain variables for a later program. Identical requests can also produce different programs. When model is supplied without an effort level, max_steps must allow at least two steps so the model can read one program’s output and write another. Version 0.50.0 of Perplexity’s Python library and version 0.45.0 of its TypeScript library lack Code Mode types, so the documentation’s examples use direct HTTP requests.

Custom functions pause a program until the developer returns function_call_output items containing the original caller information. Programmatic-only MCP tools that require approval currently need defer_loading set to true; without it, the approval request returns HTTP 400. A program error does not necessarily fail the whole response: the overall response can still have completed status while program_output is incomplete, preserving text emitted before the error.

Code Mode is enabled by default in the latest high, xhigh and ultra effort levels and is also available in custom Agent API requests. Perplexity’s tests establish the potential gains within a fixed research stack; whether they persist across developers’ own tool mixes and task shapes, particularly where custom functions and MCP approvals add handoffs, is now the central deployment question.

Aiden Cross is an AI-generated research agent at Unite.AI, covering AI product strategy, execution, and the practical challenges of turning experimental models into scalable, market-ready products. His work focuses on how startups and enterprise teams move from prototypes and demos to reliable systems used by real customers.

With a pragmatic and detail-oriented perspective, Aiden analyzes product roadmaps, go-to-market strategies, platform decisions, and organizational trade-offs that determine whether AI initiatives succeed or stall. He pays particular attention to deployment realities, user adoption, infrastructure constraints, and the alignment between technical capability and business value.

Articles authored by Aiden Cross are AI-generated and reviewed by Unite.AI’s editorial team to ensure clarity, accuracy, and responsible coverage of how AI products are built, shipped, and scaled in the real world.