Perplexity turns agent search into Python orchestration with SaC

Agentic search is becoming too complex for a single fixed search call. Perplexity posted on June 1, 2026 that it is introducing Search as Code, a search architecture where agents generate Python to compose the search stack directly. The key phrase in the tweet was “writes Python that calls our search stack directly.”

“Available in the Perplexity Agent API”

The official Perplexity account often mixes product changes with research notes, and this one came with a detailed technical article. Perplexity says Search as Code is now available in the Agent API and default in Computer. Instead of forcing models to loop through function calls or MCP-style interfaces, it exposes search components as SDK primitives: retrieval, ranking, filtering, fanouts, rendering, and access to intermediate state. A model then writes Python inside a secure sandbox to build a task-specific retrieval pipeline.

The concrete claim is the CVE vendor advisory case study. The task asked an agent to identify and characterize more than 200 high-severity CVEs from 2023 through 2025, citing vendor-authored advisories and tying each CVE to a product and fix version. Perplexity says Search as Code reached 100% accuracy while cutting token usage from 288.7K to 42.9K, an 85.1% reduction versus the non-SaC baseline. The company also says its Agent API leads the next-best evaluated system by 2.5x on WANDR, with gains of +19.77 percentage points on DSQA and +12.00 percentage points on WANDR versus a more traditional Perplexity search pipeline.

What to watch next is portability. Search as Code depends on several pieces working together: a model that can write useful code, hardened sandboxes, an Agentic Search SDK, and Perplexity’s own search infrastructure. Independent tests will need to separate architecture gains from index and ranking advantages. Still, the direction is important: long-running research agents may need programmable retrieval systems, not only better models. Source: Perplexity on X · Search as Code article