TL;DR
QUASAR is a new programming language designed specifically for "code actions"—programs written by Large Language Models (LLMs) to interact with external tools. By explicitly separating internal logic from external tool calls, QUASAR enables advanced features like automatic parallelization, batched security approvals, and uncertainty quantification that are nearly impossible to implement in standard Python.
What Problem Does This Paper Address?
Modern AI agents often solve complex tasks by writing code (usually Python) to call external APIs, databases, or sub-agents. While LLMs are proficient at writing Python, the language itself wasn't designed for autonomous agents.
General-purpose languages make it difficult to "look under the hood" during execution. For instance, if an agent needs to send five emails that require user approval, a standard Python script would stop and ask the user five separate times. Similarly, if an agent could call three different search engines at once, Python’s sequential nature often defaults to calling them one by one, increasing latency. Finally, standard code doesn't handle "hallucinations" well; if a tool returns an uncertain result, the program usually just picks the most likely one and moves on, potentially compounding errors.
Methods
The authors introduce QUASAR (QUick And Secure And Reliable), a language that distinguishes between internal code (pure logic, data manipulation) and external calls (actions that affect the world).
Key technical components include:
- Rewrite-Based Semantics: Instead of a traditional step-by-step interpreter, QUASAR uses rewrite rules. The interpreter looks at the whole program and "rewrites" parts of it as soon as the necessary data is available. This allows for opportunistic execution, where the program pushes forward on all possible branches simultaneously.
- Transpilation: Since LLMs haven't seen QUASAR before, the system lets the LLM write in a restricted subset of Python. A transpiler then converts this Python code into QUASAR's functional form (based on $\lambda$ calculus).
- Effect Annotations: External calls are annotated with their "effects" (e.g., resource access or uncertainty). The QUASAR interpreter uses these to implement three specific features:
- Access Control Batching: It identifies all "dispatchable" external calls and presents them to the user in a single batch for approval.
- Autoparallelization: It automatically runs independent tool calls in parallel threads without requiring the LLM to write complex multi-threading code.
- Conformal Semantics: It allows variables to hold sets of possible values. If a tool is uncertain, QUASAR can execute both branches of an
ifstatement and track the resulting set of possible outcomes, providing a mathematical guarantee on reliability.
Datasets
The researchers evaluated QUASAR across three distinct benchmarks:
- GQA: A visual question-answering dataset where agents write code to query image-processing modules.
- AgentDojo (AD): A benchmark for secure AI assistants, testing the agent's ability to handle tool calls safely.
- BrowseComp-Plus: A "deep research" dataset involving complex tasks that require integrating information across approximately 100 documents.
Key Insights and Ideas
- Transparency is Key: By forcing a separation between logic and side effects, the program becomes "transparent" to the interpreter. This allows the system to manage security and performance around the LLM's logic rather than relying on the LLM to be a perfect systems programmer.
- Batching Beats Fatigue: The "approval fatigue" that plagues human-in-the-loop systems can be mitigated by QUASAR’s ability to look ahead and group requests.
- Handling "Maybe": The implementation of conformal prediction (Figure 4) is a standout idea. Instead of the agent guessing if a drink is alcoholic, QUASAR allows the program to carry the uncertainty
{Alcoholic, Non-alcoholic}through the logic, only finalizing the answer if the evidence is statistically significant.
Key Results
- Efficiency: On the complex BrowseComp-Plus research tasks, QUASAR achieved a 93% speedup through autoparallelization and a 97% reduction in the number of times a user had to click "approve."
- Security: On standard benchmarks (GQA/AD), user interactions were reduced by roughly 26%, with some tasks seeing much higher reductions.
- Reliability: Using conformal semantics, the authors demonstrated they could maintain a target 10% error rate even when underlying models were uncertain.
- Compatibility: The transpilation process is effective; using multi-turn feedback, the system achieved execution success rates and accuracy comparable to unrestricted Python.
Limitations and Future Work
- Python Subset: Currently, the transpiler only supports a subset of Python. It lacks support for complex features like classes and inheritance, though the authors argue these are rarely needed for simple "code actions."
- Unstructured Data: Conformal prediction is currently easier to apply to discrete labels (like "yes/no") than to unstructured text outputs, which remains a challenge for future research.
- LLM Adherence: Smaller models sometimes struggle to stay within the supported Python subset, requiring either fine-tuning or multiple attempts to get the code right.
Summary updated