Skip to content

Web Agents Should Adopt a Compile-and-Execute ParadigmWeb Agents Should Adopt the Compile-and-Execute Paradigm

arXiv· arXiv:2605.14290· Julien Piet, Annabella Chow, Yiwei Hou, Muxi Lyu, Sylvie Venuto, Jinhao Zhu, Raluca Ada Popa, David WagnerUC BerkeleyIndexed by this site · 25 days ago· Originally publishedOpinion

Quick read

Other

Based on the paper PDF (AI-generated); refer to the original

The authors argue that Web agents should adopt compile-and-execute by default rather than ReAct; manual annotation shows that all 860 WebArena tasks are compatible with this architecture.

Questions
ReAct is the default architecture for Web agents, but web content naturally mixes inputs from multiple parties, and untrusted content enters the context when the model selects the next action, leaving a channel for prompt injection to directly control the agent's control flow.
Methods
Position paper: it argues that Web agents should adopt compile-and-execute by default—compile a task-specific program before seeing any runtime web content, then have a deterministic runtime execute it, so that untrusted content can only affect data values, with an optional isolated LLM subroutine to process data.
Experiments and results
Manual annotation of the 860 WebArena tasks shows: 81% can be completed by purely static programs, 19% require LLM subroutines, and 0 require runtime replanning; however, Postmill's native REST API supports only 33% of its 129 tasks, and the interface gap is the main obstacle.
Limitations and future work
The annotation is based on the assumption of fully trusted APIs and did not run agents for empirical testing; the authors note that Safe with Influence tasks are still subject to outcome manipulation, compilation has upfront costs, error handling must be written explicitly, and they list five research directions: interfaces, compilers, verification, fallback, and evaluation.
Experimental setupWebArena · Safe (%)、Safe+Influence (%) et al.
Threat model
Indirect prompt injection: the user gives the agent a benign task, and the attacker is a third party on the website (reviewer, seller, advertiser, etc.) who places the injection in content the agent may observe. There are two categories of goals: control-flow hijacking (hijacking the control flow to execute arbitrary actions) and outcome manipulation (not changing the task itself, but manipulating the task outcome). The model provider and the website owner are treated as trusted.
Benchmarks
WebArena
Metrics
Safe (%)Safe+Influence (%)Replan NeededCompatible (%)
AI summaryThe paper argues that web agents should adopt compile-and-execute by default rather than ReAct, to limit the influence of untrusted web content on the agent's control flow. After analyzing WebArena, the authors find that all tasks are compatible with compile-and-execute, of which 81% can be completed with pure static programs, without runtime calls to LLM subroutines. The idea is to determine the task-specific program before observing runtime web content and then execute it, so that untrusted data can only affect values or branches within the preset execution graph, and cannot redefine the task or make the model generate new actions at runtime. The authors consider the main obstacle to be that website tools need to map clearly to semantic actions with effects known before execution, whereas the meaning of browser tools such as click, type, and scroll depends on the page. The solution is to shift web interaction from clicking and typing to a typed interface of task-level operations, which is an infrastructure problem rather than a modeling problem, requiring typed, complete, auditable website APIs.

