Perplexity Lets AI Agents Write Their Own Search Code

Perplexity Lets AI Agents Write Their Own Search Code

By Markus Kasanmascheff
Publication Date: 2026-06-07 20:17:00

TL;DR

  • Architecture Launch: Perplexity has introduced Search as Code as AI-written Python search workflows for agent retrieval.
  • Search Mechanism: The system uses a model, restricted sandbox, and Agentic Search SDK to build retrieval pipelines.
  • Benchmark Caveat: Perplexity claims 100 percent software-vulnerability accuracy and 85.1 percent lower token use, pending outside validation.
  • Developer Test: Developers should compare rollout results against OpenAI, Exa, Parallel, Google, TinyFish, and Tavily alternatives.

Perplexity introduced Search as Code as a reference architecture for AI-written Python search workflows, following its 2025 real-time Search API. The new approach shifts the pitch from repeatedly calling a fixed endpoint to letting an agent build the retrieval steps a task needs.

Longer research jobs usually force agents into a query, read, refine, and query again loop. Search as Code moves more of that plan into code generated for the task. It exposes search components as software development kit primitives inside a restricted sandbox so an agent can retrieve candidates, filter pages, remove duplicates, and rerank results.

Perplexity says its CVE vendor-advisory task reached 100 percent accuracy while using 85.1 percent fewer tokens than its baseline. Because those figures come from the company’s own benchmark, developers still need outside runs before treating the accuracy and token savings as repeatable.

How Model-Written Search Workflows Run

Search as…