The way AI agents interact with search has not fundamentally changed in years. A model fires a query, a search engine runs its fixed pipeline, the model reads the results. Repeat until done. It's serial, slow, and increasingly mismatched with what modern agents actually need.
Search is the primary way AI systems tap into real-world knowledge, but traditional search pipelines are increasingly outdated in the era of agents. Traditional search answers queries; today's agents complete tasks that can take on countless shapes. Perplexity is now taking a direct swing at that problem.
Perplexity is introducing Search as Code (SaC) as its new reference search architecture. It writes Python that calls the search stack directly, instead of looping through function calls one at a time. It's available in the Perplexity Agent API and is now default in Computer.
The Problem with Monolithic Search
Traditionally, AI systems have treated search as a monolith: an AI model issues a query, the search engine runs its predefined pipeline, and the model consumes the results as context. For the most part, this worked fine to address the needs of early AI users.
But agent workloads are different in kind, not just in scale. Within Perplexity Computer, single tasks have been seen invoking hundreds or even thousands of retrieval operations within a few minutes, a workflow that is impossible for humans but absolutely natural for agents. Forcing that volume through a sequential tool-calling loop creates latency, inflates token usage, and caps what agents can realistically accomplish.
These tasks require agents to define task-specific retrieval strategies directly within their harnesses. A fixed pipeline cannot do that. Code can.
How Search as Code Works
The core idea is to expose the components of the search stack as primitives within an SDK. For any request that needs search, a model assembles these primitives on-demand into a retrieval pipeline tailored to that specific request.
The three-layer architecture behind SaC breaks down like this:
- Models as the control plane. Models reason about the user's directive, decompose it into tasks, decide which retrieval and processing pipelines are needed for each task, and generate code to implement those pipelines.
- Compute sandboxes as deterministic runtime. Compute sandboxes provide deterministic compute through a secure code execution runtime, giving models a canvas to implement control flow, batching, retries, filtering, joining, aggregation, and other deterministic operations.
- The Agentic Search SDK as the I/O layer. The Agentic Search SDK exposes Perplexity's search stack as composable primitives. Importantly, this SDK is not a preexisting search API packaged as a library. Over the past few months, the engineering team has rearchitected the search stack into modular, composable primitives.