The paper argues that web agents should adopt compile-and-execute by default rather than ReAct, to limit the influence of untrusted web content on the agent's control flow. After analyzing WebArena, the authors find that all tasks are compatible with compile-and-execute, of which 81% can be completed with pure static programs, without runtime calls to LLM subroutines. The idea is to determine the task-specific program before observing runtime web content and then execute it, so that untrusted data can only affect values or branches within the preset execution graph, and cannot redefine the task or make the model generate new actions at runtime. The authors consider the main obstacle to be that website tools need to map clearly to semantic actions with effects known before execution, whereas the meaning of browser tools such as click, type, and scroll depends on the page. The solution is to shift web interaction from clicking and typing to a typed interface of task-level operations, which is an infrastructure problem rather than a modeling problem, requiring typed, complete, auditable website APIs.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    The authors argue that ReAct is not suitable as the default architecture for Web agents and advocate switching to compile-and-execute.

    Core problem: ReAct lets untrusted web content enter the context when the model selects the next action, leaving a channel for prompt injection to directly manipulate the agent's control flow; the authors argue that Web agents should switch to compile-and-execute by default.

    • Problem setting: web content naturally mixes inputs from multiple parties—seller descriptions, user reviews, ads, platform recommendations, hidden DOM nodes, etc. In the ReAct loop, this content is presented to the model exactly when it decides what to click, type, or submit, and the agent often acts with the user's login privileges (Section I).
    • Shortcomings of existing methods: the authors argue that improvements such as hierarchical planning and workflow memory improve task performance but do not separate untrusted content from action generation; model-side defenses and runtime monitoring only mitigate specific attacks and do not address the architectural flaw of "dynamic planning interleaved with untrusted observations" (Section II-B).
    • Core observation: the control flow of many web tasks is already determined in the user request and does not require runtime reactivity; what is missing is the infrastructure to expose website operations as typed APIs with predictable effects (Section I, VI).
    • Paper's claim: it proposes compile-and-execute—compile a task-specific program before execution, so that untrusted content can only affect data values and branches within the program and cannot let the model synthesize new actions at runtime; it also annotates WebArena tasks for feasibility and proposes a research agenda covering interfaces, compilers, and verification.
    • Threat model (Section II-A):
      • Attacker: a third party on the website, such as reviewers, sellers, advertisers, forum users; the model provider and the website owner are treated as trusted.
      • Goal one, control-flow hijacking: make the agent deviate from the user task to execute arbitrary actions, such as leaking data or transferring money.
      • Goal two, outcome manipulation: not changing the task itself, only affecting the task outcome, such as inducing the purchase of another brand's product.
      • Out of scope: ordinary false or misleading content that would also fool humans or non-AI programs.
  2. What related research exists?

    The paper positions its work along three lines: ReAct improvements, prompt injection attacks and defenses, and structured defenses.

    ReAct and its Web agent variants

    • ReAct (Yao et al., 2022) — a loop alternating reasoning and action, a common paradigm for Web agents; benchmarks such as WebArena (Zhou et al., 2023) show that even strong LLM agents struggle to match human end-to-end success rates.
    • Hierarchical planning and memory types: WebPilot (2025) combines task decomposition with local action search, Plan-and-Act (2025) separates a high-level Planner from an LLM Executor, and OpAgent further splits planning, visual grounding, and reflection; Agent Workflow Memory (2025) induces reusable workflows from historical trajectories, and AgentFold (2026) uses context folding to manage long histories.
    • The paper points out: the action generation in these works is still conditioned on the current observation, preserving a prompt injection channel — even if the high-level plan is fixed in advance, the LLM still decides how to execute each step when exposed to the live page.

    Attacks and benchmarks for indirect prompt injection

    • Greshake et al. (2023) first articulated indirect prompt injection; BIPIA (2025) and InjecAgent (2024) systematized benchmarks; subsequent benchmarks cover tool use and Web-oriented agents (AgentDojo 2024, ASB 2024, WASP 2025, WAInjectBench 2025, BrowseSafe 2025, etc.).
    • WebInject (2025) demonstrated that attacks based on real HTML and images are effective against Web agents.

    Defenses: hardening the reactive loop vs. structural constraints

    • Model-side defenses (StruQ 2024, SecAlign 2024, Jatmo 2024, etc.) train models to distinguish trusted instructions from low-trust content; another line of work adds runtime monitoring, detectors, or sandboxes to reactive agents (e.g., ceLLMate 2025). The authors argue these methods mitigate specific attacks but do not solve the architectural-level problem.
    • Structural defenses: CaMeL (2025) uses privileged/isolated LLMs to separate control and data flow, Fides (2025) performs information-flow label tracking, IPIGuard (2025) uses tool dependency graphs to constrain tool calls, and there are also MiniScope (2025) and Kolluri et al. (2026). The paper points out that they are evaluated in AgentDojo and target named application tools, and migrating to browser interaction requires an additional interface layer — the task-level semantics of click and scroll depend on the current page, and their effects cannot be determined at compile time from primitive signatures.
    • The dual-LLM design of Foerster et al. (2026) supports computer-use agents, but the isolated vision-language model grounds descriptions to screen coordinates, leaving a visual prompt injection surface; the authors advocate replacing runtime VLM coordinate selection with trusted named operations.

    Positioning: Beyond Browsing (2024) shows that adding website APIs to ReAct agents can improve benchmark performance; the authors' additional requirement is to commit the task as a program based on these interfaces before any untrusted runtime content is observed.

  3. How does the paper address this problem?

    Before execution, compile the task into a program based on trusted website APIs, execute deterministically at runtime, and treat untrusted content only as data.

    Overall approach: compile-and-execute—before seeing any runtime web content, the compiler compiles the user task into a task-specific program based on trusted website APIs; at runtime a deterministic interpreter executes the program, and untrusted content can only fill parameters, determine preset branches, and affect the outputs of isolated LLM subroutines, and cannot add actions or tools or trigger replanning (Section IV).

    Preprocessing: trusted website APIs

    • Interface requirements: APIs must be complete (covering all available actions for the corresponding role and workflow) and have stable, strongly typed input/output schemas; low-level click wrappers do not provide stable action semantics, and high-level wrappers may hide side effects; the authors state that the research challenge is to expose composable operations with clear preconditions and effects.
    • Two acquisition paths: the website directly provides a REST API or MCP interface (then wrapped as a site action interface); or the agent developer builds a client SDK—implementing each function with Playwright driving a headless browser or by directly sending URL requests, done once per site and redone when the website changes.
    • Trust issues of generative SDKs: SDK implementations and documentation are part of the trusted computing base; when an LLM assists in building the SDK, it is exposed to live third-party content and may have function bodies polluted by injection, so generated SDK code and documentation must be handwritten or verified (derived from trusted artifacts, static analysis, manual audit) before entering the trusted interface.

    Compilation and execution

    • Compilation artifact: a self-contained "recipe"—it can be a conventional program (e.g., Python, Rust) or a structured sequence of API calls with parameters, dependencies, and branch logic specified in advance; the control-flow graph is fixed before any website content is observed, and the artifact size grows with task logic rather than the number of runtime observations.
    • Compilation process: an iterative agent loop—retrieving API summaries, inspecting endpoint schemas, and validating intermediate versions with static type/syntax checkers and mock tests based on trusted synthetic inputs; it never touches untrusted website content throughout, and the program is fixed once compilation is complete.
    • Execution: a deterministic sandboxed interpreter executes the preset calls step by step, substituting runtime values into declared parameters; dynamic code execution such as eval and exec is disabled; no LLM decides which instruction or API to execute next.

    Expressiveness: LLM subroutines

    • Design: the compiler generates a deterministic program but may call quarantined LLM subroutines for local data transformations such as extraction, normalization, and classification; subroutines have no tool access and return data values only through declared output schemas, and their outputs are never interpreted as executable instructions.
    • Runtime enforcement: before binding, the interpreter validates each subroutine return value against the schema, and invalid outputs are rejected; validation constrains only form and does not guarantee semantic correctness—a subroutine may be poisoned by content and return a wrong classification, but it cannot induce new tool calls outside the program.
    • Trade-off: the authors state that this operating point lies on the safety/utility trade-off curve—a fully deterministic program is fully robust to prompt injection but has limited utility, while allowing arbitrary sub-agents falls back to the insecurity of ReAct.

    Task classification and feasibility evaluation method

    • Three categories (Section VI-A): Safe (pure static program, no LLM calls at runtime), Safe with Influence (requires isolated LLM subroutines to process data but control flow is fixed), Replan-Needed (control flow depends on instructions discovered only at runtime, not suitable for this architecture).
    • Annotation protocol: for the 860 WebArena tasks, assuming each website has a complete, typed, trusted API, judge whether a program can be written in advance based only on the user request and the API description; 6 annotators first annotated independently by website, then jointly reviewed all labels and discussed until consensus was reached; only feasibility was evaluated, and no agents were run.
  4. What experiments did the paper conduct?

    Manual annotation of 860 WebArena tasks: 81% can be completed with pure static programs, 19% require LLM subroutines, and 0 require replanning.

    Experimental setup

    • Nature: this is a position paper with no model experiments; the only empirical part is feasibility annotation of WebArena tasks (Section VI-B), explicitly "evaluating feasibility, not running agents on these tasks."
    • Objects: the 860 WebArena tasks, distributed across 6 simulated websites — OneStop (192), Wiki (23), Reddit (129), Map (128), GitLab (204), CMS (184) (Table I).
    • Protocol: assuming each website has a complete, typed, trusted API, determine whether the task control flow can be fixed in advance; 6 annotators, with each site's tasks first independently annotated by 1 person, then jointly reviewed by all and discussed to consensus.
    • Metrics: Safe (no runtime LLM), Safe with Influence (requires isolated LLM subroutines), Replan-Needed, Compatible (sum of the first two categories).
    • Supplementary investigation: an exploratory examination of WebArena interfaces (Section VI-C), including Postmill native REST API coverage; not a systematic experiment.

    Main results

    According to Table I (assuming fully trusted APIs, manual annotation rather than agent execution):

    Swipe horizontally to read the table

    WebsiteTasksSafe (%)Safe+Influence (%)Replan NeededCompatible
    OneStop192154 (80%)38 (20%)0100%
    Wiki232 (9%)21 (91%)0100%
    Reddit129106 (82%)23 (18%)0100%
    Map128101 (79%)27 (21%)0100%
    GitLab204185 (91%)19 (9%)0100%
    CMS184151 (82%)33 (18%)0100%
    Total860699 (81%)161 (19%)0100%
    • The authors state that 81% of tasks can be completed by purely static programs, and the remaining 19% require LLM subroutines for semantic interpretation, background knowledge grounding, or subjective matching (Table II gives examples of each category).
    • The authors state that no WebArena task inherently requires runtime replanning, and that the obstacle is the lack of website interfaces rather than the need for reactivity.
    • The authors emphasize that these numbers are upper bounds under the full-API assumption and do not mean that today's websites can run them directly.

    Gap between existing interfaces and the assumption (Section VI-C)

    • API coverage: WebArena's Postmill forum exposes only 16 REST APIs, supporting only 33% of its 129 tasks, even though under the full-API assumption all 129 tasks are compilable; although GitLab has hundreds of APIs, some tasks (such as generating an RSS token) can only go through the UI.
    • Discovery and documentation: the authors state that compilation requires two-stage API discovery (a compact summary first, then detailed schemas); deeply nested GraphQL queries instead make it hard for the compiler to identify valid operations; when documentation quality is insufficient, endpoints are unusable even if they exist (such as the SKU format in OneStopShop and the special request headers required by Postmill).
    • Cost of client SDKs: simulating user actions with Playwright can bypass missing APIs, but requires exploring the site in advance with a logged-in account, maintaining it as the UI changes, and exploring live sites introduces preprocessing-time injection risk into SDK construction.

    Error handling and residual risk analysis

    • Brittleness example: a compiled program can only handle intermediate conditions the compiler anticipated — when a search term is misspelled or the description lacks keywords, producing empty results, a ReAct agent would observe and retry with a broader query, whereas a compile-and-execute agent may search as-is and terminate early.
    • Suggested mitigations: multi-turn user interaction at compile time to clarify ambiguity; training or prompting models to generate code with explicit error recovery and retry logic; generating multiple candidate programs for idempotent tasks and selecting the best after execution (Section VI-C).
    • Residual risk: the authors state that Safe with Influence tasks remain exposed to outcome manipulation — adversarial content can affect variable binding or subroutine classification within the fixed execution graph, but the damage is bounded and cannot induce actions outside the program; misleading information without injection is an information integrity problem unrelated to the execution paradigm (Section VI-B Discussion).
  5. What are some points that can be further explored?

    The authors list five research directions — interfaces, compilers, validation, controlled fallback, and evaluation — and acknowledge multiple gaps with reality.

    Limitations and future directions noted by the authors

    • Residual outcome manipulation: Safe with Influence tasks remain exposed to outcome manipulation, where adversarial content can affect subroutine classification or variable binding; misleading information without injection requires content verification mechanisms independent of the execution paradigm (Section VI-B Discussion).
    • Upfront cost: compilation (API discovery, iterative validation, error recovery logic) consumes tokens and latency before any action is executed; site-level preprocessing is expensive and must be maintained as websites evolve (Section VII).
    • Scope of applicability: only supports tasks whose control flow can be determined before execution; too low a level of program abstraction is brittle, while too high a level hides information needed for execution; the authors consider ReAct better in three scenarios: highly dynamic websites, exploration-intensive tasks, and tasks spanning multiple unpreprocessed sites (Section VII).
    • Error handling: compiled programs cannot improvise in response to unexpected conditions and require explicit clarification, retry, and multi-candidate program mechanisms (Section VI-C).
    • Scaling SDK validation: making validation of generated SDKs scale across sites and survive website updates is described by the authors as still an open problem (Section IV-A).
    • Research agenda: interface standardization and automated validation of SDK generation, compiler design, static safety validation of generated programs and constraints on LLM subroutines, controlled fallback signals for safe recompilation on error, and extending WebArena with benchmarks that jointly measure safety/utility/efficiency (Section VII).

    Scope of experimental coverage

    • The only empirical component is manual feasibility annotation of the 860 WebArena tasks, covering 6 simulated websites; the annotation assumes fully trusted APIs and no agent was run (Section VI-B).
    • Annotation was performed independently by 6 annotators and then jointly reviewed to consensus; the paper does not report inter-annotator agreement values (Section VI-B).
    • The interface examination is exploratory: Postmill's 16 REST APIs cover 33% of its 129 tasks, and GitLab has tasks that can only be completed via the UI; the paper does not report API coverage numbers for other websites (Section VI-C).
    • The paper does not implement or evaluate a compile-and-execute system and does not report measured values for end-to-end success rate, token consumption, latency, or compilation cost (Sections I, VII).
    • The paper does not run any models and does not conduct experiments on attack success rate or defense effectiveness; the discussion of alternative approaches such as model-side defenses, runtime monitoring, and taint tracking is qualitative (Section VII).
  6. Summarize the main content of the paper

    Position paper: Web agents should compile before executing by default, and the WebArena annotation shows that all tasks are compatible with this architecture.

    A position paper from UC Berkeley arguing that Web agents should not adopt ReAct by default, but should adopt a compile-and-execute architecture by default.

    • Problem: web content mixes inputs from multiple parties such as sellers, reviewers, and ads; ReAct lets untrusted content enter the context when the model selects the next action, creating a channel for prompt injection to directly hijack the control flow; the authors distinguish two categories of attack goals—control-flow hijacking and outcome manipulation.
    • Method: before observing any runtime web content, the compiler compiles the task into a program based on trusted, typed website APIs; a deterministic sandboxed runtime executes it, and untrusted content can only fill parameters, determine preset branches, or affect isolated LLM subroutines (no tool access, outputs validated by schema), and cannot synthesize new actions. Trusted APIs can be provided by the website or served by a verified client SDK.
    • Feasibility evidence: manual annotation of the 860 WebArena tasks (assuming fully trusted APIs) shows that 81% can be completed with pure static programs, 19% require LLM subroutines, and 0 require runtime replanning, i.e., all are compatible with this architecture (Table I).
    • Gap to reality: Postmill's native REST API supports only 33% of its 129 tasks, and GitLab also has tasks that can only be completed through the UI; the authors therefore argue that the obstacle is the missing infrastructure of website interfaces, not that tasks require reactivity.
    • Costs and residual risks: compilation has upfront token and latency costs, programs are fragile to unexpected conditions, and Safe with Influence tasks are still subject to outcome manipulation; the authors consider ReAct more suitable for highly dynamic websites, exploratory tasks, and multi-site scenarios.
    • Conclusion: the authors propose a five-part research agenda of interfaces, compilers, verification, controlled fallback, and evaluation, with the goal of making compile-and-execute a practical default architecture for Web agents.

Related papers

Show 3 more papers
Read originalarxiv.org