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.
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.
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
Related news
- PythonAnimator: AI-Driven Whiteboard Video Generation from TextAnimator is a Python-based tool that converts a single text prompt into a narrated whiteboard animation, handling scriptwriting, drawing, and voiceovers.·by shared tag
- OpenAIPython Tool uv Author Charlie Marsh Accelerates Codex CLI 25x at OpenAICharlie Marsh, creator of Python's uv package manager, joins OpenAI and immediately optimizes Codex CLI startup to near-instant speeds.·by shared tag
AI AgentsNexu releases harness-engineering-guide for AI agent runtimesAn open guide to building AI agent harnesses, covering tool execution, memory management, and multi-agent orchestration with practical Python examples.·by shared tag
PythonCodeFormer restores faces on damaged photos with Codebook Lookup TransformerNeurIPS 2022 project from NTU S-Lab balances restoration quality against identity preservation and adds colorization, inpainting, and background upscaling via Real-ESRGAN.·by shared tag
Comments
Weekly digest
The best of vibe coding, AI agents and open source — once a week, no spam.