Scrapeless Wiki

What Is an AI Web Agent? – Definition and How It Works

Informational P1 what is an ai web agent

Learn what an AI web agent is, how the perceive-decide-act loop works, how agents differ from scrapers, and where they succeed and fail.

An AI web agent is a language model given tools that operate a browser or an API, plus a loop that lets it decide what to do next based on what it just saw. The defining feature is that the sequence of steps is chosen at run time rather than written in advance.

1. What Is an AI Web Agent?

An agent pursues a goal across multiple steps on the open web, rather than executing a fixed script.

  • Key idea: the path is decided during execution, so the same goal can be pursued on sites the author never inspected.
  • Mechanism: a loop of observe the page, choose an action, execute it, observe the result.
  • Goal: complete tasks stated as outcomes β€” "find current pricing for these five products" β€” instead of as steps.

Example of the Loop

goal:     "find the support email for this company"
step 1:   observe homepage β†’ decide: click "Contact"
step 2:   observe contact page β†’ decide: extract email
step 3:   validate β†’ return result

2. How the Agent Sees a Page

Perception is the design decision that shapes everything else.

Representation What it gives the model Cost
Raw HTML Complete, and mostly noise Very high token use
Cleaned text or Markdown Readable content, no structure for clicking Low
Accessibility tree Interactive elements with roles and labels Moderate, and directly actionable
Screenshot Visual layout, including canvas-rendered content Requires a vision model; coordinates must match the real viewport

The accessibility tree is the common default for agents that click and type, because every node it returns is something a browser can act on by reference rather than by pixel position.

3. How Agents Differ From Scrapers

Aspect Scraper Web agent
Path Fixed selectors and URLs Decided per run
Change tolerance Breaks when the DOM changes Often adapts
Cost per page Very low Model inference per step
Determinism Repeatable Varies between runs
Best fit One known site, high volume Many sites, low volume, or unknown layouts

For a site you will read a million times, a scraper is cheaper and more predictable. For a hundred sites you will read once each, an agent avoids writing a hundred parsers.

4. What Agents Need Underneath

  • A real browser environment, because much of the web renders client-side and requires JavaScript execution.
  • A durable session, so cookies and navigation state survive between steps.
  • Constrained actions, exposed as tools the application validates rather than arbitrary code execution.
  • Step and cost limits, since an unbounded loop can wander indefinitely.
  • Structured output, so a downstream system receives typed fields rather than prose.

5. Where Agents Fail

  • Long horizons. Error compounds across steps; a wrong turn at step three poisons everything after it.
  • Ambiguous pages. Cookie dialogs, interstitials, and modal overlays absorb steps that were meant for the task.
  • Prompt injection. Page content is untrusted input, and text on a page can attempt to redirect an agent. Actions must be authorised by the application, never by the page.
  • Cost. Each step is an inference call, so a task with twenty steps is not a cheap page fetch.

6. Real-World Examples

  • Cross-site research β€” gather one specific figure from thirty vendor sites that share no common layout.
  • Form-driven lookups β€” search an unfamiliar portal, submit a query, and read back the result.
  • Long-tail extraction β€” pull the same three fields from sites whose volume never justified a dedicated parser.
  • Regression checking β€” visit a flow after a release and report whether the expected steps still complete.

7. Summary

An AI web agent combines a language model, browser tools, and a decision loop to pursue goals on pages it has not seen before. It trades the cost and determinism of a scraper for tolerance of variation.

Use an agent where layouts are unknown or numerous, and a scraper where volume is high and the target is stable. Whichever is used, treat page content as untrusted and keep authorisation in the application rather than in the prompt.