Why Perplexity lets AI agents code their search workflows
Terminator AI search By What The Future Newsroom · June 7, 2026 · 4 min read

Why Perplexity lets AI agents code their search workflows

Perplexity's "Search as Code" lets models generate Python search workflows instead of relying only on fixed search APIs. The company says the approach improves precision, reduces token use, and performed strongly on complex CVE research tasks.

Perplexity is changing how AI agents search. Its new "Search as Code" architecture lets a model write a custom Python workflow for a research task, run that code in a secure sandbox, and use Perplexity's search backend through modular SDK functions.

“The story mildly leans Terminator because it gives AI agents more autonomous control over complex research workflows, though within a sandbox and for productivity gains.”Why it scores Terminator

The goal is straightforward: give the model more control over search strategy while keeping the context window cleaner. Perplexity says that can produce more precise results and lower token usage, especially when the task requires many searches rather than one simple lookup.

Why fixed search APIs can slow agents down

Most AI search workflows follow a familiar loop. The model writes a query, receives a list of results from a search API, reads those results, then decides what to search next. For a simple question, that can be enough.

For complex research, Perplexity argues that this pattern becomes a bottleneck. Search engines were designed around people scanning lists of links. An AI agent doing hundreds of searches in a few minutes needs a different kind of control.

In the standard setup, the agent can mostly change the search term. The rest of the pipeline is hidden behind the API. That means filtering, deduplication, ranking, and follow-up logic are not shaped directly by the model's plan for the task.

Perplexity's criticism is that this rigidity can fill the model's context window with irrelevant material. When too much weak evidence enters the context, the agent has less room for the information that actually matters.

How Search as Code changes the workflow

"Search as Code" replaces the fixed call-and-response pattern with code written by the model. Instead of asking a search API for a standard result set, the model writes a Python script that defines the search process for the specific job.

That script runs in a secure sandbox and connects to Perplexity's search backend. The lower-level search operations are exposed through the "Agentic Search SDK," which breaks the search engine into functions the model can combine.

Perplexity describes the architecture in three layers:

  • Model: understands the research goal and decides the search strategy.
  • Sandbox: runs the generated Python code in a controlled environment.
  • Agentic Search SDK: provides functions for retrieving, filtering, deduplicating, and reranking results.

Standard search APIs remain available for quick questions. The difference is that harder research tasks can use a more flexible path. A model can run parallel queries, filter out weak results programmatically, and keep only relevant hits in its context window.

The CVE test shows the intended use case

Perplexity tested the approach on a cybersecurity research task involving 200 critical software vulnerabilities (CVEs) published between 2023 and 2025. For each CVE, the agent had to identify the official vendor advisory, the affected software, and the exact version that fixed the issue.

The test was designed to be strict. News articles and blog posts were not accepted. The agent needed official vendor information, which makes the task more demanding than simply finding a page that mentions the vulnerability.

With SaC, the model produced a three-stage script. First, it ran parallel searches tuned to how vendors such as Mozilla or Google format security bulletins. Then it reviewed its own findings, identified missing pieces, and launched targeted follow-up queries. Finally, it used a schema to check that the CVE, product, and fix version matched.

Perplexity says the agent completed the task while using 85 percent fewer tokens than its standard pipeline. The company also says competing systems got less than a quarter of the data right.

The company further claims SaC beat rivals including OpenAI's Responses API and Anthropic's Managed Agents on four out of five benchmarks. The largest difference appeared on "WANDR," Perplexity's own benchmark for broad research tasks, which it plans to release soon.

What this says about agent design

The larger point is not just search. Perplexity frames SaC as part of a shift toward code as the operational layer for agents. In that view, the model handles strategy, while deterministic runtimes handle repeatable work such as batching, filtering, and verification.

This matters because current AI search agents can struggle to prove that they are actually using live search well. The source article cites a recent study finding that popular search agents often cheat on benchmarks like BrowseComp by relying on training data and using search to confirm what they already know. On a newer benchmark with fresh facts, every system's score fell by 25 to 40 points.

Those systems were using standard search tools. Perplexity's argument is that agents need more than a search box: they need infrastructure that lets them control how evidence is gathered and checked.

A separate survey paper also points in this direction, describing code as a new operational layer for agents. It suggests that the surrounding systems of tools, sandboxes, and verification mechanisms are becoming a key bottleneck for autonomous systems.

Search as Code is rolling out now in Perplexity Computer and the Agent API. If the approach works beyond Perplexity's own benchmarks, it could make AI search less like asking for links and more like running a task-specific research pipeline.

← Back to the wire

Read next