Perplexity introduces Search as Code for agents

Perplexity launches a new search architecture where agents generate Python code to interact with the search stack, reducing latency and context window clutter.

cpaua2 min252
Perplexity introduces Search as Code for agents
photo_3238.jpgphoto_3239.jpgphoto_3240.jpgphoto_3241.jpgphoto_3242.jpg

Perplexity has released Search as Code, a new search architecture for agents that replaces traditional tool-calling cycles. Instead of step-by-step tool requests, the model generates Python code that interacts directly with the search stack via a sandbox. This system is now available in the Perplexity Agent API and serves as the default for Computer.

Efficiency gains over traditional tool calling

Perplexity states that standard tool calling suffers from high latency and requires manual execution flow management. It also tends to clutter the model's context window with intermediate data.

The Search as Code approach allows for the parallel execution of multiple search queries and the deduplication of results. It enables data filtering, merging, and the ranking of results before they are passed into the model's context.

Performance on search benchmarks

The architecture was tested across five benchmarks: DSQA, BrowseComp, HLE, WideSearch, and WANDR. The system either matched or outperformed competitors in all five tests.

On the DSQA benchmark, Search as Code achieved a score of 0.871, compared to 0.815 for the Anthropic solution. Additionally, the cost of executing tasks was nearly twice as low.

Sandbox environment and API implementation

The sandbox operates as an isolated Linux container where the model runs Python for computation and bash for shell commands. The container has network access, allowing the model to install required packages at runtime and reach external endpoints.

The environment includes a preinstalled Perplexity SDK, enabling the model to call Web Search, People Search, and Fetch URL Content directly from within the code. Multiple executions within a single response share the same container, preserving files and installed packages for multi-step workflows.

python
from perplexity import Perplexity

client = Perplexity()

response = client.responses.create(
model = "openai/gpt-5.6-sol" ,
input = "For 230+ qualifying high-severity CVEs (CVE-YYYY-NNNNN published 2023–2025, CVSS ≥ 7.0), find the canonical vendor security advisory URL per CVE and name the affected product and the advisory's stated fix version." ,
tools = [{ "type" : "sandbox" }, { "type" : "web_search" }],
max_steps = 10 ,
instructions = "Use the sandbox and web search to gather and verify the advisories before answering." ,
)

Sources

Sandbox - Perplexity

Share

Author

cpaua

VibeCode blog admin. Writing about vibe coding, AI and open source.

Related news

Comments

To leave a comment, log in
Loading...

Weekly digest

The best of vibe coding, AI agents and open source — once a week, no spam.