Perplexity Agent API adds Code Mode
Perplexity's new programmatic_tool_calling feature lets models write short JavaScript scripts executed in an embedded QuickJS WebAssembly runtime instead of calling tools one JSON turn at a time. Scripts can fan out web, finance, sandbox, MCP, and custom function calls in parallel and filter raw payloads locally, cutting WANDR research benchmark costs by up to 53% while avoiding context bloat.
Sequential JSON tool calling is rapidly becoming a legacy pattern as Cloudflare, Anthropic, and now Perplexity converge on code-as-orchestration. Letting models write short scripts to batch, branch, and trim tool payloads treats LLMs like engineers instead of expensive chat-loop routers.
- –Runs inside an embedded QuickJS WebAssembly runtime directly in the agent loop—eliminating the container boot overhead of Perplexity's earlier Python-based Search as Code approach—while sandboxing away module imports, fetch, and cross-program state.
- –Supports parallel fan-out via Promise.all across built-in search, finance, and sandbox tools, MCP servers, and custom functions (which pause execution for client-side return via caller IDs), with background execution returning partial output after 10 seconds to cut WANDR p95 duration by 40.9%.
- –Enabled by default on the updated xhigh and ultra effort presets (xhigh@2026-12-01.0 and ultra@2026-12-01.0), though developers wiring custom POST /v1/agent requests must use raw HTTP for now because Python SDK v0.50.0 and TypeScript SDK v0.45.0 lack Code Mode types.
- –Early integration gotchas to watch: programmatic-only MCP tools requiring approval return HTTP 400 unless defer_loading is enabled, and self-managed conversation history requires echoing back untouched program fingerprints.
- –Perplexity's ablations explain why this architecture only recently crossed the reliability threshold—earlier models scored worse and spent more recovering from syntax errors, tying code-driven tool orchestration directly to frontier model coding quality.
DISCOVERED
2h ago
2026-12-03
PUBLISHED
2h ago
2026-12-03
RELEVANCE
AUTHOR
AravSrinivas