Search as Code: Perplexity Is Right About the Future — Just Not First to It

TL;DR

Perplexity Research published a June 1 proposal for Search as Code, a system in which AI agents write code to assemble custom search workflows from smaller retrieval primitives. The approach is a real engineering bet, but its core pattern follows earlier work on code-driven agents rather than starting a wholly new category.

Perplexity Research on June 1 published a proposal called Search as Code, arguing that AI agents should generate code to build task-specific search pipelines instead of repeatedly calling a fixed search endpoint, a shift that could affect how agent products retrieve, filter and verify web information.

The confirmed event is Perplexity’s publication of a research piece titled Rethinking Search as Code Generation. The company describes Search as Code as a move away from monolithic search, where a model sends query parameters to one fixed pipeline and receives a full result set, toward a programmable model in which an agent composes retrieval, ranking, filtering, fan-out and verification steps inside a sandbox.

Perplexity says the old search contract breaks down for long-running agent tasks that may require many retrieval operations. Its proposed setup has three main parts: the model acts as the control plane, generated code runs in a secure execution environment with state across turns, and an Agentic Search SDK supplies the search primitives the model can combine.

The strongest performance claims come from Perplexity’s own tests. In a CVE case study, the company reports that Search as Code reached 100% accuracy while reducing token use by 85%, from 288.7K tokens to 42.9K. Perplexity also says rival systems in that test scored below 25%, and that Search as Code led on four of five broader benchmarks while tying OpenAI on the fifth. Those figures are company-reported and have not been independently replicated in the supplied material.

AI Dispatch · Infrastructure

Search as Code

Perplexity says agents shouldn’t call a search engine — they should program one, composing atomic primitives into a bespoke pipeline in a sandbox. The thesis is right. It’s also the search-shaped version of an idea the field has been converging on since 2024.

■ The old contract
One fixed pipeline. The model tweaks query params and consumes whatever comes back — through the context window, every time.
model → query(params)
engine → fixed pipeline
return → full result set
repeat ×N serial round-trips
⚠ every intermediate result routed through model context
▲ Search as Code
Amazon

search engine API development kit

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Amazon

search pipeline programming SDK

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Programmable primitives

The model writes code that orchestrates atomic search ops — fan-out, dedupe, verify — keeping bulk data out of the token stream.
sdk.search.web_many(queries)
filter()
dedupe()
sdk.llm.extract_many(schema)
verified records
✓ only the useful tokens reach the model
100%
CVE case-study accuracy (SaC run)
−85%
Token use vs baseline 288.7K → 42.9K
<25%
Score for the rival systems tested
2.5×
SaC lead on Perplexity’s own WANDR bench
A convergent idea, not a cold start
“Let the model write code instead of emitting tool calls” has been building for two years. SaC is the search-specific instantiation.
2024
CodeAct
Wang et al. · ICML
2024–25
smolagents
Hugging Face
2025
Code Mode
Cloudflare
Nov 2025
Code exec + MCP
Anthropic
Jun 2026
Search as Code
Perplexity
The take

Directionally right, genuinely engineered — the rebuilt-from-atoms search stack is the part rivals can’t cheaply copy. But it’s a strong execution of an industry-wide idea, validated mostly on benchmarks Perplexity ran itself. The moat is the infrastructure and the tuning loops, not the architecture.

Sources: Perplexity Research, “Rethinking Search as Code Generation” (Jun 1 2026); CodeAct (Wang et al., ICML 2024); HF smolagents; Cloudflare Code Mode; Anthropic “Code execution with MCP” (Nov 2025). Figures as reported by Perplexity.
thorstenmeyerai.com
Amazon

search primitives API development kit

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Agents Get Programmable Retrieval

The proposal matters because search is becoming part of how AI agents perform work, not just how humans find pages. If an agent can write a retrieval program for each task, it may reduce wasted tokens, preserve more useful evidence and run checks before sending material back into the model’s context window.

The competitive question is different from the technical one. The idea of models writing code to coordinate tools has been building across the field since at least 2024. Perplexity’s stronger claim is execution: rebuilding search into smaller, composable parts and tuning the loop around agent behavior. That infrastructure may be harder to copy than the general architecture.

