@yibie: Search as Code: The Next Paradigm Shift in Search Architecture Perplexity just released a new architecture called Search as Code (SaC). Sounds like another marketing term, but after reading their research paper, I think this might be one of the most important architectural decisions in the AI infrastructure space for 2026.
Summary
Perplexity released a new architecture called Search as Code (SaC), which lets AI agents write Python code directly to orchestrate search pipelines, replacing traditional function calling. This enables more efficient and accurate searches, achieving superior results across multiple benchmarks.
View Cached Full Text
Cached at: 06/02/26, 03:42 PM
Search as Code: The Next Paradigm Shift in Search Architecture
Perplexity just released a new architecture called Search as Code (SaC). It sounds like yet another marketing term, but after reading their research paper, I believe this could be one of the most important architectural decisions in the AI infrastructure space of 2026.
One sentence for the core idea: An AI agent no longer calls a search API one at a time through function calling. Instead, it directly writes Python code to orchestrate the entire search pipeline.
1. The Problem: Function Calling Is a “Serial Bottleneck”
Traditional AI search architectures look like this:
Model issues query → Search engine runs a preset pipeline → Returns results → Model consumes results
↑_______________________________________________↓
Each search operation = one LLM inference round-trip
This architecture was sufficient when “a user asks one question and the AI searches once”. But when an agent needs to complete a complex task involving hundreds of retrievals, the problem becomes apparent. In Perplexity’s Computer product, a single task can trigger hundreds or even thousands of retrieval operations within minutes.
Each operation requires an LLM round-trip — this is the “serial bottleneck.” More specifically, the traditional architecture has three fatal flaws:
Coarse-grained context. If the model only needs a highly precise piece of information but is forced to use a “high-recall” search endpoint, the result is a flood of irrelevant information crammed into the context window, wasting tokens and diluting signal.
Inability to leverage domain knowledge. The model may know how to search — e.g., when to mix lexical and semantic signals, which sources to prioritize, how to aggregate results — based on its training data, Agent Skills, or memory. But traditional search APIs only expose query parameters; the model cannot put this knowledge into action.
Inefficient control flow + context pollution. Many search workflows are not linear — they require fan-out, parallelism, and deduplication. Implementing these with serial function calls is not only slow, but also dumps large amounts of intermediate state into the model context, leading to performance degradation and forcing frequent compaction.
2. The SaC Approach: Code Replaces Function Calls
Perplexity’s solution is to completely abandon function calling and MCP as the search interface. Not improving the existing approach, but swapping it for an entirely different paradigm:
Model writes Python code → Sandbox executes → Code directly calls atomic primitives of the Agentic Search SDK
↓
One LLM inference can orchestrate thousands of search operations
Three-layer architecture:
-
Model layer (control plane): Reasons about user intent, decomposes the task, decides which retrieval strategies are needed, and generates Python code to implement those strategies.
-
Compute sandbox (execution layer): Provides a secure code execution environment, handling deterministic operations like control flow, batching, retries, filtering, and aggregation.
-
Agentic Search SDK (primitive layer): Decomposes Perplexity’s search stack into composable atomic primitives — retrieval, ranking, filtering, fan-out, rendering, etc. It does not package a search API as a library; instead, it re-architects the entire search system as modular components.
Key difference: In SaC, the model no longer calls search. The model orchestrates search.
3. One Case Study Is Enough: CVE Vulnerability Analysis
Perplexity gives a concrete example in the paper. Task: Find 200+ high-severity CVEs from 2023–2025, each requiring a citation from the vendor’s own security advisory, including affected products, fixed versions, and proof that the fix version is related to a specific CVE.
SaC results:
- 100% accuracy
- Token consumption dropped from 288.7K to 42.9K — an 85.1% reduction
- All other tested systems (OpenAI, Anthropic, Exa, etc.) had accuracy below 25%
Why such a big difference? Because SaC let the model do three things that traditional architectures cannot:
Encode rules into the query plan. The generated code directly encodes the constraint “only vendor advisories” — NVD, MITRE, third-party aggregators are structurally excluded from the search.
Use LLM for intermediate planning. The code first summarizes which vendor-year combinations have yielded enough candidate pages, requests targeted query refinements, then validates each query before executing. This is not a hardcoded crawler; it is an agent defining search strategies via code at runtime.
Use code for result validation. The search sub‑routine finds seemingly relevant pages, but the task requires “the vendor’s original text must bind a CVE + an affected product + a fix version.” The code explicitly defines this schema, automatically deduplicates, rejects aggregator URLs, and discards weak version evidence until the record count is met.
4. Benchmarks: 2.5x Advantage
Perplexity compared SaC (using GPT 5.5 high reasoning) against OpenAI Responses API, Anthropic Managed Agents, Exa Agent, and Parallel Tasks on five benchmarks.
SaC won 4 out of 5 benchmarks. On the hardest benchmark, WANDR (simulating “broad research” professional tasks), SaC’s score was 2.5 times that of the runner-up.
The cost-performance frontier is even clearer: SaC’s low‑reasoning setting is cheaper than all non‑SaC systems while matching their performance; its medium‑reasoning setting outperforms all competitors below $1/task.
5. Three Deeper Insights
5.1 “Code as Orchestrator + Capability Filler”
SaC doesn’t just use code to call existing capabilities. When the search stack or SDK doesn’t have a native function for something, the model can dynamically implement it in the sandbox. For example, a complex regex — without native support, a traditional approach would fire an approximate query and filter noisy results in token space. SaC instead fans out with the SDK to collect a superset, deduplicates with code, then writes additional Python for exact filtering. Code simultaneously serves as “orchestrator of existing capabilities” and “manufacturer of missing capabilities.”
5.2 SDK Self-Evolves Through Autoresearch
Perplexity did not hand-design the SDK. They built an autoresearch loop that runs continuously for weeks, automatically proposing and validating SDK improvements — measuring latency, code generation quality, and task completion rate. This loop has already made numerous structural and aesthetic changes to the SDK, yielding significant gains across all dimensions.
This is a key meta-level signal: The tools for building AI primitives must themselves be AI‑native.
5.3 Minimalist Design of Agent Skills
Teaching the model to use a custom SDK is hard — the SDK is not in the pretraining data. Perplexity’s solution is carefully tuned Agent Skills with a root file under 2000 tokens. The focus is not on listing every function (the model can get those via runtime reflection), but on providing concise, generalizable guidelines and a few examples that teach the model how to compose those atomic primitives.
6. What This Means
Search as Code is the concrete application of the larger paradigm “code as orchestrator” to the search domain. We previously discussed how Claude Code’s dynamic workflow uses JS to orchestrate sub‑agents; today SaC shows the same principle applied to search infrastructure.
The common pattern:
| Old Paradigm | New Paradigm |
|---|---|
| Serial function calls | Parallel code orchestration |
| Preset pipeline | Runtime assembly |
| LLM calls API | LLM writes code, calls primitives |
| Context bloat | Intermediate state stays in sandbox |
| Human-designed interfaces | Autoresearch-evolved interfaces |
Every dimension points in the same direction: The next step for AI agents is not better function calling — it is to stop using function calling altogether.
Source: Perplexity Research, “Rethinking Search for Agents: Search as Code” (2026.06)
Benchmark data: DSQA, BrowseComp, HLE, WideSearch, WANDR
Word count: ~2800 words
Similar Articles
Rethinking Search as Code Generation (25 minute read)
Perplexity introduces Search as Code (SaC), a new architecture that atomizes search primitives for AI agents to compose via code, moving beyond traditional monolithic search pipelines to enable fine-grained control over retrieval.
@aigclink: An Agent-oriented code search tool: Semble. It uses natural language to search codebases and returns precise code snippets, saving 98% token consumption compared to grep+read. The method lets Agents use natural language to directly locate the most relevant lines of code, without guessing keywords or reading entire files. Speed: indexing a typical…
Semble is an Agent-oriented code search tool that supports natural language queries, accurately returns semantically complete code snippets, saves 98% token consumption compared to traditional grep+read methods, and features intelligent chunking, dual-path retrieval, and code-aware re-ranking.
@Pluvio9yte: After integrating AnySearch, my agent's search efficiency improved. Tools like Parallel, Perplexity, and Tavily have a persistent issue when used by agents — they return links and summaries, so the agent still has to open pages, filter content, and assess relevance. For verticals like finance, academia, and code, search quality is even worse. Output lacks structure, and parsing content alone burns a lot of tokens.
AnySearch is a search infrastructure designed for AI agents. It supports real-time web search and vertical domain search, outputting structured Markdown that agents can directly use, improving search efficiency.
@NainsiDwiv50980: AI agents got smarter. Their way of understanding codebases didn't. Most still crawl through repositories file-by-file,…
A fully open-source codebase intelligence engine called SocratiCode helps AI navigate repositories using semantic search, dependency graphs, impact analysis, and shared indexes without vendor lock-in.
@Leechael: The second 'release' is pi-codex-search. Thanks to OpenAI for open-sourcing codex; I directly 'cloned' it and used it on the Pi. Whether using Pi TUI as a coding agent or a chat agent, codex search is probably still in a league of its own…
Released a search tool pi-codex-search based on OpenAI codex, used as a coding agent for Pi TUI.