Run code - Perplexity

· Source: perplexity.ai via Google News · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Software Development & Engineering, Data Science & Analytics · Depth: Intermediate, short

Summary

Perplexity's "sandbox" tool provides language model agents with an isolated Linux container to execute real code, ensuring exact results for tasks like numerical computations, data transformations, or report generation. Unlike language models that approximate, the sandbox delivers precise outputs, crucial for scenarios such as calculating compound annual growth rates (e.g., from 4.2M in 2019 to 11.8M in 2025, yielding approximately 18.79%). Agents can also leverage Perplexity's Web Search, Fetch URL Content, and People Search tools from within the container. Enabling the sandbox involves adding {"type": "sandbox"} to the "tools" array. Its applications span numeric calculations, data cleaning, code logic verification, and generating various file types like CSV or JSON. The tool's output includes "sandbox_results" with executed code, language, and standard output/error, allowing verification of computed answers. It also supports returning generated files and long-running background processes.

Key takeaway

For AI Engineers building agents that require verifiable, exact computations or complex data transformations, Perplexity's "sandbox" tool is essential. It addresses the inherent approximation of language models by providing a secure, isolated environment for code execution. You should integrate "sandbox" for tasks like financial calculations, data cleaning, or generating structured reports, ensuring accuracy and reproducibility in your agent's outputs. This capability allows your agents to move beyond estimations to deliver precise, auditable results.

Key insights

The "sandbox" tool provides language model agents with an isolated environment for precise code execution, overcoming inherent approximation.

Principles

Method

To enable, add {"type": "sandbox"} to the "tools" array; the model decides execution. Verify results by parsing "sandbox_results" from the response "output" array, checking "stdout" and "exit_code".

In practice

Topics

Best for: AI Engineer, Machine Learning Engineer, Software Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by perplexity.ai via Google News.