Perplexity AI, A Practical Guide to Powered Research: Smart Search, Workflow Automation, and Knowledge Discovery in 2026 (The Practical Guide to Modern AI Tools)

Perplexity AI, A Practical Guide to Powered Research: Smart Search, Workflow Automation, and Knowledge Discovery in 2026 (The Practical Guide to Modern AI Tools)

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Earlier Code-Driven Agent Work

The supplied analysis places Search as Code in a broader pattern rather than treating it as a sudden break. CodeAct, presented at ICML 2024, explored agents acting through generated code. Hugging Face’s smolagents work in 2024 and 2025 also leaned into code as a practical interface for agent actions.

Other recent examples cited in the source material include Cloudflare’s Code Mode and Anthropic’s work around code execution with MCP. Search as Code applies that direction to search itself: the model does not only call a tool, but writes a small program that decides how search operations should be combined for the task at hand.

“Search as Code”

— Perplexity Research

National Geographic 4-Cylinder Engine Building Kit – 175+ Piece Working Model with Moving Parts, Clear Visible Engine Model, STEM Building Toy with Tools & Learning Guide for Kids

National Geographic 4-Cylinder Engine Building Kit – 175+ Piece Working Model with Moving Parts, Clear Visible Engine Model, STEM Building Toy with Tools & Learning Guide for Kids

BUILD YOUR OWN ENGINE – Assemble a clear 4-cylinder engine model kit with 175+ durable pieces. A fun…

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Independent Tests Are Still Missing

It is not yet clear how Search as Code performs outside Perplexity’s reported evaluations, how reproducible the benchmark results are, or how much of the gain comes from the architecture versus Perplexity’s own search stack, data access and tuning. The supplied material also does not establish whether Perplexity will productize the system broadly, license it to developers, or keep it mainly as internal infrastructure.

Replication Will Set The Stakes

The next milestone is outside testing. Developers, researchers and competing search providers will be watching whether the reported gains hold on independent tasks, especially workloads that need evidence gathering, source verification and repeated retrieval at scale. Product adoption will also show whether programmable search becomes a standard agent layer or remains a specialized implementation inside Perplexity’s stack.

Key Questions

What did Perplexity announce?

Perplexity Research published a June 1, 2026 proposal for Search as Code, a method that lets AI agents write code to assemble search workflows from smaller primitives rather than making repeated calls to one fixed search endpoint.

Is Search as Code a brand-new idea?

The search-specific implementation appears new to Perplexity’s stack, but the broader pattern of agents using generated code to coordinate tools has earlier examples, including CodeAct, smolagents, Cloudflare Code Mode and Anthropic’s code execution work.

What results did Perplexity report?

Perplexity reports that Search as Code scored 100% accuracy in a CVE case study and reduced token use from 288.7K to 42.9K. It also says Search as Code led on four of five broader benchmarks and tied OpenAI on the fifth.

Why does token use matter here?

Lower token use can reduce cost and limit how much raw intermediate material enters a model’s context window. Perplexity’s claim is that code can keep bulk retrieval work outside the model until verified records are ready.

Are the benchmark claims settled?

No. The figures in the supplied material are reported by Perplexity. Independent replication, wider task coverage and side-by-side testing against other agent search systems remain open questions.

Source: Thorsten Meyer AI

Nothing in this article is financial or investment advice. Cryptocurrency and precious-metal investments carry significant risk — do your own research and consider a licensed advisor.
You May Also Like

OpenEuroLLM. The third path.

OpenEuroLLM, a pan-European project funded by €20.6M from the EU, faces significant compute challenges as it aims to develop multilingual open-source LLMs across 20 organizations.

Agentic Loop Failure Modes: A Production Taxonomy at the End of Year One

A comprehensive taxonomy of failure modes in production agentic systems after one year of deployment, highlighting detection, mitigation, and operational implications.

The $725 Billion Question: Hyperscaler Capex Q1 2026 and What the Earnings Don’t Answer

Big Four hyperscalers announce $725 billion AI infrastructure spending in Q1 2026, raising questions about the impact on revenues, GPUs, and future growth.

The Twelve Real Complaints About AI Tools in 2026 — A Reddit, Twitter, and GitHub Synthesis

A detailed report on the top twelve user complaints about AI tools in 2026, based on Reddit, Twitter, and GitHub discussions, highlighting real-world challenges.