[{"data":1,"prerenderedAt":3729},["ShallowReactive",2],{"/blog/headless-browsers-vs-live-sessions-for-customer-facing-ai-agents":3,"related-/blog/headless-browsers-vs-live-sessions-for-customer-facing-ai-agents":519},{"id":4,"title":5,"authorId":6,"body":7,"category":477,"created":478,"description":479,"extension":480,"faqs":481,"featurePriority":494,"head":495,"hideCta":496,"landingPath":495,"meta":497,"navigation":508,"ogImage":495,"path":509,"robots":495,"schemaOrg":495,"seo":510,"sitemap":511,"stem":512,"tags":513,"__hash__":518},"blog/blog/1047.headless-browsers-vs-live-sessions-for-customer-facing-ai-agents.md","Headless Browsers vs Live Sessions: Which Is Right for Customer-Facing AI Agents? (2026)","salome-koshadze",{"type":8,"value":9,"toc":460},"minimark",[10,14,17,43,46,49,58,63,66,69,73,76,80,83,86,89,93,98,105,108,134,138,143,146,172,176,179,182,208,214,218,221,224,235,238,241,245,248,251,255,299,303,306,332,336,340,343,369,373,376,379,457],[11,12,13],"p",{},"Customer-facing AI agents need more than text generation. They need to act in a browser, respond quickly enough for live conversation, and work inside the user's authenticated session.",[11,15,16],{},"That usually leads to two implementation models: run a headless browser on remote infrastructure, or run inside the user's live browser session. Both can work, but they solve different problems. Headless browsers are a good fit for background automation. Live sessions are often a better fit for customer-facing voice and support workflows, where latency, authentication, and visibility matter.",[18,19,21],"tldr-box",{"title":20},"Quick Summary",[22,23,24,32,38],"ul",{},[25,26,27,31],"li",{},[28,29,30],"strong",{},"Headless browsers"," are a strong fit for scraping, testing, and batch automation.",[25,33,34,37],{},[28,35,36],{},"Live sessions"," are a better fit when a user is already on the page and needs to see the agent act in real time.",[25,39,40],{},[28,41,42],{},"For voice agents, latency often decides the architecture.",[11,44,45],{},"The main challenge is not deciding what action to take. It is executing that action reliably in a modern web app. A model may produce the right form values, but the action can still fail if the target sits inside an unhydrated React Suspense boundary, an Angular component is still updating, a Salesforce Lightning element is hidden behind Shadow DOM, or a cookie banner blocks the click target.",[11,47,48],{},"Resolving the execution bottleneck forces engineering teams to choose an architecture. The choice dictates the latency profile, the security perimeter, and the integration complexity.",[50,51],"nuxt-picture",{":height":52,":width":53,"alt":54,"loading":55,"src":56,"provider":57},"450","800","Diagram showing an AI agent acting inside a user's live authenticated browser session","lazy","/blog/headless-browsers-vs-live-sessions-for-customer-facing-ai-agents/2.svg","none",[59,60,62],"h2",{"id":61},"evaluating-the-latency-budget","Evaluating the Latency Budget",[11,64,65],{},"Voice-driven interactions leave little room for delay. Natural conversation starts to feel broken once response times drift too high, and web automation has to fit inside that budget rather than sit on top of it.",[11,67,68],{},"Speech recognition, end-of-speech detection, LLM response time, and text-to-speech synthesis already consume most of the available time. In many systems, the full pipeline lands around 1,200 milliseconds before the browser action is even considered.",[50,70],{":height":52,":width":53,"alt":71,"loading":55,"src":72,"provider":57},"Diagram breaking down the voice AI latency budget across speech recognition, LLM, and text-to-speech stages","/blog/headless-browsers-vs-live-sessions-for-customer-facing-ai-agents/3.svg",[11,74,75],{},"Web automation approaches that add hundreds of milliseconds on top of this pipeline produce broken experiences. The execution layer cannot afford to add network round-trips for pixel streaming. The system must operate within the existing browser session to meet the strict timing constraints.",[59,77,79],{"id":78},"headless-browsers","Headless Browsers",[11,81,82],{},"Headless browsers provide a clean, isolated environment for task execution. A server starts a fresh Chromium instance, runs the task, and tears the environment down afterward. That model works well for testing, data extraction, and background automation, where isolation and repeatability matter more than immediacy.",[11,84,85],{},"The tradeoff is that the browser runs outside the user's active session. If the user is authenticated locally, the remote instance does not automatically share that state. To act on the user's behalf, the system usually has to copy session material such as cookies into the remote environment. In regulated settings, that can create governance and compliance concerns.",[11,87,88],{},"It also separates the action from what the user sees. If the remote browser clicks a button and opens a modal, the user does not see that directly unless the system streams screenshots or video back to the client. That extra transport layer adds latency and makes the experience feel slower.",[50,90],{":height":52,":width":53,"alt":91,"loading":55,"src":92,"provider":57},"Diagram showing a remote headless browser streaming screenshots back to the local client and the resulting latency","/blog/headless-browsers-vs-live-sessions-for-customer-facing-ai-agents/4.svg",[94,95,97],"h3",{"id":96},"playwright","Playwright",[50,99],{":height":100,":width":101,"alt":102,"loading":55,"src":103,"format":104},"600","1200","Playwright GitHub social preview","/blog/headless-browsers-vs-live-sessions-for-customer-facing-ai-agents/Playwrite.png","webp",[11,106,107],{},"Playwright is a browser automation framework that drives cross-browser execution for developers. Microsoft maintains this open-source project, which interacts with browsers through a bidirectional WebSocket connection. AI agents use Playwright to load pages, evaluate JavaScript, and extract content for LLM processing. The framework provides rich selectors and auto-waiting mechanisms out of the box.",[22,109,110,116,122,128],{},[25,111,112,115],{},[28,113,114],{},"Multi-page support:"," The API manages multiple browser contexts simultaneously, isolating cookies and local storage between individual execution runs.",[25,117,118,121],{},[28,119,120],{},"Network interception:"," Developers mock network requests or modify HTTP headers during execution to test edge cases and agent error handling.",[25,123,124,127],{},[28,125,126],{},"DOM traversal:"," Agents extract the accessibility tree using built-in methods to feed concise representations to LLMs, reducing overall token consumption.",[25,129,130,133],{},[28,131,132],{},"Trace viewer:"," The system captures execution logs, network payloads, and DOM snapshots to debug failed agent actions post-execution.",[94,135,137],{"id":136},"browserbase","Browserbase",[50,139],{":height":140,":width":141,"alt":137,"loading":55,"src":142},"1508","2880","/blog/headless-browsers-vs-live-sessions-for-customer-facing-ai-agents/browserbase.png",[11,144,145],{},"Browserbase is a serverless platform that hosts headless browsers for AI agents. The infrastructure manages the complexity of scaling browser instances, handling session timeouts, and dealing with bot mitigation systems. Agents connect to the service via standard automation protocols and receive a dedicated, clean execution environment. The platform abstracts away the DevOps burden of maintaining a fleet of Chrome containers.",[22,147,148,154,160,166],{},[25,149,150,153],{},[28,151,152],{},"Session persistence:"," The service keeps browser contexts alive across multiple LLM reasoning cycles to maintain active login states and shopping cart data.",[25,155,156,159],{},[28,157,158],{},"Proxy rotation:"," The infrastructure automatically routes traffic through different IP addresses to avoid rate limits on heavily guarded target domains.",[25,161,162,165],{},[28,163,164],{},"Stealth mode:"," The environment includes built-in configurations to bypass common anti-bot protections and advanced canvas fingerprinting checks.",[25,167,168,171],{},[28,169,170],{},"Debug viewing:"," Developers access a live video stream of the remote browser to monitor agent behavior during complex, multi-step execution workflows.",[94,173,175],{"id":174},"browserless","Browserless",[50,177],{":height":140,":width":141,"alt":175,"loading":55,"src":178},"/blog/headless-browsers-vs-live-sessions-for-customer-facing-ai-agents/Browserless.png",[11,180,181],{},"Browserless is a cloud infrastructure that provisions headless browser APIs for data scrapers. It operates as a managed service offering high-concurrency browser execution environments accessed via REST APIs or WebSocket connections. The platform focuses heavily on raw execution speed and throughput for background tasks. Teams use it to run thousands of parallel agent extraction jobs without managing server clusters.",[22,183,184,190,196,202],{},[25,185,186,189],{},[28,187,188],{},"GraphQL endpoints:"," The API supports structured queries for specific DOM elements, returning clean JSON payloads instead of raw, unparsed HTML.",[25,191,192,195],{},[28,193,194],{},"Concurrent execution:"," The infrastructure scales horizontally to handle massive parallel scraping jobs across geographically distributed worker nodes.",[25,197,198,201],{},[28,199,200],{},"Custom docker images:"," Engineers deploy customized browser binaries with specific Chrome extensions pre-loaded for highly specialized scraping tasks.",[25,203,204,207],{},[28,205,206],{},"Webhook integration:"," The system pushes extracted data back to the originating server once the autonomous agent completes the defined web task.",[209,210],"article-signup-cta",{"eyebrow":211,"heading":212,"highlight":213},"Headless browsers give your agent a copy of the web.","Webfuse gives it the live session.","live",[59,215,217],{"id":216},"live-sessions","Live Sessions",[11,219,220],{},"Live sessions run the execution layer inside the browser the customer is already using. The agent works in the same tab and uses the state that already exists there, including authentication, cookies, and local storage.",[11,222,223],{},"That changes a few practical things right away:",[22,225,226,229,232],{},[25,227,228],{},"The agent does not have to recreate the user's session on a remote server.",[25,230,231],{},"Actions appear directly in the page the user is already viewing.",[25,233,234],{},"Existing security controls and analytics stay in the same environment.",[11,236,237],{},"This is why live sessions fit real-time support and voice workflows well. When the agent fills a form or clicks a button, the result shows up immediately instead of being relayed back from a separate browser.",[11,239,240],{},"They can also be more reliable in complex JavaScript applications, where timing and page readiness often break browser automation.",[94,242,244],{"id":243},"webfuse","Webfuse",[50,246],{":height":140,":width":141,"alt":244,"loading":55,"src":247},"/blog/headless-browsers-vs-live-sessions-for-customer-facing-ai-agents/webfuse.png",[11,249,250],{},"Webfuse is a proxy-based execution layer that augments live sessions for enterprise AI platforms. The service acts as an on-demand reverse proxy that injects a virtualization layer into any target website without requiring infrastructure changes from the website owner. Voice agents and LLM orchestrators connect to the session via an MCP server or direct RPC WebSocket, receiving compressed DOM snapshots and issuing actuation commands. The execution happens inside the user's active browser, making it highly suitable for real-time customer support workflows where visual audit trails matter.",[50,252],{":height":52,":width":53,"alt":253,"loading":55,"src":254,"provider":57},"Diagram of the Webfuse proxy injecting a virtualization layer into a live web session for AI agent automation","/blog/headless-browsers-vs-live-sessions-for-customer-facing-ai-agents/6.svg",[22,256,257,268,281,287,293],{},[25,258,259,262,263,267],{},[28,260,261],{},"Cross-shadow targeting:"," The API penetrates Shadow DOM and iframe boundaries to interact with encapsulated components, allowing agents to click elements deep inside Salesforce Lightning interfaces using the ",[264,265,266],"code",{},"wf-id"," attribute.",[25,269,270,273,274,277,278,280],{},[28,271,272],{},"DOM downsampling:"," The ",[264,275,276],{},"applyAdaptiveD2Snap"," algorithm compresses a DOM snapshot to fit a target LLM token budget (around 32K tokens by default), retaining structure and the interactive elements agents target via ",[264,279,266],{},".",[25,282,283,286],{},[28,284,285],{},"Visual audit trails:"," The platform records every agent action and user interaction for strict compliance reporting, storing the output in WORM-compliant storage for financial services audits.",[25,288,289,292],{},[28,290,291],{},"Event simulation:"," Actuation commands fire the complete sequence of framework-level events, including hover and focus states, to satisfy strict React and Angular event listeners.",[25,294,295,298],{},[28,296,297],{},"PII redaction:"," The virtualization layer masks sensitive fields like credit card numbers on the client side before the DOM snapshot ever reaches the external LLM provider.",[94,300,302],{"id":301},"chrome-cdp","Chrome CDP",[11,304,305],{},"Chrome CDP is a protocol layer that exposes internal browser APIs for automation engineers. Connecting an agent to a local debugging port allows the system to drive an already active browser rather than booting a new, isolated container. This attachment method means the AI operates within the authenticated environment the user is actively viewing. Developers utilize this approach when they need granular control over a visible session without injecting external JavaScript libraries.",[22,307,308,314,320,326],{},[25,309,310,313],{},[28,311,312],{},"Active attachment:"," Agents connect directly to a running browser tab, sharing the live session, existing cookies, and local state without transferring credentials to a remote server.",[25,315,316,319],{},[28,317,318],{},"Raw input emulation:"," The protocol bypasses high-level JavaScript events by dispatching low-level input commands, simulating exact mouse coordinates and key presses within the user's window.",[25,321,322,325],{},[28,323,324],{},"Live DOM inspection:"," Engineers query the rendered document object model in real-time, giving agents immediate access to newly painted elements on the user's screen.",[25,327,328,331],{},[28,329,330],{},"Network monitoring:"," The system intercepts live HTTP requests, allowing the automation logic to pause execution until specific backend data finishes loading visually.",[94,333,335],{"id":334},"browser-use","Browser Use",[50,337],{":height":100,":width":101,"alt":338,"loading":55,"src":339,"format":104},"Browser Use GitHub social preview","/blog/headless-browsers-vs-live-sessions-for-customer-facing-ai-agents/browseruse.png",[11,341,342],{},"Browser Use is an open-source library that connects language models to local browsers for agent builders. The framework takes a goal-oriented approach, allowing the developer to pass a prompt and an LLM client, after which the library autonomously determines the required browser actions. It manages the translation between the model's text outputs and the Playwright Python commands required to drive the local Chrome instance. The project emphasizes simplicity, letting developers spin up an agent with minimal initial configuration.",[22,344,345,351,357,363],{},[25,346,347,350],{},[28,348,349],{},"Self-correcting execution:"," The agent evaluates the page state after each action, reading the new DOM to retry the command if the expected outcome fails.",[25,352,353,356],{},[28,354,355],{},"Multi-tab orchestration:"," The library manages workflows that span across several open browser tabs simultaneously, switching contexts to gather scattered data points.",[25,358,359,362],{},[28,360,361],{},"Vision capabilities:"," The system captures screenshots and annotates interactive elements with numeric bounding boxes to feed context to multimodal visual models.",[25,364,365,368],{},[28,366,367],{},"Extensible action space:"," Developers register custom Python functions as tools that the agent calls during its autonomous execution loop to interact with local databases.",[59,370,372],{"id":371},"choosing-between-the-two","Choosing Between the Two",[11,374,375],{},"Headless browsers are a strong fit for background automation: scraping, testing, scheduled tasks, and other workloads where no user is waiting on the screen. They are easy to isolate, easy to scale, and well suited to parallel execution.",[11,377,378],{},"Live sessions are a better fit when the agent needs to work inside a real user's active session. They keep authentication local, provide immediate visual feedback, and avoid the extra round-trips that make real-time interactions feel slow.",[380,381,382,398],"table",{},[383,384,385],"thead",{},[386,387,388,392,395],"tr",{},[389,390,391],"th",{},"Factor",[389,393,394],{},"Headless (remote)",[389,396,397],{},"Live session (in-browser)",[399,400,401,413,424,435,446],"tbody",{},[386,402,403,407,410],{},[404,405,406],"td",{},"Where it runs",[404,408,409],{},"Remote server",[404,411,412],{},"The user's own browser",[386,414,415,418,421],{},[404,416,417],{},"Authentication",[404,419,420],{},"Cookies copied to a remote instance",[404,422,423],{},"Inherited from the active session",[386,425,426,429,432],{},[404,427,428],{},"Visual feedback",[404,430,431],{},"Screenshot streaming",[404,433,434],{},"Native and immediate",[386,436,437,440,443],{},[404,438,439],{},"Latency",[404,441,442],{},"Adds network round-trips",[404,444,445],{},"Local execution",[386,447,448,451,454],{},[404,449,450],{},"Best fit",[404,452,453],{},"Scraping, testing, background jobs",[404,455,456],{},"Real-time customer support and voice",[11,458,459],{},"For voice agents, that last point matters most. The speech pipeline already consumes much of the response budget, so adding remote browser streaming usually pushes the interaction further out of range for natural conversation.",{"title":461,"searchDepth":462,"depth":462,"links":463},"",2,[464,465,471,476],{"id":61,"depth":462,"text":62},{"id":78,"depth":462,"text":79,"children":466},[467,469,470],{"id":96,"depth":468,"text":97},3,{"id":136,"depth":468,"text":137},{"id":174,"depth":468,"text":175},{"id":216,"depth":462,"text":217,"children":472},[473,474,475],{"id":243,"depth":468,"text":244},{"id":301,"depth":468,"text":302},{"id":334,"depth":468,"text":335},{"id":371,"depth":462,"text":372},"ai-agents","2026-06-29","Headless browsers run on remote servers; live sessions run inside the user's own browser. Compare both for customer-facing AI agents across latency, authentication, and governance.","md",[482,485,488,491],{"question":483,"answer":484},"What is the difference between a headless browser and a live session for AI agents?","A headless browser runs on a remote server in a fresh, isolated instance with no graphical interface. A live session runs inside the user's own browser, sharing the cookies, authentication, and page state the user already has open. Headless suits background jobs; live sessions suit customer-facing work.",{"question":486,"answer":487},"Why does latency matter for customer-facing AI agents?","Natural voice conversation has a budget of roughly 800 milliseconds end to end. The speech and language pipeline often uses most of that budget before any web action runs. A remote headless browser that streams screenshots back to the user adds network round-trips the budget cannot absorb, so the experience feels broken.",{"question":489,"answer":490},"Can a headless browser act inside a logged-in user session?","Only by copying the user's session cookies from the local browser into the remote instance. Moving credentials outside the local security perimeter raises compliance problems under frameworks like the EU Digital Operational Resilience Act (DORA). A live session avoids the transfer by acting where the user is already authenticated.",{"question":492,"answer":493},"Which approach suits real-time voice agents?","Live sessions. Running inside the active browser executes actions locally through JavaScript, removes the pixel-streaming round-trip, and shows the user each action as it happens, which keeps the interaction within the latency budget.",0,null,false,{"shortTitle":498,"relatedLinks":499},"Headless vs Live Sessions",[500,504],{"text":501,"href":502,"description":503},"Agent Browser vs Puppeteer & Playwright","/blog/agent-browser-vs-puppeteer-and-playwright","Compare browser automation approaches for AI agents and where agent-focused control changes the model.",{"text":505,"href":506,"description":507},"Browser Use vs Playwright: Which Is Better for AI Agent Control","/blog/browser-use-vs-playwright-which-is-better-for-ai-agent-control","A look at goal-directed agents against scripted automation for driving a browser.",true,"/blog/headless-browsers-vs-live-sessions-for-customer-facing-ai-agents",{"title":5,"description":479},{"loc":509},"blog/1047.headless-browsers-vs-live-sessions-for-customer-facing-ai-agents",[477,514,515,516,517],"web-agents","browser-automation","voice-ai","headless-browser","n_GODpEsT3i9lz8ua5YL2ypUMzlkFN77M_Pt7COV28I",[520,3236],{"id":521,"title":522,"authorId":523,"body":524,"category":477,"created":3217,"description":3218,"extension":480,"faqs":495,"featurePriority":495,"head":495,"hideCta":508,"landingPath":495,"meta":3219,"navigation":508,"ogImage":495,"path":3227,"robots":495,"schemaOrg":495,"seo":3228,"sitemap":3229,"stem":3230,"tags":3231,"__hash__":3235},"blog/blog/1013.serialising-web-ui-state-for-llms-the-complete-guide.md","Serialising Web UI State for LLMs: The Complete Guide","thassilo-schiepanski",{"type":8,"value":525,"toc":3200},[526,532,555,559,562,566,569,572,581,585,589,596,614,618,621,624,628,635,639,644,647,664,668,685,689,701,715,719,733,737,740,744,762,765,769,779,784,858,861,864,869,940,945,1064,1069,1178,1182,1193,1198,1500,1505,1659,1668,1672,1683,1688,1692,1696,1699,1702,1705,1813,1817,1820,1824,1827,1830,1835,2059,2064,2316,2321,2397,2402,2409,2418,2422,2425,2428,2431,2436,2445,2449,2789,2809,2862,2866,2869,2901,3050,3054,3057,3060,3064,3075,3078,3089,3095,3196],[11,527,528,529,280],{},"LLMs have become a core component of AI web browsing agents. Previously, automating a web journey required formal models of both web browsing and web-based user interfaces (UIs). An LLM can serve as a plug-in reasoning backend: given serialised web UI state, it is expected to suggest input actions that progress a specified web browsing task. Serialised UI state is, more ergonomically, referred to as a ",[28,530,531],{},"snapshot",[11,533,534,535,541,542,546,547,541,551,554],{},"Snapshots and action suggestions are the two key artefacts along the agent loop. Action suggestions are elicited from the web agent LLM backend. Suggestions can be acted out via automated web browser environments, such as ",[536,537,97],"a",{"href":538,"rel":539},"https://playwright.dev",[540],"nofollow"," or ",[536,543,244],{"href":544,"rel":545},"https://www.webfuse.com",[540],", for example, ",[548,549,550],"em",{},"clicking",[548,552,553],{},"typing",". The snapshot, on the other hand, is an artefact created by the agent harness, that is, the individual application component between the LLM and the web browser.",[50,556],{"src":557,":alt":558},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/1.svg","{\"Figurative depiction of two key artefacts along the agent loop\":\"the snapshot towards the LLM and the input action towards the browser\",\"provider\":\"none\",\"loading\":\"lazy\",\"width\":460}",[11,560,561],{},"Creating snapshots for LLMs is a central challenge of developing efficient web agents. It is a trade-off between representation utility – how well models can interpret the such encoded UI – and LLM token costs. Snapshots are the major cost factor of an agentic web journey, accumulated over multiple rounds of the loop.",[59,563,565],{"id":564},"gui-snapshots","GUI Snapshots",[11,567,568],{},"Screenshots, i.e., GUI snapshots, resemble what humans see when viewing a web page at a given point in time. Early LLM-based web agents were primarily premised on GUI snapshots because of this evident equivalence. By design, the GUI surfaces only the UI context designated to be visible to the user.",[11,570,571],{},"The document object model (DOM) is a web browser's model of a web application UI's runtime state. With few exceptions, the DOM is the single source of truth regarding the UI. Most snapshot representations are thus, technically speaking, derivatives of a raw DOM snapshot. For the cases not reflected in the DOM, GUI snapshots are a first-class base representation.",[11,573,574,575,580],{},"Rendering a GUI snapshot from the DOM is, moreover, non-trivial; no client-side library manages to create GUI snapshots in reasonable quality or time – ",[536,576,579],{"href":577,"rel":578},"https://html2canvas.hertzen.com",[540],"HTML2Canvas"," demonstrates the limits.",[50,582],{"src":583,"alt":584,"loading":55},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/2.png","The same web-based user interface serialised via browser-native screenshot API and the client-side library HTML2Canvas showing significant geometric differences",[94,586,588],{"id":587},"vision-based-targeting","Vision-Based Targeting",[11,590,591,592,595],{},"The snapshot representation dictates how elements can be targeted in the live UI. Unambiguous targeting based on a visual representation must be either geometric (absolute), e.g., via point coordinates, or semantic (relative), e.g., via cues, such as ",[548,593,594],{},"\"Button with Text 'Shop'\"",". On its own, semantic targeting introduces a circular problem: which element has this text?",[11,597,598,599,602,603,606,607,610,611,280],{},"Consider the web browsing task: ",[548,600,601],{},"\"Navigate to the Apple online shop\"",". In combination with an action, in this case ",[548,604,605],{},"click",", the agent could target the ",[548,608,609],{},"Shop"," button via a point coordinate, e.g., ",[264,612,613],{},"(725, 750)",[50,615],{"src":616,"alt":617,"loading":55},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/3.png","A GUI snapshot (screenshot) visualising point coordinate targeting",[11,619,620],{},"When the UI shifts between snapshot and action time, geometric targeting suggestions might have become obsolete.",[11,622,623],{},"Depending on the web browser environment, screenshots might be constrained to the GUI viewport. Scrolling is a secondary task that is imperative with viewport-contrained GUI snapshots.",[94,625,627],{"id":626},"the-problem-with-gui-snapshots","The Problem with GUI Snapshots",[11,629,630,631,634],{},"Image data is downsampled to make it economically viable as input to LLMs. It reduces LLM input tokens to a few thousand for real-world-representative full-page screenshots. A common downsampling approach is averaging ",[548,632,633],{},"n×n","-tiles of pixels, as known from image downscaling. Side effects are: pixel-precise targeting does not map back to the live UI, and small geometric features are not preserved (e.g., small labels). Downsampling effects can be accounted for under certain circumstances, e.g., by providing a snapshot format that downsamples to its identity. However, GUI aspect ratio and detail might be beyond the agent's control.",[50,636],{"src":637,"alt":638,"loading":55},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/4.png","A GUI snapshot (screenshot) compared to its figuratively downsampled counterpart",[640,641,643],"h4",{"id":642},"grounded-gui-snapshots","Grounded GUI Snapshots",[11,645,646],{},"Geometric targeting remains unreliable with certain models and responsive UIs. To rely on semantic targeting instead, the agent must link relevant elements in the live UI to semantics in the screenshot. Relevance usually equates with actionability, but ultimately depends on the snapshot's purpose.",[11,648,649,652,653,663],{},[548,650,651],{},"Set-of-Mark"," prompting is the go-to technique to create grounded GUI snapshots",[654,655,656],"sup",{},[536,657,662],{"href":658,"ariaDescribedBy":659,"dataFootnoteRef":461,"id":661},"#user-content-fn-1",[660],"footnote-label","user-content-fnref-1","1",". In this context, relevant elements are parsed from the live DOM and indexed with a unique numeric identifier. Each indexed element in the live UI is then enhanced with a coloured bounding box associated with the respective identifier.",[50,665],{"src":666,"alt":667,"loading":55},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/5.png","A GUI snapshot (screenshot) visualising grounded cue targeting",[11,669,670,676,677,280],{},[536,671,674],{"href":672,"rel":673},"https://browser-use.com",[540],[548,675,335],{}," agents implement Set-of-Mark-grounded GUI snapshots",[654,678,679],{},[536,680,684],{"href":681,"ariaDescribedBy":682,"dataFootnoteRef":461,"id":683},"#user-content-fn-2",[660],"user-content-fnref-2","2",[59,686,688],{"id":687},"dom-snapshots","DOM Snapshots",[11,690,691,692,700],{},"The DOM is parsed from HTML. In its latest state it can be serialised back to HTML – including all runtime mutations. Research has supported LLMs' capabilities to interpret HTML, and even to navigate such encoded UIs",[654,693,694],{},[536,695,699],{"href":696,"ariaDescribedBy":697,"dataFootnoteRef":461,"id":698},"#user-content-fn-3",[660],"user-content-fnref-3","3",". For that reason, DOM snapshots are a compelling alternative to GUI snapshots. LLMs excel at code generation and review, so these capabilities are no surprise.",[11,702,703,704,707,708,711,712,714],{},"Cross-origin ",[264,705,706],{},"iframe"," elements and ",[264,709,710],{},"canvas"," elements are exceptions to the DOM-is-source-of-truth assumption: ",[264,713,710],{},"-drawn GUI is not reflected in the DOM, nor are external, self-contained DOM subtrees if no explicit policy allows it. Structurally, both are leaves in the serialisable DOM tree.",[94,716,718],{"id":717},"dom-based-targeting","DOM-Based Targeting",[11,720,721,722,725,726,729,730,280],{},"Programmatically, DOM elements can be targeted by different relative means. CSS selectors abstract targeting with a standalone language. Whilst CSS selectors can resolve to more than one element in the DOM – compare semantics of the HTML ",[264,723,724],{},"class"," and ",[264,727,728],{},"id"," attributes – every element has at least one unique CSS selector, constructed from nth-child node paths, e.g., ",[264,731,732],{},"main .section:nth-child(2) > .row:nth-of-type(5) > form button",[50,734],{"src":735,"alt":736,"loading":55},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/6.png","A DOM snapshot (HTML) visualising CSS selector targeting",[11,738,739],{},"A raw DOM snapshot is complete, beyond the GUI that renders in the spatially limited browser viewport. For a human-like visual browsing experience, scrolling can be abstracted by an indirect scroll-target-into-view mechanism.",[94,741,743],{"id":742},"the-problem-with-dom-snapshots","The Problem with DOM Snapshots",[11,745,746,747,752,753,761],{},"DOM snapshots of real-world web pages may come at a size of several megabytes, which converts to millions of LLM input tokens – we estimate a raw snapshot of ",[536,748,751],{"href":749,"rel":750},"https://edition.cnn.com",[540],"cnn.com"," at around 1.5M tokens. At this size, DOM snapshots over-utilise the context window of many LLMs, or even exceed it (such as of ",[536,754,757,760],{"href":755,"rel":756},"https://openai.com/index/gpt-4o-system-card/",[540],[548,758,759],{},"GPT-4o"," (OpenAI)","). Ultimately, raw DOM snapshots out-cost GUI snapshots.",[11,763,764],{},"Using DOM snapshots with LLM-based web agents requires size-reducing transformations, similar to image downsampling implemented behind LLM APIs.",[640,766,768],{"id":767},"extracted-dom-snapshots","Extracted DOM Snapshots",[11,770,771,772,775,776,778],{},"The naïve approach to use information from the DOM as a snapshot is element extraction: relevant elements are copied from the live DOM to an initially empty virtual DOM. For small top-",[548,773,774],{},"k"," extractions – the ",[548,777,774],{}," highest-scoring elements – a snapshot of the virtual DOM comes at a fraction of the original DOM's size.",[11,780,781],{},[28,782,783],{},"Top-3 DOM Snapshot:",[785,786,790],"pre",{"className":787,"code":788,"language":789,"meta":461,"style":461},"language-html shiki shiki-themes github-dark github-dark","\u003Cbutton type=\"submit\">Submit\u003C/button>\n\u003Cbutton>More\u003C/button>\n\u003Ca href=\"/more\">Find out more\u003C/a>\n","html",[264,791,792,824,837],{"__ignoreMap":461},[793,794,797,801,805,809,812,816,819,821],"span",{"class":795,"line":796},"line",1,[793,798,800],{"class":799},"suv1-","\u003C",[793,802,804],{"class":803},"sxg3X","button",[793,806,808],{"class":807},"sFR8T"," type",[793,810,811],{"class":799},"=",[793,813,815],{"class":814},"s4wv1","\"submit\"",[793,817,818],{"class":799},">Submit\u003C/",[793,820,804],{"class":803},[793,822,823],{"class":799},">\n",[793,825,826,828,830,833,835],{"class":795,"line":462},[793,827,800],{"class":799},[793,829,804],{"class":803},[793,831,832],{"class":799},">More\u003C/",[793,834,804],{"class":803},[793,836,823],{"class":799},[793,838,839,841,843,846,848,851,854,856],{"class":795,"line":468},[793,840,800],{"class":799},[793,842,536],{"class":803},[793,844,845],{"class":807}," href",[793,847,811],{"class":799},[793,849,850],{"class":814},"\"/more\"",[793,852,853],{"class":799},">Find out more\u003C/",[793,855,536],{"class":803},[793,857,823],{"class":799},[11,859,860],{},"If done manually, element extraction presupposes correct assumptions about which elements and element properties count as relevant. Alternatively, element relevance scoring can be outsourced to an LLM, at the cost of another inference step.",[11,862,863],{},"Extraction disposes of deep DOM hierarchy, which might be salient to the web agent LLM backend. From the below extracted DOM snapshot alone, the original content relationship is lost:",[11,865,866],{},[28,867,868],{},"Extracted DOM Snapshot:",[785,870,872],{"className":787,"code":871,"language":789,"meta":461,"style":461},"\u003Cstrong>MacBook Air\u003C/strong>\n\u003Cbutton>Add to cart\u003C/button>\n\u003Cp>Out of stock\u003C/p>\n\u003Ch2>MacBook Pro\u003C/h2>\n\u003Cbutton>Add to cart\u003C/button>\n",[264,873,874,887,900,913,927],{"__ignoreMap":461},[793,875,876,878,880,883,885],{"class":795,"line":796},[793,877,800],{"class":799},[793,879,28],{"class":803},[793,881,882],{"class":799},">MacBook Air\u003C/",[793,884,28],{"class":803},[793,886,823],{"class":799},[793,888,889,891,893,896,898],{"class":795,"line":462},[793,890,800],{"class":799},[793,892,804],{"class":803},[793,894,895],{"class":799},">Add to cart\u003C/",[793,897,804],{"class":803},[793,899,823],{"class":799},[793,901,902,904,906,909,911],{"class":795,"line":468},[793,903,800],{"class":799},[793,905,11],{"class":803},[793,907,908],{"class":799},">Out of stock\u003C/",[793,910,11],{"class":803},[793,912,823],{"class":799},[793,914,916,918,920,923,925],{"class":795,"line":915},4,[793,917,800],{"class":799},[793,919,59],{"class":803},[793,921,922],{"class":799},">MacBook Pro\u003C/",[793,924,59],{"class":803},[793,926,823],{"class":799},[793,928,930,932,934,936,938],{"class":795,"line":929},5,[793,931,800],{"class":799},[793,933,804],{"class":803},[793,935,895],{"class":799},[793,937,804],{"class":803},[793,939,823],{"class":799},[11,941,942],{},[28,943,944],{},"Original DOM Snapshot – Candidate A:",[785,946,948],{"className":787,"code":947,"language":789,"meta":461,"style":461},"\u003Csection class=\"product\">\n  \u003Cstrong>MacBook Air\u003C/strong>\n  \u003Cbutton>Add to cart\u003C/button>\n  \u003Cp>Out of stock\u003C/p>  👈\n\u003C/section>\n\u003Csection class=\"product\">\n  \u003Cstrong>MacBook Pro\u003C/strong>\n  \u003Cbutton>Add to cart\u003C/button>\n\u003C/section>\n",[264,949,950,967,980,992,1005,1014,1029,1042,1055],{"__ignoreMap":461},[793,951,952,954,957,960,962,965],{"class":795,"line":796},[793,953,800],{"class":799},[793,955,956],{"class":803},"section",[793,958,959],{"class":807}," class",[793,961,811],{"class":799},[793,963,964],{"class":814},"\"product\"",[793,966,823],{"class":799},[793,968,969,972,974,976,978],{"class":795,"line":462},[793,970,971],{"class":799},"  \u003C",[793,973,28],{"class":803},[793,975,882],{"class":799},[793,977,28],{"class":803},[793,979,823],{"class":799},[793,981,982,984,986,988,990],{"class":795,"line":468},[793,983,971],{"class":799},[793,985,804],{"class":803},[793,987,895],{"class":799},[793,989,804],{"class":803},[793,991,823],{"class":799},[793,993,994,996,998,1000,1002],{"class":795,"line":915},[793,995,971],{"class":799},[793,997,11],{"class":803},[793,999,908],{"class":799},[793,1001,11],{"class":803},[793,1003,1004],{"class":799},">  👈\n",[793,1006,1007,1010,1012],{"class":795,"line":929},[793,1008,1009],{"class":799},"\u003C/",[793,1011,956],{"class":803},[793,1013,823],{"class":799},[793,1015,1017,1019,1021,1023,1025,1027],{"class":795,"line":1016},6,[793,1018,800],{"class":799},[793,1020,956],{"class":803},[793,1022,959],{"class":807},[793,1024,811],{"class":799},[793,1026,964],{"class":814},[793,1028,823],{"class":799},[793,1030,1032,1034,1036,1038,1040],{"class":795,"line":1031},7,[793,1033,971],{"class":799},[793,1035,28],{"class":803},[793,1037,922],{"class":799},[793,1039,28],{"class":803},[793,1041,823],{"class":799},[793,1043,1045,1047,1049,1051,1053],{"class":795,"line":1044},8,[793,1046,971],{"class":799},[793,1048,804],{"class":803},[793,1050,895],{"class":799},[793,1052,804],{"class":803},[793,1054,823],{"class":799},[793,1056,1058,1060,1062],{"class":795,"line":1057},9,[793,1059,1009],{"class":799},[793,1061,956],{"class":803},[793,1063,823],{"class":799},[11,1065,1066],{},[28,1067,1068],{},"Original DOM Snapshot – Candidate B:",[785,1070,1072],{"className":787,"code":1071,"language":789,"meta":461,"style":461},"\u003Csection class=\"product\">\n  \u003Cstrong>MacBook Air\u003C/strong>\n  \u003Cbutton>Add to cart\u003C/button>\n\u003C/section>\n\u003Csection class=\"product\">\n  \u003Cp>Out of stock\u003C/p>  👈\n  \u003Cstrong>MacBook Pro\u003C/strong>\n  \u003Cbutton>Add to cart\u003C/button>\n\u003C/section>\n",[264,1073,1074,1088,1100,1112,1120,1134,1146,1158,1170],{"__ignoreMap":461},[793,1075,1076,1078,1080,1082,1084,1086],{"class":795,"line":796},[793,1077,800],{"class":799},[793,1079,956],{"class":803},[793,1081,959],{"class":807},[793,1083,811],{"class":799},[793,1085,964],{"class":814},[793,1087,823],{"class":799},[793,1089,1090,1092,1094,1096,1098],{"class":795,"line":462},[793,1091,971],{"class":799},[793,1093,28],{"class":803},[793,1095,882],{"class":799},[793,1097,28],{"class":803},[793,1099,823],{"class":799},[793,1101,1102,1104,1106,1108,1110],{"class":795,"line":468},[793,1103,971],{"class":799},[793,1105,804],{"class":803},[793,1107,895],{"class":799},[793,1109,804],{"class":803},[793,1111,823],{"class":799},[793,1113,1114,1116,1118],{"class":795,"line":915},[793,1115,1009],{"class":799},[793,1117,956],{"class":803},[793,1119,823],{"class":799},[793,1121,1122,1124,1126,1128,1130,1132],{"class":795,"line":929},[793,1123,800],{"class":799},[793,1125,956],{"class":803},[793,1127,959],{"class":807},[793,1129,811],{"class":799},[793,1131,964],{"class":814},[793,1133,823],{"class":799},[793,1135,1136,1138,1140,1142,1144],{"class":795,"line":1016},[793,1137,971],{"class":799},[793,1139,11],{"class":803},[793,1141,908],{"class":799},[793,1143,11],{"class":803},[793,1145,1004],{"class":799},[793,1147,1148,1150,1152,1154,1156],{"class":795,"line":1031},[793,1149,971],{"class":799},[793,1151,28],{"class":803},[793,1153,922],{"class":799},[793,1155,28],{"class":803},[793,1157,823],{"class":799},[793,1159,1160,1162,1164,1166,1168],{"class":795,"line":1044},[793,1161,971],{"class":799},[793,1163,804],{"class":803},[793,1165,895],{"class":799},[793,1167,804],{"class":803},[793,1169,823],{"class":799},[793,1171,1172,1174,1176],{"class":795,"line":1057},[793,1173,1009],{"class":799},[793,1175,956],{"class":803},[793,1177,823],{"class":799},[640,1179,1181],{"id":1180},"downsampled-dom-snapshots","Downsampled DOM Snapshots",[11,1183,1184,1185,280],{},"Downsampling means reducing data point count whilst preserving the overall data shape and most of the relevant features. Picture an image being downsized: the depicted object remains recognisable to a large degree. The concept of image downsampling can be transferred to the DOM by locally 'averaging' DOM subtrees – trading fidelity for size",[654,1186,1187],{},[536,1188,1192],{"href":1189,"ariaDescribedBy":1190,"dataFootnoteRef":461,"id":1191},"#user-content-fn-4",[660],"user-content-fnref-4","4",[11,1194,1195],{},[28,1196,1197],{},"Original DOM Snapshot:",[785,1199,1201],{"className":787,"code":1200,"language":789,"meta":461,"style":461},"\u003Csection class=\"container\" tabindex=\"3\" required=\"true\" type=\"example\">\n  \u003Cdiv class=\"mx-auto\" data-topic=\"products\" required=\"false\">\n    \u003Ch1>Our Pizza\u003C/h1>\n    \u003Cdiv>\n      \u003Cdiv class=\"shadow-lg\">\n        \u003Ch2>Margherita\u003C/h2>\n        \u003Cp>\n         A simple classic: mozzarella, tomatoes and basil.\n         An everyday choice!\n        \u003C/p>\n        \u003Cbutton type=\"button\">Add\u003C/button>\n      \u003C/div>\n      \u003Cdiv class=\"shadow-lg\">\n        \u003Ch2>Capricciosa\u003C/h2>\n        \u003Cp>\n          A rich taste: mozzarella, ham, mushrooms, artichokes and olives.\n          A true favourite!\n        \u003C/p>\n        \u003Cbutton type=\"button\">Add\u003C/button>\n      \u003C/div>\n    \u003C/div>\n  \u003C/div>\n\u003C/section>\n",[264,1202,1203,1241,1272,1287,1295,1311,1325,1333,1338,1343,1353,1374,1384,1399,1413,1422,1428,1434,1443,1462,1471,1481,1491],{"__ignoreMap":461},[793,1204,1205,1207,1209,1211,1213,1216,1219,1221,1224,1227,1229,1232,1234,1236,1239],{"class":795,"line":796},[793,1206,800],{"class":799},[793,1208,956],{"class":803},[793,1210,959],{"class":807},[793,1212,811],{"class":799},[793,1214,1215],{"class":814},"\"container\"",[793,1217,1218],{"class":807}," tabindex",[793,1220,811],{"class":799},[793,1222,1223],{"class":814},"\"3\"",[793,1225,1226],{"class":807}," required",[793,1228,811],{"class":799},[793,1230,1231],{"class":814},"\"true\"",[793,1233,808],{"class":807},[793,1235,811],{"class":799},[793,1237,1238],{"class":814},"\"example\"",[793,1240,823],{"class":799},[793,1242,1243,1245,1248,1250,1252,1255,1258,1260,1263,1265,1267,1270],{"class":795,"line":462},[793,1244,971],{"class":799},[793,1246,1247],{"class":803},"div",[793,1249,959],{"class":807},[793,1251,811],{"class":799},[793,1253,1254],{"class":814},"\"mx-auto\"",[793,1256,1257],{"class":807}," data-topic",[793,1259,811],{"class":799},[793,1261,1262],{"class":814},"\"products\"",[793,1264,1226],{"class":807},[793,1266,811],{"class":799},[793,1268,1269],{"class":814},"\"false\"",[793,1271,823],{"class":799},[793,1273,1274,1277,1280,1283,1285],{"class":795,"line":468},[793,1275,1276],{"class":799},"    \u003C",[793,1278,1279],{"class":803},"h1",[793,1281,1282],{"class":799},">Our Pizza\u003C/",[793,1284,1279],{"class":803},[793,1286,823],{"class":799},[793,1288,1289,1291,1293],{"class":795,"line":915},[793,1290,1276],{"class":799},[793,1292,1247],{"class":803},[793,1294,823],{"class":799},[793,1296,1297,1300,1302,1304,1306,1309],{"class":795,"line":929},[793,1298,1299],{"class":799},"      \u003C",[793,1301,1247],{"class":803},[793,1303,959],{"class":807},[793,1305,811],{"class":799},[793,1307,1308],{"class":814},"\"shadow-lg\"",[793,1310,823],{"class":799},[793,1312,1313,1316,1318,1321,1323],{"class":795,"line":1016},[793,1314,1315],{"class":799},"        \u003C",[793,1317,59],{"class":803},[793,1319,1320],{"class":799},">Margherita\u003C/",[793,1322,59],{"class":803},[793,1324,823],{"class":799},[793,1326,1327,1329,1331],{"class":795,"line":1031},[793,1328,1315],{"class":799},[793,1330,11],{"class":803},[793,1332,823],{"class":799},[793,1334,1335],{"class":795,"line":1044},[793,1336,1337],{"class":799},"         A simple classic: mozzarella, tomatoes and basil.\n",[793,1339,1340],{"class":795,"line":1057},[793,1341,1342],{"class":799},"         An everyday choice!\n",[793,1344,1346,1349,1351],{"class":795,"line":1345},10,[793,1347,1348],{"class":799},"        \u003C/",[793,1350,11],{"class":803},[793,1352,823],{"class":799},[793,1354,1356,1358,1360,1362,1364,1367,1370,1372],{"class":795,"line":1355},11,[793,1357,1315],{"class":799},[793,1359,804],{"class":803},[793,1361,808],{"class":807},[793,1363,811],{"class":799},[793,1365,1366],{"class":814},"\"button\"",[793,1368,1369],{"class":799},">Add\u003C/",[793,1371,804],{"class":803},[793,1373,823],{"class":799},[793,1375,1377,1380,1382],{"class":795,"line":1376},12,[793,1378,1379],{"class":799},"      \u003C/",[793,1381,1247],{"class":803},[793,1383,823],{"class":799},[793,1385,1387,1389,1391,1393,1395,1397],{"class":795,"line":1386},13,[793,1388,1299],{"class":799},[793,1390,1247],{"class":803},[793,1392,959],{"class":807},[793,1394,811],{"class":799},[793,1396,1308],{"class":814},[793,1398,823],{"class":799},[793,1400,1402,1404,1406,1409,1411],{"class":795,"line":1401},14,[793,1403,1315],{"class":799},[793,1405,59],{"class":803},[793,1407,1408],{"class":799},">Capricciosa\u003C/",[793,1410,59],{"class":803},[793,1412,823],{"class":799},[793,1414,1416,1418,1420],{"class":795,"line":1415},15,[793,1417,1315],{"class":799},[793,1419,11],{"class":803},[793,1421,823],{"class":799},[793,1423,1425],{"class":795,"line":1424},16,[793,1426,1427],{"class":799},"          A rich taste: mozzarella, ham, mushrooms, artichokes and olives.\n",[793,1429,1431],{"class":795,"line":1430},17,[793,1432,1433],{"class":799},"          A true favourite!\n",[793,1435,1437,1439,1441],{"class":795,"line":1436},18,[793,1438,1348],{"class":799},[793,1440,11],{"class":803},[793,1442,823],{"class":799},[793,1444,1446,1448,1450,1452,1454,1456,1458,1460],{"class":795,"line":1445},19,[793,1447,1315],{"class":799},[793,1449,804],{"class":803},[793,1451,808],{"class":807},[793,1453,811],{"class":799},[793,1455,1366],{"class":814},[793,1457,1369],{"class":799},[793,1459,804],{"class":803},[793,1461,823],{"class":799},[793,1463,1465,1467,1469],{"class":795,"line":1464},20,[793,1466,1379],{"class":799},[793,1468,1247],{"class":803},[793,1470,823],{"class":799},[793,1472,1474,1477,1479],{"class":795,"line":1473},21,[793,1475,1476],{"class":799},"    \u003C/",[793,1478,1247],{"class":803},[793,1480,823],{"class":799},[793,1482,1484,1487,1489],{"class":795,"line":1483},22,[793,1485,1486],{"class":799},"  \u003C/",[793,1488,1247],{"class":803},[793,1490,823],{"class":799},[793,1492,1494,1496,1498],{"class":795,"line":1493},23,[793,1495,1009],{"class":799},[793,1497,956],{"class":803},[793,1499,823],{"class":799},[11,1501,1502],{},[28,1503,1504],{},"Downsampled DOM Snapshot:",[785,1506,1508],{"className":787,"code":1507,"language":789,"meta":461,"style":461},"\u003Csection class=\"container\" required=\"true\" type=\"example\">\n  \u003Cdiv class=\"mx-auto\" required=\"false\">\n    Our Pizza\n    \u003Cdiv>\n      Margherita\n      A simple classic: mozzarella, tomatoes and basil.\n      An everyday choice!\n      \u003Cbutton type=\"button\">Add\u003C/button>\n      Capricciosa\n      A rich taste: mozzarella, ham, mushrooms, artichokes and olives.\n      A true favourite!\n      \u003Cbutton type=\"button\">Add\u003C/button>\n    \u003C/div>\n  \u003C/div>\n\u003C/section>\n",[264,1509,1510,1536,1556,1561,1569,1574,1579,1584,1602,1607,1612,1617,1635,1643,1651],{"__ignoreMap":461},[793,1511,1512,1514,1516,1518,1520,1522,1524,1526,1528,1530,1532,1534],{"class":795,"line":796},[793,1513,800],{"class":799},[793,1515,956],{"class":803},[793,1517,959],{"class":807},[793,1519,811],{"class":799},[793,1521,1215],{"class":814},[793,1523,1226],{"class":807},[793,1525,811],{"class":799},[793,1527,1231],{"class":814},[793,1529,808],{"class":807},[793,1531,811],{"class":799},[793,1533,1238],{"class":814},[793,1535,823],{"class":799},[793,1537,1538,1540,1542,1544,1546,1548,1550,1552,1554],{"class":795,"line":462},[793,1539,971],{"class":799},[793,1541,1247],{"class":803},[793,1543,959],{"class":807},[793,1545,811],{"class":799},[793,1547,1254],{"class":814},[793,1549,1226],{"class":807},[793,1551,811],{"class":799},[793,1553,1269],{"class":814},[793,1555,823],{"class":799},[793,1557,1558],{"class":795,"line":468},[793,1559,1560],{"class":799},"    Our Pizza\n",[793,1562,1563,1565,1567],{"class":795,"line":915},[793,1564,1276],{"class":799},[793,1566,1247],{"class":803},[793,1568,823],{"class":799},[793,1570,1571],{"class":795,"line":929},[793,1572,1573],{"class":799},"      Margherita\n",[793,1575,1576],{"class":795,"line":1016},[793,1577,1578],{"class":799},"      A simple classic: mozzarella, tomatoes and basil.\n",[793,1580,1581],{"class":795,"line":1031},[793,1582,1583],{"class":799},"      An everyday choice!\n",[793,1585,1586,1588,1590,1592,1594,1596,1598,1600],{"class":795,"line":1044},[793,1587,1299],{"class":799},[793,1589,804],{"class":803},[793,1591,808],{"class":807},[793,1593,811],{"class":799},[793,1595,1366],{"class":814},[793,1597,1369],{"class":799},[793,1599,804],{"class":803},[793,1601,823],{"class":799},[793,1603,1604],{"class":795,"line":1057},[793,1605,1606],{"class":799},"      Capricciosa\n",[793,1608,1609],{"class":795,"line":1345},[793,1610,1611],{"class":799},"      A rich taste: mozzarella, ham, mushrooms, artichokes and olives.\n",[793,1613,1614],{"class":795,"line":1355},[793,1615,1616],{"class":799},"      A true favourite!\n",[793,1618,1619,1621,1623,1625,1627,1629,1631,1633],{"class":795,"line":1376},[793,1620,1299],{"class":799},[793,1622,804],{"class":803},[793,1624,808],{"class":807},[793,1626,811],{"class":799},[793,1628,1366],{"class":814},[793,1630,1369],{"class":799},[793,1632,804],{"class":803},[793,1634,823],{"class":799},[793,1636,1637,1639,1641],{"class":795,"line":1386},[793,1638,1476],{"class":799},[793,1640,1247],{"class":803},[793,1642,823],{"class":799},[793,1644,1645,1647,1649],{"class":795,"line":1401},[793,1646,1486],{"class":799},[793,1648,1247],{"class":803},[793,1650,823],{"class":799},[793,1652,1653,1655,1657],{"class":795,"line":1415},[793,1654,1009],{"class":799},[793,1656,956],{"class":803},[793,1658,823],{"class":799},[11,1660,1661,1662,280],{},"When downsampling is defined over different types of nodes – for instance, elements, attributes, and text – it becomes a powerful technique to control DOM size in a snapshot pipeline. Adaptive implementations can moreover produce snapshots that fall below a hard token limit. Our evaluation revealed that moderate downsampling ratios comfortably fit the mean DOM snapshot of real-world-representative web pages within GPT-4o's context window – leaving headroom for an agent system prompt and a trace of reasoning and action history",[654,1663,1664],{},[536,1665,1192],{"href":1189,"ariaDescribedBy":1666,"dataFootnoteRef":461,"id":1667},[660],"user-content-fnref-4-2",[94,1669,1671],{"id":1670},"the-problem-with-dom-based-targeting","The Problem with DOM-Based Targeting",[11,1673,1674,1675,1678,1679,1682],{},"When DOM snapshots are transformation artefacts, relative CSS selectors like nth-child paths might not map back to the live DOM. There are two straightforward ways to account for breaking CSS selectors: (1) assigning unique IDs to relevant elements in the live UI that persist transformations (e.g., via a unique attribute ",[264,1676,1677],{},"UNIQUE-ID=\"27\"",", which can be selected via ",[264,1680,1681],{},"[UNIQUE-ID=\"27\"]","), and (2) maintaining a source map between elements in the live DOM and the transformed DOM. The latter approach does favourably not affect the snapshot directly.",[11,1684,1685],{},[28,1686,1687],{},"DOM Snapshot with Inlined IDs:",[50,1689],{"src":1690,"alt":1691,"loading":55},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/7.png","A DOM snapshot (HTML) visualising unique ID (attribute) targeting",[94,1693,1695],{"id":1694},"the-dom-based-snapshot-pipeline","The DOM-Based Snapshot Pipeline",[11,1697,1698],{},"LLMs are able to reason over HTML. Yet, HTML carries noise, such as obfuscated scripts or hidden subtrees. DOM snapshots should for that reason be seen as a base representation, rather than a target representation.",[11,1700,1701],{},"The concept of DOM downsampling can be utilised as a universal size control in a snapshot pipeline – ideally exposed as quality, the inverse property of downsampling. Moreover, the DOM can be pre-transformed by deterministic techniques, such as pruning hidden subtrees to surface only the tangible UI – a characteristic that is natural with GUI snapshots.",[11,1703,1704],{},"The pipeline approach traceably goes from the raw DOM to an abstract snapshot representation. For example:",[1706,1707,1708,1731,1737,1795,1801,1807],"ol",{},[25,1709,1710,1713,1714,1719,1720,1723,1724,725,1727,1730],{},[28,1711,1712],{},"Scope Subtree."," Scope in to a task-relevant subtree. An information retrieval task on ",[536,1715,1718],{"href":1716,"rel":1717},"https://www.wikipedia.org",[540],"wikipedia.org"," can scope into the ",[264,1721,1722],{},"main"," element – ",[264,1725,1726],{},"header",[264,1728,1729],{},"footer"," are irrelevant.",[25,1732,1733,1736],{},[28,1734,1735],{},"Clone."," Clone the live DOM.",[25,1738,1739,1742,1743],{},[28,1740,1741],{},"Filter."," Apply arbitrary filters to the cloned DOM (in memory). For example:\n",[22,1744,1745,1783,1789],{},[25,1746,1747,1750,1751],{},[28,1748,1749],{},"Prune Subtrees"," E.g.:\n",[22,1752,1753,1759,1765],{},[25,1754,1755,1758],{},[28,1756,1757],{},"Non-interactive Nodes",", e.g., hidden elements.",[25,1760,1761,1764],{},[28,1762,1763],{},"Irrelevant Nodes",", e.g., comment nodes.",[25,1766,1767,1770,1771,1773,1774,1776,1777,1780,1781,280],{},[28,1768,1769],{},"Redundant Nodes",", e.g., ",[264,1772,536],{}," in the ",[264,1775,1729],{}," that has a same-",[264,1778,1779],{},"href"," equivalent in the ",[264,1782,1726],{},[25,1784,1785,1788],{},[28,1786,1787],{},"Sanitise."," E.g., sensitive information from content-editables.",[25,1790,1791,1794],{},[28,1792,1793],{},"Clean."," E.g., remove stop words from text nodes.",[25,1796,1797,1800],{},[28,1798,1799],{},"Serialise."," Serialise the cloned DOM to HTML.",[25,1802,1803,1806],{},[28,1804,1805],{},"Downsample."," Downsample the HTML to control size.",[25,1808,1809,1812],{},[28,1810,1811],{},"Translate."," Translate the downsampled HTML to any DOM-based representation, e.g., the accessibility tree.",[50,1814],{"src":1815,"alt":1816,"loading":55,"provider":57},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/8.svg","Example of a DOM snapshot pipeline",[11,1818,1819],{},"A filtered DOM drastically increases stability of repeatedly run web journeys: if only a single button routes to a target page, the agent perceives an unambiguous action target element. The rule of thumb is: the less actionable options a snapshot transcribes, the better – given all relevant options are covered.",[640,1821,1823],{"id":1822},"arbitrary-snapshot-representations","Arbitrary Snapshot Representations",[11,1825,1826],{},"Any text-based snapshot representation can be derived from the single-source-of-truth DOM. Which representation is best highly depends on the given web browsing task. A high-level distinction is between (A) navigation and (B) information retrieval tasks. Navigation tasks do not require extensive text, but  actionable elements – if a snapshot omits a relevant button, the LLM is not able to use the encoded UI. Information retrieval tasks, on the other hand, require text, as the text contains topical information, whilst actionable elements do not matter.",[11,1828,1829],{},"Compare the following snapshots representations for the same UI:",[11,1831,1832],{},[28,1833,1834],{},"DOM Snapshot:",[785,1836,1838],{"className":787,"code":1837,"language":789,"meta":461,"style":461},"\u003Csection class=\"container\" required=\"true\" type=\"example\">\n  \u003Cdiv class=\"mx-auto\" required=\"false\">\n    \u003Ch1>Our Pizza\u003C/h1>\n    \u003Cdiv>\n      \u003Ch2>Margherita\u003C/h2>\n      \u003Cp>\n        A simple classic: mozzarella, tomatoes and basil.\n        An everyday choice!\n      \u003C/p>\n      \u003Ca href=\"add?p=margherita\" data-uid=\"1\">Add\u003C/a>\n      \u003Ch2>Capricciosa\u003C/h2>\n      \u003Cp>\n        A rich taste: mozzarella, ham, mushrooms, artichokes and olives.\n        A true favourite!\n      \u003C/p>\n      \u003Ca href=\"add?p=capricciosa\" data-uid=\"2\">Add\u003C/a>\n    \u003C/div>\n  \u003C/div>\n\u003C/section>\n",[264,1839,1840,1866,1886,1898,1906,1918,1926,1931,1936,1944,1971,1983,1991,1996,2001,2009,2035,2043,2051],{"__ignoreMap":461},[793,1841,1842,1844,1846,1848,1850,1852,1854,1856,1858,1860,1862,1864],{"class":795,"line":796},[793,1843,800],{"class":799},[793,1845,956],{"class":803},[793,1847,959],{"class":807},[793,1849,811],{"class":799},[793,1851,1215],{"class":814},[793,1853,1226],{"class":807},[793,1855,811],{"class":799},[793,1857,1231],{"class":814},[793,1859,808],{"class":807},[793,1861,811],{"class":799},[793,1863,1238],{"class":814},[793,1865,823],{"class":799},[793,1867,1868,1870,1872,1874,1876,1878,1880,1882,1884],{"class":795,"line":462},[793,1869,971],{"class":799},[793,1871,1247],{"class":803},[793,1873,959],{"class":807},[793,1875,811],{"class":799},[793,1877,1254],{"class":814},[793,1879,1226],{"class":807},[793,1881,811],{"class":799},[793,1883,1269],{"class":814},[793,1885,823],{"class":799},[793,1887,1888,1890,1892,1894,1896],{"class":795,"line":468},[793,1889,1276],{"class":799},[793,1891,1279],{"class":803},[793,1893,1282],{"class":799},[793,1895,1279],{"class":803},[793,1897,823],{"class":799},[793,1899,1900,1902,1904],{"class":795,"line":915},[793,1901,1276],{"class":799},[793,1903,1247],{"class":803},[793,1905,823],{"class":799},[793,1907,1908,1910,1912,1914,1916],{"class":795,"line":929},[793,1909,1299],{"class":799},[793,1911,59],{"class":803},[793,1913,1320],{"class":799},[793,1915,59],{"class":803},[793,1917,823],{"class":799},[793,1919,1920,1922,1924],{"class":795,"line":1016},[793,1921,1299],{"class":799},[793,1923,11],{"class":803},[793,1925,823],{"class":799},[793,1927,1928],{"class":795,"line":1031},[793,1929,1930],{"class":799},"        A simple classic: mozzarella, tomatoes and basil.\n",[793,1932,1933],{"class":795,"line":1044},[793,1934,1935],{"class":799},"        An everyday choice!\n",[793,1937,1938,1940,1942],{"class":795,"line":1057},[793,1939,1379],{"class":799},[793,1941,11],{"class":803},[793,1943,823],{"class":799},[793,1945,1946,1948,1950,1952,1954,1957,1960,1962,1965,1967,1969],{"class":795,"line":1345},[793,1947,1299],{"class":799},[793,1949,536],{"class":803},[793,1951,845],{"class":807},[793,1953,811],{"class":799},[793,1955,1956],{"class":814},"\"add?p=margherita\"",[793,1958,1959],{"class":807}," data-uid",[793,1961,811],{"class":799},[793,1963,1964],{"class":814},"\"1\"",[793,1966,1369],{"class":799},[793,1968,536],{"class":803},[793,1970,823],{"class":799},[793,1972,1973,1975,1977,1979,1981],{"class":795,"line":1355},[793,1974,1299],{"class":799},[793,1976,59],{"class":803},[793,1978,1408],{"class":799},[793,1980,59],{"class":803},[793,1982,823],{"class":799},[793,1984,1985,1987,1989],{"class":795,"line":1376},[793,1986,1299],{"class":799},[793,1988,11],{"class":803},[793,1990,823],{"class":799},[793,1992,1993],{"class":795,"line":1386},[793,1994,1995],{"class":799},"        A rich taste: mozzarella, ham, mushrooms, artichokes and olives.\n",[793,1997,1998],{"class":795,"line":1401},[793,1999,2000],{"class":799},"        A true favourite!\n",[793,2002,2003,2005,2007],{"class":795,"line":1415},[793,2004,1379],{"class":799},[793,2006,11],{"class":803},[793,2008,823],{"class":799},[793,2010,2011,2013,2015,2017,2019,2022,2024,2026,2029,2031,2033],{"class":795,"line":1424},[793,2012,1299],{"class":799},[793,2014,536],{"class":803},[793,2016,845],{"class":807},[793,2018,811],{"class":799},[793,2020,2021],{"class":814},"\"add?p=capricciosa\"",[793,2023,1959],{"class":807},[793,2025,811],{"class":799},[793,2027,2028],{"class":814},"\"2\"",[793,2030,1369],{"class":799},[793,2032,536],{"class":803},[793,2034,823],{"class":799},[793,2036,2037,2039,2041],{"class":795,"line":1430},[793,2038,1476],{"class":799},[793,2040,1247],{"class":803},[793,2042,823],{"class":799},[793,2044,2045,2047,2049],{"class":795,"line":1436},[793,2046,1486],{"class":799},[793,2048,1247],{"class":803},[793,2050,823],{"class":799},[793,2052,2053,2055,2057],{"class":795,"line":1445},[793,2054,1009],{"class":799},[793,2056,956],{"class":803},[793,2058,823],{"class":799},[11,2060,2061],{},[28,2062,2063],{},"Accessibility Tree Snapshot:",[785,2065,2069],{"className":2066,"code":2067,"language":2068,"meta":461,"style":461},"language-yaml shiki shiki-themes github-dark github-dark","- document:\n  children:\n    - section:\n      children:\n        - heading:\n          name: \"Our Pizza\"\n          level: 1\n        - heading:\n          name: \"Margherita\"\n          level: 2\n        - paragraph:\n          children:\n            - text: \"A simple classic: mozzarella, tomatoes and basil. An everyday choice!\"\n        - link:\n          name: \"Add\"\n          url: \"add?p=margherita\"\n          data-uid: 1\n        - heading:\n          name: \"Capricciosa\"\n          level: 2\n        - paragraph:\n          children:\n            - text: \"A rich taste: mozzarella, ham, mushrooms, artichokes and olives. A true favourite!\"\n        - link:\n          name: \"Add\"\n          url: \"add?p=capricciosa\"\n          data-uid: 2\n","yaml",[264,2070,2071,2082,2089,2098,2105,2115,2126,2137,2145,2154,2163,2172,2179,2192,2201,2210,2220,2229,2237,2246,2254,2262,2268,2279,2288,2297,2307],{"__ignoreMap":461},[793,2072,2073,2076,2079],{"class":795,"line":796},[793,2074,2075],{"class":799},"- ",[793,2077,2078],{"class":803},"document",[793,2080,2081],{"class":799},":\n",[793,2083,2084,2087],{"class":795,"line":462},[793,2085,2086],{"class":803},"  children",[793,2088,2081],{"class":799},[793,2090,2091,2094,2096],{"class":795,"line":468},[793,2092,2093],{"class":799},"    - ",[793,2095,956],{"class":803},[793,2097,2081],{"class":799},[793,2099,2100,2103],{"class":795,"line":915},[793,2101,2102],{"class":803},"      children",[793,2104,2081],{"class":799},[793,2106,2107,2110,2113],{"class":795,"line":929},[793,2108,2109],{"class":799},"        - ",[793,2111,2112],{"class":803},"heading",[793,2114,2081],{"class":799},[793,2116,2117,2120,2123],{"class":795,"line":1016},[793,2118,2119],{"class":803},"          name",[793,2121,2122],{"class":799},": ",[793,2124,2125],{"class":814},"\"Our Pizza\"\n",[793,2127,2128,2131,2133],{"class":795,"line":1031},[793,2129,2130],{"class":803},"          level",[793,2132,2122],{"class":799},[793,2134,2136],{"class":2135},"s8ozJ","1\n",[793,2138,2139,2141,2143],{"class":795,"line":1044},[793,2140,2109],{"class":799},[793,2142,2112],{"class":803},[793,2144,2081],{"class":799},[793,2146,2147,2149,2151],{"class":795,"line":1057},[793,2148,2119],{"class":803},[793,2150,2122],{"class":799},[793,2152,2153],{"class":814},"\"Margherita\"\n",[793,2155,2156,2158,2160],{"class":795,"line":1345},[793,2157,2130],{"class":803},[793,2159,2122],{"class":799},[793,2161,2162],{"class":2135},"2\n",[793,2164,2165,2167,2170],{"class":795,"line":1355},[793,2166,2109],{"class":799},[793,2168,2169],{"class":803},"paragraph",[793,2171,2081],{"class":799},[793,2173,2174,2177],{"class":795,"line":1376},[793,2175,2176],{"class":803},"          children",[793,2178,2081],{"class":799},[793,2180,2181,2184,2187,2189],{"class":795,"line":1386},[793,2182,2183],{"class":799},"            - ",[793,2185,2186],{"class":803},"text",[793,2188,2122],{"class":799},[793,2190,2191],{"class":814},"\"A simple classic: mozzarella, tomatoes and basil. An everyday choice!\"\n",[793,2193,2194,2196,2199],{"class":795,"line":1401},[793,2195,2109],{"class":799},[793,2197,2198],{"class":803},"link",[793,2200,2081],{"class":799},[793,2202,2203,2205,2207],{"class":795,"line":1415},[793,2204,2119],{"class":803},[793,2206,2122],{"class":799},[793,2208,2209],{"class":814},"\"Add\"\n",[793,2211,2212,2215,2217],{"class":795,"line":1424},[793,2213,2214],{"class":803},"          url",[793,2216,2122],{"class":799},[793,2218,2219],{"class":814},"\"add?p=margherita\"\n",[793,2221,2222,2225,2227],{"class":795,"line":1430},[793,2223,2224],{"class":803},"          data-uid",[793,2226,2122],{"class":799},[793,2228,2136],{"class":2135},[793,2230,2231,2233,2235],{"class":795,"line":1436},[793,2232,2109],{"class":799},[793,2234,2112],{"class":803},[793,2236,2081],{"class":799},[793,2238,2239,2241,2243],{"class":795,"line":1445},[793,2240,2119],{"class":803},[793,2242,2122],{"class":799},[793,2244,2245],{"class":814},"\"Capricciosa\"\n",[793,2247,2248,2250,2252],{"class":795,"line":1464},[793,2249,2130],{"class":803},[793,2251,2122],{"class":799},[793,2253,2162],{"class":2135},[793,2255,2256,2258,2260],{"class":795,"line":1473},[793,2257,2109],{"class":799},[793,2259,2169],{"class":803},[793,2261,2081],{"class":799},[793,2263,2264,2266],{"class":795,"line":1483},[793,2265,2176],{"class":803},[793,2267,2081],{"class":799},[793,2269,2270,2272,2274,2276],{"class":795,"line":1493},[793,2271,2183],{"class":799},[793,2273,2186],{"class":803},[793,2275,2122],{"class":799},[793,2277,2278],{"class":814},"\"A rich taste: mozzarella, ham, mushrooms, artichokes and olives. A true favourite!\"\n",[793,2280,2282,2284,2286],{"class":795,"line":2281},24,[793,2283,2109],{"class":799},[793,2285,2198],{"class":803},[793,2287,2081],{"class":799},[793,2289,2291,2293,2295],{"class":795,"line":2290},25,[793,2292,2119],{"class":803},[793,2294,2122],{"class":799},[793,2296,2209],{"class":814},[793,2298,2300,2302,2304],{"class":795,"line":2299},26,[793,2301,2214],{"class":803},[793,2303,2122],{"class":799},[793,2305,2306],{"class":814},"\"add?p=capricciosa\"\n",[793,2308,2310,2312,2314],{"class":795,"line":2309},27,[793,2311,2224],{"class":803},[793,2313,2122],{"class":799},[793,2315,2162],{"class":2135},[11,2317,2318],{},[28,2319,2320],{},"Markdown Snapshot:",[785,2322,2325],{"className":2323,"code":2324,"language":480,"meta":461,"style":461},"language-md shiki shiki-themes github-dark github-dark","# Our Pizza\n\n## Margherita\n\nA simple classic: mozzarella, tomatoes and basil.\nAn everyday choice!\n\n[Add](add?p=margherita)\n\n## Capricciosa\n\nA rich taste: mozzarella, ham, mushrooms, artichokes and olives.\nA true favourite!\n\n[Add](add?p=capricciosa)\n",[264,2326,2327,2332,2337,2342,2346,2351,2356,2360,2365,2369,2374,2378,2383,2388,2392],{"__ignoreMap":461},[793,2328,2329],{"class":795,"line":796},[793,2330,2331],{},"# Our Pizza\n",[793,2333,2334],{"class":795,"line":462},[793,2335,2336],{"emptyLinePlaceholder":508},"\n",[793,2338,2339],{"class":795,"line":468},[793,2340,2341],{},"## Margherita\n",[793,2343,2344],{"class":795,"line":915},[793,2345,2336],{"emptyLinePlaceholder":508},[793,2347,2348],{"class":795,"line":929},[793,2349,2350],{},"A simple classic: mozzarella, tomatoes and basil.\n",[793,2352,2353],{"class":795,"line":1016},[793,2354,2355],{},"An everyday choice!\n",[793,2357,2358],{"class":795,"line":1031},[793,2359,2336],{"emptyLinePlaceholder":508},[793,2361,2362],{"class":795,"line":1044},[793,2363,2364],{},"[Add](add?p=margherita)\n",[793,2366,2367],{"class":795,"line":1057},[793,2368,2336],{"emptyLinePlaceholder":508},[793,2370,2371],{"class":795,"line":1345},[793,2372,2373],{},"## Capricciosa\n",[793,2375,2376],{"class":795,"line":1355},[793,2377,2336],{"emptyLinePlaceholder":508},[793,2379,2380],{"class":795,"line":1376},[793,2381,2382],{},"A rich taste: mozzarella, ham, mushrooms, artichokes and olives.\n",[793,2384,2385],{"class":795,"line":1386},[793,2386,2387],{},"A true favourite!\n",[793,2389,2390],{"class":795,"line":1401},[793,2391,2336],{"emptyLinePlaceholder":508},[793,2393,2394],{"class":795,"line":1415},[793,2395,2396],{},"[Add](add?p=capricciosa)\n",[11,2398,2399],{},[28,2400,2401],{},"Custom Format Snapshot:",[785,2403,2407],{"className":2404,"code":2406,"language":2186},[2405],"language-text","[0] H1 \"Our Pizza\"\n[1] H2 \"Margherita\"\n[2] P \"A simple classic: mozzarella, tomatoes and basil.\\nAn everyday choice!\"\n[3] A \"Add\" \"add?p=margherita\"\n[4] H2 \"Capricciosa\"\n[5] P \"A rich taste: mozzarella, ham, mushrooms, artichokes and olives.\\nA true...\"\n[6] A \"Add\" \"add?p=capricciosa\"\n",[264,2408,2406],{"__ignoreMap":461},[11,2410,2411,2412,280],{},"Browser Use agents implement hybrid snapshots: the grounded GUI snapshot is a supplement to a custom-format indexed-list DOM snapshot, similar to the above example. Evaluations show that the indexed-list snapshot representation generally conveys most of the salient UI features for the web agent LLM backend",[654,2413,2414],{},[536,2415,1192],{"href":1189,"ariaDescribedBy":2416,"dataFootnoteRef":461,"id":2417},[660],"user-content-fnref-4-3",[59,2419,2421],{"id":2420},"non-idiomatic-application-designs","Non-Idiomatic Application Designs",[11,2423,2424],{},"An actionable element might lack affordance – not communicating its actionability through its bare appearance. That is bad UI/UX design practice. The concept extends to the DOM through HTML semantics, which communicate the general purpose of an element to web browsers and developers rather than users. Generalising to web agent LLM backends, the concept of affordance aligns between the GUI and the DOM – the model is a UI representation-agnostic user.",[11,2426,2427],{},"Missing affordances should be rectified in a snapshot wherever they can be discovered. Discoverability is another circular problem: what is an indirect affordance for actionability? Ideally, the underlying actionability is tracked, such as by checking for attached action event listeners. However, there is no browser API for this practice.",[11,2429,2430],{},"As an example for bad affordance in the GUI, imagine an overly subtle 'Shop' button. Bounding boxes in grounded GUI snapshots are a workaround – provided the element is discoverable as actionable in the DOM in the first place.",[50,2432],{"src":2433,"alt":2434,"loading":55,":width":2435},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/9.png","Example of a fictional UI/UX bad practice (overly subtle button)","480",[11,2437,2438,2439,2444],{},"As an example for bad affordance in the DOM, look at this datepicker from ",[536,2440,2443],{"href":2441,"rel":2442},"https://www.webmd.com",[540],"webmd.com",":",[50,2446],{"src":2447,"alt":2448,"loading":55,":width":2435},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/10.png","Example of an HTML bad practice (ignoring tag name semantics)",[785,2450,2452],{"className":787,"code":2451,"language":789,"meta":461,"style":461},"\u003Cdiv>\n  \u003Cspan class=\"cell day-header\">Sun\u003C/span>\n  \u003Cspan class=\"cell day-header\">Mon\u003C/span>\n  \u003Cspan class=\"cell day-header\">Tue\u003C/span>\n  \u003Cspan class=\"cell day-header\">Wed\u003C/span>\n  \u003Cspan class=\"cell day-header\">Thu\u003C/span>\n  \u003Cspan class=\"cell day-header\">Fri\u003C/span>\n  \u003Cspan class=\"cell day-header\">Sat\u003C/span>\n  \u003C!-- [...] -->\n  \u003Cspan class=\"cell day blank\">\u003C/span>\n  \u003Cspan class=\"cell day blank\">\u003C/span>\n  \u003Cspan class=\"cell day\">\u003Cspan>1\u003C/span>\u003C/span>\n  \u003Cspan class=\"cell day\">\u003Cspan>2\u003C/span>\u003C/span>\n  \u003Cspan class=\"cell day\">\u003Cspan>3\u003C/span>\u003C/span>\n  \u003C!-- [...] -->\n  \u003Cspan class=\"cell day\">\u003Cspan>29\u003C/span>\u003C/span>\n  \u003Cspan class=\"cell day\">\u003Cspan>30\u003C/span>\u003C/span>\n\u003C/div>\n",[264,2453,2454,2462,2482,2501,2520,2539,2558,2577,2596,2602,2622,2640,2669,2696,2723,2727,2754,2781],{"__ignoreMap":461},[793,2455,2456,2458,2460],{"class":795,"line":796},[793,2457,800],{"class":799},[793,2459,1247],{"class":803},[793,2461,823],{"class":799},[793,2463,2464,2466,2468,2470,2472,2475,2478,2480],{"class":795,"line":462},[793,2465,971],{"class":799},[793,2467,793],{"class":803},[793,2469,959],{"class":807},[793,2471,811],{"class":799},[793,2473,2474],{"class":814},"\"cell day-header\"",[793,2476,2477],{"class":799},">Sun\u003C/",[793,2479,793],{"class":803},[793,2481,823],{"class":799},[793,2483,2484,2486,2488,2490,2492,2494,2497,2499],{"class":795,"line":468},[793,2485,971],{"class":799},[793,2487,793],{"class":803},[793,2489,959],{"class":807},[793,2491,811],{"class":799},[793,2493,2474],{"class":814},[793,2495,2496],{"class":799},">Mon\u003C/",[793,2498,793],{"class":803},[793,2500,823],{"class":799},[793,2502,2503,2505,2507,2509,2511,2513,2516,2518],{"class":795,"line":915},[793,2504,971],{"class":799},[793,2506,793],{"class":803},[793,2508,959],{"class":807},[793,2510,811],{"class":799},[793,2512,2474],{"class":814},[793,2514,2515],{"class":799},">Tue\u003C/",[793,2517,793],{"class":803},[793,2519,823],{"class":799},[793,2521,2522,2524,2526,2528,2530,2532,2535,2537],{"class":795,"line":929},[793,2523,971],{"class":799},[793,2525,793],{"class":803},[793,2527,959],{"class":807},[793,2529,811],{"class":799},[793,2531,2474],{"class":814},[793,2533,2534],{"class":799},">Wed\u003C/",[793,2536,793],{"class":803},[793,2538,823],{"class":799},[793,2540,2541,2543,2545,2547,2549,2551,2554,2556],{"class":795,"line":1016},[793,2542,971],{"class":799},[793,2544,793],{"class":803},[793,2546,959],{"class":807},[793,2548,811],{"class":799},[793,2550,2474],{"class":814},[793,2552,2553],{"class":799},">Thu\u003C/",[793,2555,793],{"class":803},[793,2557,823],{"class":799},[793,2559,2560,2562,2564,2566,2568,2570,2573,2575],{"class":795,"line":1031},[793,2561,971],{"class":799},[793,2563,793],{"class":803},[793,2565,959],{"class":807},[793,2567,811],{"class":799},[793,2569,2474],{"class":814},[793,2571,2572],{"class":799},">Fri\u003C/",[793,2574,793],{"class":803},[793,2576,823],{"class":799},[793,2578,2579,2581,2583,2585,2587,2589,2592,2594],{"class":795,"line":1044},[793,2580,971],{"class":799},[793,2582,793],{"class":803},[793,2584,959],{"class":807},[793,2586,811],{"class":799},[793,2588,2474],{"class":814},[793,2590,2591],{"class":799},">Sat\u003C/",[793,2593,793],{"class":803},[793,2595,823],{"class":799},[793,2597,2598],{"class":795,"line":1057},[793,2599,2601],{"class":2600},"sJ8bj","  \u003C!-- [...] -->\n",[793,2603,2604,2606,2608,2610,2612,2615,2618,2620],{"class":795,"line":1345},[793,2605,971],{"class":799},[793,2607,793],{"class":803},[793,2609,959],{"class":807},[793,2611,811],{"class":799},[793,2613,2614],{"class":814},"\"cell day blank\"",[793,2616,2617],{"class":799},">\u003C/",[793,2619,793],{"class":803},[793,2621,823],{"class":799},[793,2623,2624,2626,2628,2630,2632,2634,2636,2638],{"class":795,"line":1355},[793,2625,971],{"class":799},[793,2627,793],{"class":803},[793,2629,959],{"class":807},[793,2631,811],{"class":799},[793,2633,2614],{"class":814},[793,2635,2617],{"class":799},[793,2637,793],{"class":803},[793,2639,823],{"class":799},[793,2641,2642,2644,2646,2648,2650,2653,2656,2658,2661,2663,2665,2667],{"class":795,"line":1376},[793,2643,971],{"class":799},[793,2645,793],{"class":803},[793,2647,959],{"class":807},[793,2649,811],{"class":799},[793,2651,2652],{"class":814},"\"cell day\"",[793,2654,2655],{"class":799},">\u003C",[793,2657,793],{"class":803},[793,2659,2660],{"class":799},">1\u003C/",[793,2662,793],{"class":803},[793,2664,2617],{"class":799},[793,2666,793],{"class":803},[793,2668,823],{"class":799},[793,2670,2671,2673,2675,2677,2679,2681,2683,2685,2688,2690,2692,2694],{"class":795,"line":1386},[793,2672,971],{"class":799},[793,2674,793],{"class":803},[793,2676,959],{"class":807},[793,2678,811],{"class":799},[793,2680,2652],{"class":814},[793,2682,2655],{"class":799},[793,2684,793],{"class":803},[793,2686,2687],{"class":799},">2\u003C/",[793,2689,793],{"class":803},[793,2691,2617],{"class":799},[793,2693,793],{"class":803},[793,2695,823],{"class":799},[793,2697,2698,2700,2702,2704,2706,2708,2710,2712,2715,2717,2719,2721],{"class":795,"line":1401},[793,2699,971],{"class":799},[793,2701,793],{"class":803},[793,2703,959],{"class":807},[793,2705,811],{"class":799},[793,2707,2652],{"class":814},[793,2709,2655],{"class":799},[793,2711,793],{"class":803},[793,2713,2714],{"class":799},">3\u003C/",[793,2716,793],{"class":803},[793,2718,2617],{"class":799},[793,2720,793],{"class":803},[793,2722,823],{"class":799},[793,2724,2725],{"class":795,"line":1415},[793,2726,2601],{"class":2600},[793,2728,2729,2731,2733,2735,2737,2739,2741,2743,2746,2748,2750,2752],{"class":795,"line":1424},[793,2730,971],{"class":799},[793,2732,793],{"class":803},[793,2734,959],{"class":807},[793,2736,811],{"class":799},[793,2738,2652],{"class":814},[793,2740,2655],{"class":799},[793,2742,793],{"class":803},[793,2744,2745],{"class":799},">29\u003C/",[793,2747,793],{"class":803},[793,2749,2617],{"class":799},[793,2751,793],{"class":803},[793,2753,823],{"class":799},[793,2755,2756,2758,2760,2762,2764,2766,2768,2770,2773,2775,2777,2779],{"class":795,"line":1430},[793,2757,971],{"class":799},[793,2759,793],{"class":803},[793,2761,959],{"class":807},[793,2763,811],{"class":799},[793,2765,2652],{"class":814},[793,2767,2655],{"class":799},[793,2769,793],{"class":803},[793,2771,2772],{"class":799},">30\u003C/",[793,2774,793],{"class":803},[793,2776,2617],{"class":799},[793,2778,793],{"class":803},[793,2780,823],{"class":799},[793,2782,2783,2785,2787],{"class":795,"line":1436},[793,2784,1009],{"class":799},[793,2786,1247],{"class":803},[793,2788,823],{"class":799},[11,2790,2791,2792,2794,2795,2798,2799,2801,2802,2805,2806,2808],{},"The days wrapped in ",[264,2793,793],{}," (e.g., ",[264,2796,2797],{},"16",") are clickable, but the HTML communicates no such actionability. The idiomatic DOM equivalent would instead use ",[264,2800,804],{}," elements throughout, or at least assign suitable ",[264,2803,2804],{},"role"," attributes like ",[264,2807,804],{},". A DOM snapshot pipeline leaves space for solving this problem: rewrite the virtual DOM with idiomatic elements.",[785,2810,2812],{"className":787,"code":2811,"language":789,"meta":461,"style":461},"  \u003Cbutton class=\"cell day\">29\u003C/button>\n  \u003C!-- OR -->\n  \u003Cspan role=\"button\" class=\"cell day\">30\u003C/button>\n",[264,2813,2814,2832,2837],{"__ignoreMap":461},[793,2815,2816,2818,2820,2822,2824,2826,2828,2830],{"class":795,"line":796},[793,2817,971],{"class":799},[793,2819,804],{"class":803},[793,2821,959],{"class":807},[793,2823,811],{"class":799},[793,2825,2652],{"class":814},[793,2827,2745],{"class":799},[793,2829,804],{"class":803},[793,2831,823],{"class":799},[793,2833,2834],{"class":795,"line":462},[793,2835,2836],{"class":2600},"  \u003C!-- OR -->\n",[793,2838,2839,2841,2843,2846,2848,2850,2852,2854,2856,2858,2860],{"class":795,"line":468},[793,2840,971],{"class":799},[793,2842,793],{"class":803},[793,2844,2845],{"class":807}," role",[793,2847,811],{"class":799},[793,2849,1366],{"class":814},[793,2851,959],{"class":807},[793,2853,811],{"class":799},[793,2855,2652],{"class":814},[793,2857,2772],{"class":799},[793,2859,804],{"class":803},[793,2861,823],{"class":799},[59,2863,2865],{"id":2864},"choosing-between-snapshot-representations","Choosing Between Snapshot Representations",[11,2867,2868],{},"No snapshot representation fits all purposes; the two base representations alone – GUI and DOM (HTML) – come with markedly different advantages and limitations. A proper snapshot tool should therefore route and cascade:",[1706,2870,2871,2883,2889,2895],{},[25,2872,2873,2876,2877,2879,2880,2882],{},[28,2874,2875],{},"Route Modality."," Fall back to GUI snapshots if the UI is based on ",[264,2878,710],{}," or cross-origin ",[264,2881,706],{}," elements; use DOM snapshots by default.",[25,2884,2885,2888],{},[28,2886,2887],{},"Route Representation."," Categorise task and translate DOM snapshot to the most suitable representation. Categorising the task can be done with increasing levels of machine learning – simple keyword matching, or deploying a language model.",[25,2890,2891,2894],{},[28,2892,2893],{},"Scope Escalation."," If elicited action suggestions are unusable, widen the snapshot scope and representation richness.",[25,2896,2897,2900],{},[28,2898,2899],{},"Cascade to Hybrid."," If elicited action suggestions are still unusable, augment the rich DOM snapshot with a GUI snapshot for maximum grounding.",[380,2902,2903,2922],{},[383,2904,2905],{},[386,2906,2907,2910,2913,2916,2919],{},[389,2908],{"align":2909},"left",[389,2911,2912],{},"GUI",[389,2914,2915],{},"grounded",[389,2917,2918],{},"DOM",[389,2920,2921],{},"transformed",[399,2923,2924,2946,2967,2990,3009,3030],{},[386,2925,2926,2929,2934,2938,2941],{},[404,2927,2928],{"align":2909},"LLM Input Tokens",[404,2930,2931],{},[28,2932,2933],{},"Low",[404,2935,2936],{},[28,2937,2933],{},[404,2939,2940],{},"High",[404,2942,2943,2945],{},[28,2944,2933],{}," to Moderate",[386,2947,2948,2951,2954,2959,2963],{},[404,2949,2950],{"align":2909},"Element Targeting",[404,2952,2953],{},"Absolute",[404,2955,2956],{},[28,2957,2958],{},"Relative",[404,2960,2961],{},[28,2962,2958],{},[404,2964,2965],{},[28,2966,2958],{},[386,2968,2969,2972,2978,2982,2986],{},[404,2970,2971],{"align":2909},"Snapshot Scope",[404,2973,2974,2977],{},[28,2975,2976],{},"Free","/Viewport",[404,2979,2980,2977],{},[28,2981,2976],{},[404,2983,2984],{},[28,2985,2976],{},[404,2987,2988],{},[28,2989,2976],{},[386,2991,2992,2995,2998,3000,3005],{},[404,2993,2994],{"align":2909},"Snapshot Context",[404,2996,2997],{},"UI",[404,2999,2997],{},[404,3001,3002],{},[28,3003,3004],{},"Full",[404,3006,3007],{},[28,3008,3004],{},[386,3010,3011,3016,3021,3025,3028],{},[404,3012,3013,3015],{"align":2909},[264,3014,706],{}," Context",[404,3017,3018],{},[28,3019,3020],{},"Viewport",[404,3022,3023],{},[28,3024,3020],{},[404,3026,3027],{},"Same-origin only",[404,3029,3027],{},[386,3031,3032,3036,3041,3045,3048],{},[404,3033,3034,3015],{"align":2909},[264,3035,710],{},[404,3037,3038],{},[28,3039,3040],{},"Yes",[404,3042,3043],{},[28,3044,3040],{},[404,3046,3047],{},"No",[404,3049,3047],{},[59,3051,3053],{"id":3052},"using-snapshots-in-the-model-context","Using Snapshots in the Model Context",[11,3055,3056],{},"Creating a snapshot is one thing. Using it as context to a model prompt is the other. Usually, conversational AI maintains a full trace of history as model context. Since a snapshot is time-sensitive, however, only the latest snapshot can be targeted with actions by an LLM.",[11,3058,3059],{},"Whether to keep a trace of previous actions and model reasoning is a question in its own right. If web browsing is modelled as a history-independent task, the snapshot-to-actions agent loop could even be separated from the persistent conversational loop as transient, one-shot model prompts.",[59,3061,3063],{"id":3062},"timing-snapshots-in-the-web-client","Timing Snapshots in the Web Client",[11,3065,3066,3067,280],{},"LLM-based web agents are much slower than humans in taking and processing snapshots. Not least for that reason, snapshot rounds should be kept to a minimum and timed so that a snapshot is taken as soon as the UI has reached a stable state. That implies a non-trivial challenge: defining what qualifies as a UI change, and at what intensity such a change counts as a state shift – beyond hard page transitions, e.g., in a single-page application",[654,3068,3069],{},[536,3070,3074],{"href":3071,"ariaDescribedBy":3072,"dataFootnoteRef":461,"id":3073},"#user-content-fn-5",[660],"user-content-fnref-5","5",[3076,3077],"hr",{},[11,3079,3080,3081,280],{},"The snapshot is the central artefact in a web agent harness. Its representation is among the most significant factors for agent success",[654,3082,3083],{},[536,3084,3088],{"href":3085,"ariaDescribedBy":3086,"dataFootnoteRef":461,"id":3087},"#user-content-fn-6",[660],"user-content-fnref-6","6",[11,3090,3091,3092,3094],{},"At Webfuse, we develop a platform for agentic browsing. A focus of our research is on efficient snapshot representations. The Automation API can be used to create next-level snapshots: timed, rectified, across ",[264,3093,706],{}," boundaries, etc.",[956,3096,3099,3104],{"className":3097,"dataFootnotes":461},[3098],"footnotes",[59,3100,3103],{"className":3101,"id":660},[3102],"sr-only","Footnotes",[1706,3105,3106,3121,3134,3146,3172,3184],{},[25,3107,3109,3113,3114],{"id":3108},"user-content-fn-1",[536,3110,3111],{"href":3111,"rel":3112},"https://arxiv.org/abs/2310.11441",[540]," ",[536,3115,3120],{"href":3116,"ariaLabel":3117,"className":3118,"dataFootnoteBackref":461},"#user-content-fnref-1","Back to reference 1",[3119],"data-footnote-backref","↩",[25,3122,3124,3125,3113,3129],{"id":3123},"user-content-fn-2","Our reimplementation of Browser Use's grounded GUI snapshots: ",[536,3126,3127],{"href":3127,"rel":3128},"https://github.com/webfuse-com/D2Snap/blob/main/snapshots/_bu.js",[540],[536,3130,3120],{"href":3131,"ariaLabel":3132,"className":3133,"dataFootnoteBackref":461},"#user-content-fnref-2","Back to reference 2",[3119],[25,3135,3137,3113,3141],{"id":3136},"user-content-fn-3",[536,3138,3139],{"href":3139,"rel":3140},"https://arxiv.org/abs/2210.03945",[540],[536,3142,3120],{"href":3143,"ariaLabel":3144,"className":3145,"dataFootnoteBackref":461},"#user-content-fnref-3","Back to reference 3",[3119],[25,3147,3149,3113,3153,3113,3158,3113,3165],{"id":3148},"user-content-fn-4",[536,3150,3151],{"href":3151,"rel":3152},"https://arxiv.org/abs/2508.04412",[540],[536,3154,3120],{"href":3155,"ariaLabel":3156,"className":3157,"dataFootnoteBackref":461},"#user-content-fnref-4","Back to reference 4",[3119],[536,3159,3120,3163],{"href":3160,"ariaLabel":3161,"className":3162,"dataFootnoteBackref":461},"#user-content-fnref-4-2","Back to reference 4-2",[3119],[654,3164,684],{},[536,3166,3120,3170],{"href":3167,"ariaLabel":3168,"className":3169,"dataFootnoteBackref":461},"#user-content-fnref-4-3","Back to reference 4-3",[3119],[654,3171,699],{},[25,3173,3175,3113,3179],{"id":3174},"user-content-fn-5",[536,3176,3177],{"href":3177,"rel":3178},"https://github.com/webfuse-com/DOMQuake",[540],[536,3180,3120],{"href":3181,"ariaLabel":3182,"className":3183,"dataFootnoteBackref":461},"#user-content-fnref-5","Back to reference 5",[3119],[25,3185,3187,3113,3191],{"id":3186},"user-content-fn-6",[536,3188,3189],{"href":3189,"rel":3190},"https://arxiv.org/abs/2504.01382",[540],[536,3192,3120],{"href":3193,"ariaLabel":3194,"className":3195,"dataFootnoteBackref":461},"#user-content-fnref-6","Back to reference 6",[3119],[3197,3198,3199],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .suv1-, html code.shiki .suv1-{--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}html pre.shiki code .sxg3X, html code.shiki .sxg3X{--shiki-default:#85E89D;--shiki-dark:#85E89D}html pre.shiki code .sFR8T, html code.shiki .sFR8T{--shiki-default:#B392F0;--shiki-dark:#B392F0}html pre.shiki code .s4wv1, html code.shiki .s4wv1{--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF}html pre.shiki code .s8ozJ, html code.shiki .s8ozJ{--shiki-default:#79B8FF;--shiki-dark:#79B8FF}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}",{"title":461,"searchDepth":462,"depth":462,"links":3201},[3202,3206,3212,3213,3214,3215,3216],{"id":564,"depth":462,"text":565,"children":3203},[3204,3205],{"id":587,"depth":468,"text":588},{"id":626,"depth":468,"text":627},{"id":687,"depth":462,"text":688,"children":3207},[3208,3209,3210,3211],{"id":717,"depth":468,"text":718},{"id":742,"depth":468,"text":743},{"id":1670,"depth":468,"text":1671},{"id":1694,"depth":468,"text":1695},{"id":2420,"depth":462,"text":2421},{"id":2864,"depth":462,"text":2865},{"id":3052,"depth":462,"text":3053},{"id":3062,"depth":462,"text":3063},{"id":660,"depth":462,"text":3103},"2025-08-28","Understand how web-based user interfaces can be serialised for use with LLM-based web agents.",{"homepage":508,"relatedLinks":3220},[3221,3224],{"text":3222,"href":3223},"DOM Downsampling for LLM-Based Web Agents","/rnd/dom-downsampling-for-llm-based-web-agents",{"text":3225,"href":3226,"external":508},"Webfuse Automation API","https://dev.webfuse.com/automation-api/","/blog/serialising-web-ui-state-for-llms-the-complete-guide",{"title":522,"description":3218},{"loc":3227},"blog/1013.serialising-web-ui-state-for-llms-the-complete-guide",[477,514,3232,3233,3234],"web-automation","llms","snapshots","X7R93b2XjyDfLllTDaNgFoo_c8AvF9oBDGzv4yiISFA",{"id":3237,"title":3238,"authorId":523,"body":3239,"category":477,"created":3714,"description":3715,"extension":480,"faqs":495,"featurePriority":495,"head":495,"hideCta":508,"landingPath":495,"meta":3716,"navigation":508,"ogImage":495,"path":3722,"robots":495,"schemaOrg":495,"seo":3723,"sitemap":3724,"stem":3725,"tags":3726,"__hash__":3728},"blog/blog/1011.a-gentle-introduction-to-ai-agents-for-the-web.md","A Gentle Introduction to AI Agents for the Web",{"type":8,"value":3240,"toc":3695},[3241,3259,3263,3271,3276,3279,3283,3286,3306,3310,3319,3323,3339,3344,3347,3351,3362,3366,3369,3373,3380,3384,3407,3411,3415,3418,3421,3425,3446,3449,3453,3457,3466,3477,3482,3486,3495,3498,3502,3505,3508,3512,3525,3528,3532,3541,3544,3548,3552,3555,3559,3563,3566,3639,3641,3644,3658],[11,3242,3243,3248,3249,3248,3253,3258],{},[536,3244,3247],{"href":3245,"rel":3246},"https://openai.com/index/introducing-operator/",[540],"Operator",", ",[536,3250,335],{"href":3251,"rel":3252},"https://browser-use.com/",[540],[536,3254,3257],{"href":3255,"rel":3256},"https://www.skyvern.com/",[540],"Skyvern"," – we are currently witnessing an evolution of autonomous web browsing agents. The concept of agents is, in general, ubiquitous in the era of AI.",[59,3260,3262],{"id":3261},"what-is-an-agent","What is an Agent?",[11,3264,3265,3266,280],{},"An agent is an entity that acts on behalf of another entity – its principal. Robotic agents are modelled after humans: they perceive the world and act in it to achieve a specified goal. Whilst humans perceive through their senses, agents perceive through sensors; whilst humans act through motor systems (e.g., fingers), agents act through actuators. This terminology has been transferred from hard- to software agents, particularly those premised on artificial intelligence (AI). An agent's purpose, that is, its goal, is clearly defined; the principal interfaces with that goal by assigning the agent tasks",[654,3267,3268],{},[536,3269,662],{"href":658,"ariaDescribedBy":3270,"dataFootnoteRef":461,"id":661},[660],[50,3272],{"alt":3273,"loading":55,"src":3274,"provider":57,":width":3275},"Figurative comparison of component equivalents between a human and an AI agent","/blog/a-gentle-introduction-to-ai-agents-for-the-web/1.svg","430",[11,3277,3278],{},"The analogy is more than decorative: an agent takes over the tool-use expertise, leaving the principal with only the domain expertise. Traditional software applications like Photoshop demand both.",[94,3280,3282],{"id":3281},"what-makes-an-agent-intelligent","What Makes an Agent Intelligent?",[11,3284,3285],{},"For acting on behalf of a human, developing an agent could be as simple as making it follow a hardcoded sequence of actions. This describes process automation, but not an artificially intelligent agent. Whilst definitions for AI differ, agent intelligence comes from making informed decisions that are not hardcoded. Here are common – not necessarily mutually exclusive – high-level approaches to induce intelligence:",[22,3287,3288,3294,3300],{},[25,3289,3290,3293],{},[28,3291,3292],{},"Search"," – the agent has a complete or heuristic model of the world and the action space to anticipate the effects of actions and search for a goal state.",[25,3295,3296,3299],{},[28,3297,3298],{},"Reinforcement learning"," – the agent has an initial action space and iteratively discovers the world and effects of actions, learning an optimal policy to act in order to reach a goal state.",[25,3301,3302,3305],{},[28,3303,3304],{},"Neural networks"," – the agent has no model, only examples: a network is fitted to task–solution instances and generalises to unseen, yet related tasks.",[94,3307,3309],{"id":3308},"a-quick-note-on-multi-agent-systems","A Quick Note on Multi-Agent Systems",[11,3311,3312,3313,3318],{},"Agent design gets an additional edge when other entities act in the same world as the agent. Such entities can be considered agents on their own. Their beliefs and goals might affect the agent: cooperative agents share the designed agent's goal, whilst adversarial agents have an opposite goal. In a zero-sum game, an adversarial agent maximises the exact inverse of the designed agent's utility. Knowing this, the designed agent needs to anticipate intelligent decisions by the adversary (e.g., by applying the ",[536,3314,3317],{"href":3315,"rel":3316},"https://cs.stanford.edu/people/eroberts/courses/soco/projects/2003-04/intelligent-search/minimax.html",[540],"Minimax algorithm","), as opposed to random world changes. That said, web browsing – modelled after humans – is not a typical multi-agent scenario.",[94,3320,3322],{"id":3321},"the-agent-loop","The Agent Loop",[11,3324,3325,3330,3331,3338],{},[536,3326,3329],{"href":3327,"rel":3328},"https://www.nngroup.com/people/don-norman/",[540],"Don Norman","'s ",[536,3332,3335],{"href":3333,"rel":3334},"https://jnd.org/books/the-design-of-everyday-things-revised-and-expanded-edition/",[540],[548,3336,3337],{},"Seven Stages of Action"," is a model of the human cognition cycle that generalises to an agent's lifecycle – the agent loop: with a (1) goal, (2) intent to act, (3) plan actions, (4) execute the action plan – this alters the world – then (5) perceive the new world state, (6) interpret the perception, and finally (7) evaluate the interpretation – report task success or an irrevocable failure; continue the cycle if the world state not yet reflects a goal state.",[50,3340],{"alt":3341,"loading":55,"src":3342,"provider":57,":width":3343},"Don Norman's Seven Stages of Action – a model of human cognition","/blog/a-gentle-introduction-to-ai-agents-for-the-web/2.svg","500",[11,3345,3346],{},"Humans can run many of these cycles hierarchically, with increasing frequency the smaller the task. Take driving a car as an example: choosing a route runs on the order of minutes, choosing when to change lanes on seconds, and holding the car in its lane on fractions of a second. A cycle for holding the lane (1) is: intent to actively hold the lane (2), plan to keep the steering wheel straight, then watch the road (3), execute plan (4), observe the road (5), check whether the car is in the lane (6), if not, cycle again with an adjusted action plan (e.g., slightly rotate the steering wheel to the right) (7).",[94,3348,3350],{"id":3349},"errors-and-recovery","Errors and Recovery",[11,3352,3353,3354,3357,3358,3361],{},"Precisely speaking, \"to err is human\" means that errors are inevitable when heuristically navigating the world. Consequently, AI agents regularly run into errors, too. Norman's Seven Stages of Action make two error spaces apparent: when executing an action plan; the ",[548,3355,3356],{},"Gulf of Action (Execution)"," – how to act in the world? – and when perceiving world state; the ",[548,3359,3360],{},"Gulf of Perception (Evaluation)"," – how to understand the world?",[50,3363],{"alt":3364,"loading":55,"src":3365,"provider":57,":width":3343},"The Gulf of Action (Execution) and  Perception (Evaluation) in Don Norman's Seven Stages of Action","/blog/a-gentle-introduction-to-ai-agents-for-the-web/3.svg",[11,3367,3368],{},"There are two notable kinds of errors within the Gulf of Action: mistakes and slips. A mistake occurs when the action plan is wrong, although executing this action plan might go right in itself. A slip occurs when the action plan is right, but the execution goes wrong. Here is an example: stopping a manual-shift car without pressing the clutch. This error describes a mistake if the driver did not know about the need to press the clutch, e.g., because they only knew how to operate automatic-drive cars. It is, in turn, a slip if they simply forgot to press the clutch because of fatigue. Since cognition cycles are hierarchic, most errors can be recovered within a cycle. Hearing a choking engine sound, the driver might adjust the action plan and press the clutch late. Errors that cannot be recovered – picture the car's engine dying – require adjusting the goal, which can be seen as moving on to a new cycle.",[59,3370,3372],{"id":3371},"web-browsing-agents","Web Browsing Agents",[11,3374,3375,3376,3379],{},"The advent of large language models (LLMs) has recently opened a new perspective on developing web agents – falling back on the neural networks approach to intelligence. An LLM can serve as a plug-in reasoning backend: given a task and somehow encoded UI state, it can suggest input actions – type and target, e.g., click at ",[264,3377,3378],{},"(200, 375)"," – that progress the given task. Moreover, it can decide whether a goal state has been reached. Providing a state-and-action history within context conveys to the model prior outcomes and contributes to in-context learning.",[94,3381,3383],{"id":3382},"web-browsing-is-all-about-the-journey","Web Browsing is All About the Journey",[11,3385,3386,3387,3390,3391,3396,3397,3402,3403,3406],{},"A web browsing task is any task that can be solved through a web-based user interface (UI). For instance: ",[548,3388,3389],{},"\"Book the cheapest flight from Amsterdam to New York tomorrow night\""," on ",[536,3392,3395],{"href":3393,"rel":3394},"https://www.klm.com",[540],"klm.com",". Application programming interfaces (APIs; e.g., ",[536,3398,3401],{"href":3399,"rel":3400},"https://www.ibm.com/think/topics/rest-apis",[540],"REST APIs",") are often restricted, incomplete, or unavailable. For that reason, web browsing agents today have to rely on human-facing web application UIs. Many agent use cases, such as for customer experience, even require a human in the loop. In this context, web browsing agents come at two levels: outcome-driven agents care only about reaching a goal state, which favours shortcuts like direct URL navigation or expert navigation like ",[264,3404,3405],{},"Ctrl + F",", whilst journey-driven agents are supposed to browse a web application in human fashion, via the application-native UI.",[50,3408],{"alt":3409,"loading":55,"src":3410},"A depiction of a web journey over three web application UI states","/blog/a-gentle-introduction-to-ai-agents-for-the-web/4.png",[94,3412,3414],{"id":3413},"a-formal-model-for-web-browsing","A Formal Model for Web Browsing",[11,3416,3417],{},"The world of web application UIs is hard to formalise; a complete model spans the union of every reachable UI state in every web application on the web. For that reason, conventional AI has failed to produce capable generalist web agents. From a web agent design perspective, however, an abstract model of web browsing is sufficient.",[11,3419,3420],{},"Web browsing might afford a model that is history-independent. A human could certainly pick up a partially completed browsing task. For example, completing the payment process on an airline website for an already selected flight – assuming prior actions were correct with respect to the specified task (e.g., the selected destination).",[50,3422],{"alt":3423,"loading":55,"src":3424},"Screenshot of the payment page on klm.com that reflects outcomes of prior actions and affords next actions","/blog/a-gentle-introduction-to-ai-agents-for-the-web/5.png",[11,3426,3427,3428,3433,3434,3439,3440,3445],{},"Yet, many web applications lack ",[536,3429,3432],{"href":3430,"rel":3431},"https://www.nngroup.com/articles/ten-usability-heuristics/#toc-1-visibility-of-system-status-1",[540],"visibility of system status"," – against ",[536,3435,3438],{"href":3436,"rel":3437},"https://www.nngroup.com/people/jakob-nielsen/",[540],"Jakob Nielsen","'s first heuristic for UI usability. Visibility of system status comprises reflecting both outcomes of prior actions and affordances for next actions in the UI. With this concept, web browsing is best described as a partially observable Markov decision process (POMDP)",[654,3441,3442],{},[536,3443,684],{"href":681,"ariaDescribedBy":3444,"dataFootnoteRef":461,"id":683},[660]," with, adapting to discovered UI states, where states can be tuples of UI state trajectories to contain history.",[11,3447,3448],{},"Reflex agents take actions that solely depend on the current world state. Planning agents, in turn, plan ahead. For most web browsing tasks, future UI states are roughly predictable, given that web journeys are similar across different web applications that help with similar tasks. In POMDP terms, the expected next UI state has a high probability, whilst unexpected states remain with a non-negligible probability. The further a web journey is progressed, the higher the probability of the next expected UI state gets: the flight selection step is likely followed by the passenger details step, which is even more likely followed by the payment step.",[50,3450],{"alt":3451,"loading":55,"src":3452},"Graph-based web journey representation of an unknown, adaptive, partially observable Markov decision process (POMDP)","/blog/a-gentle-introduction-to-ai-agents-for-the-web/6.png",[94,3454,3456],{"id":3455},"llm-sensors-actuators-agent","LLM + Sensors + Actuators = Agent",[11,3458,3459,3460,3465],{},"Conversationally satisfying simple information requests does not reasonably qualify an LLM as an agent – no more than it would a TF-IDF search system",[654,3461,3462],{},[536,3463,699],{"href":696,"ariaDescribedBy":3464,"dataFootnoteRef":461,"id":698},[660],", or a colleague telling you the time. The web agent LLM backend is metaphorically the brain of the agent. It abstracts the world model and state transition function, and can decide whether a goal state was reached.",[11,3467,3468,3469,3248,3471,3248,3473,3476],{},"Turning an LLM into a web agent means, at the core, connecting it with sensors and actuators, for example, the ability to take DOM snapshots and dispatch clicks via CSS selectors. This is a specialised architecture of LLM tool calling. The set of available input actions is known from human computer use: ",[548,3470,550],{},[548,3472,553],{},[548,3474,3475],{},"scrolling",", etc. The agent loop is then a continuous cycle of serialising UI state for the model to elicit action suggestions under a goal derived from the user-specified task.",[50,3478],{"alt":3479,"loading":55,"src":3480,"provider":57,":width":3481},"Figurative depiction of components in the agent loop","/blog/a-gentle-introduction-to-ai-agents-for-the-web/7.svg","460",[94,3483,3485],{"id":3484},"snapshots-serialised-ui-state","Snapshots – Serialised UI State",[11,3487,3488,3489,3494],{},"There are plenty of ways to serialise the state of a web-based UI – referred to as a snapshot. A screenshot resembles what humans see when viewing a web page's graphical UI (GUI) at a given point in time. That said, a UI can be represented in versatile ways. LLMs have demonstrated the ability to interpret HTML and even navigate a UI encoded in this way",[654,3490,3491],{},[536,3492,1192],{"href":1189,"ariaDescribedBy":3493,"dataFootnoteRef":461,"id":1191},[660],". The document object model (DOM) is a web browser's runtime model of a web page. Serialised as HTML, to that effect, DOM snapshots represent a compelling alternative to GUI snapshots, offering certain advantages, such as processability (e.g., filtering). Filtering the DOM by pruning hidden, disabled, or redundant subtrees saves LLM communication costs and works towards more stable and predictable journeys.",[11,3496,3497],{},"Outcome-driven web agents have used UI-invasive snapshot measures, such as grounding LLMs with bounding boxes around actionable elements.",[50,3499],{"alt":3500,"loading":55,"src":3501},"Example of a screenshot (GUI snapshot) with coloured bounding boxes that visually ground an LLM","/blog/a-gentle-introduction-to-ai-agents-for-the-web/8.png",[11,3503,3504],{},"The ideal snapshot representation depends on the task. To get an idea, classify between navigation and information retrieval tasks: navigation tasks require snapshots to preserve actionable elements, whilst retrieval tasks require them to preserve text – both can be sourced from DOM snapshots. Accessibility tree snapshots are another DOM-sourced representation. Web UIs rarely afford merely a single task, so many of their components are noise in any given snapshot – which is not just a UI serialisation, but one scoped to the task at hand. GUI snapshots become a necessity when the target application is graphics-based, such as a canvas-based application like Google Maps.",[11,3506,3507],{},"A snapshot impacts the width of Norman's Gulf of Perception: if a relevant element is omitted or diffused, the model is hindered in identifying correct actions to progress a web browsing task. The Gulf of Action mostly grows when the snapshot-encoded UI state and the live UI state have irrecoverably drifted apart. The agent loop should be fast to prevent such drift. The Gulf of Perception is much wider by the nature of the problem: what snapshot representation can an LLM interpret, and which representation is best?",[94,3509,3511],{"id":3510},"targeting-action-suggestions","Targeting – Action Suggestions",[11,3513,3514,3515,3248,3517,3520,3521,3524],{},"An action is a user event, such as ",[548,3516,605],{},[548,3518,3519],{},"type",", or ",[548,3522,3523],{},"scroll",", targeting a specific element in the UI. The set of available actions thereby is defined by the accepted user input types which are generally derived and standardised over the mouse and keyboard devices.",[11,3526,3527],{},"The type of snapshot representation provided to an LLM dictates how an element can be targeted for an action. Vision-based, geometric targeting is indirect and absolute, i.e., by coordinates. DOM-based targeting is direct and relative, e.g., by CSS selectors or object references. Relative targeting remains valid if the UI shifts between snapshot and action time. A shift can happen due to many reasons, for instance, a lazy-loaded image.",[94,3529,3531],{"id":3530},"the-agent-harness","The Agent Harness",[11,3533,3534,3535,3540],{},"Any custom logic that sits between the LLM backend and the web page UI (problem world) is considered an agent harness – often linguistically equated with the agent in general. Common aspects of a harness include task decomposition, model routing, snapshot creation, history management, error recovery, and timeouts. ",[536,3536,3539],{"href":3537,"rel":3538},"https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents",[540],"System prompts"," are also part of the harness, instructing a general-purpose LLM to model a web agent for a specific domain – right in context.",[11,3542,3543],{},"Designing a harness is where the POMDP and Seven Stages of Action models come into play. The POMDP model helps with context engineering, for instance, how much history to provide to the LLM. The Seven Stages of Action set out problem components and artefacts, for example, the LLM or snapshots, respectively.",[50,3545],{"alt":3546,"loading":55,"src":3547,"provider":57},"Don Norman's Seven Stages of Action mapped to the agentic web browsing problem","/blog/a-gentle-introduction-to-ai-agents-for-the-web/9.svg",[94,3549,3551],{"id":3550},"the-model-context-protocol","The Model Context Protocol",[11,3553,3554],{},"LLM providers commonly offer a structured output interface, which allows eliciting well-formed action suggestions from an LLM. A client can subsequently parse and drive these suggested actions in the live user interface. Through the model context protocol (MCP) – another web-based RPC standard – structured output can be bridged with tools that LLMs can call directly, without an extra client trip.",[50,3556],{"alt":3557,"loading":55,"src":3558,"provider":57,":width":3343},"Figurative depiction of components in the agent loop using the model context protocol (MCP)","/blog/a-gentle-introduction-to-ai-agents-for-the-web/10.svg",[94,3560,3562],{"id":3561},"web-browser-environments","Web Browser Environments",[11,3564,3565],{},"When connected to web perception and actuation tools via MCP, an ordinary AI chat UI already qualifies as an agent UI; the MCP integration decides where the actual web browser runs. There are several types of browser runtime environment:",[22,3567,3568,3583,3595,3607],{},[25,3569,3570,3573,3574,3577,3578],{},[28,3571,3572],{},"Agentic browser"," – the agent's UI embeds a browser.",[3575,3576],"br",{},"\nExample: ",[536,3579,3582],{"href":3580,"rel":3581},"https://www.perplexity.ai/comet",[540],"Perplexity Comet",[25,3584,3585,3588,3589,3577,3591],{},[28,3586,3587],{},"Cloud browser"," – the agent spins up a browser in the cloud.",[3575,3590],{},[536,3592,137],{"href":3593,"rel":3594},"https://www.browserbase.com",[540],[25,3596,3597,3600,3601,3577,3603],{},[28,3598,3599],{},"Local browser (3rd-party browser)"," – the agent spins up an isolated browser locally.",[3575,3602],{},[536,3604,3606],{"href":538,"rel":3605},[540],"Chromium + Playwright",[25,3608,3609,3612,3613],{},[28,3610,3611],{},"Local browser (1st-party browser)"," – the agent is embedded within a web application running in a user's personal browser, e.g., in the form of a chatbot.\n",[22,3614,3615,3628],{},[25,3616,3617,3620,3621,3577,3623],{},[28,3618,3619],{},"Implemented (1st-party app)"," – served directly through the website.",[3575,3622],{},[536,3624,3627],{"href":3625,"rel":3626},"https://www.cognigy.com/platform/ai-agent-studio",[540],"Cognigy Studio",[25,3629,3630,3633,3634,3577,3636],{},[28,3631,3632],{},"Augmented (3rd-party app)"," – served indirectly through a website proxy.",[3575,3635],{},[536,3637,244],{"href":544,"rel":3638},[540],[3076,3640],{},[11,3642,3643],{},"Building AI agents has been approached from different angles. LLMs have opened up new perspectives on the design and development of AI agents, particularly web agents, which work in a problem domain that is hard to grasp with a formal model. Whilst higher-level agent methodology can borrow much from established research, LLMs have introduced new challenges, such as how to take UI state snapshots for eliciting input action suggestions from such models.",[11,3645,3646,3647,3652,3653,280],{},"At Webfuse, we research agentic web browsing and develop a platform for agentic browsing. Our web application reverse proxy allows LLMs to perceive and act on the live web. Use cases include connecting a chat UI like ",[536,3648,3651],{"href":3649,"rel":3650},"https://claude.com/",[540],"Claude",", or shipping ",[536,3654,3657],{"href":3655,"rel":3656},"https://github.com/webfuse-com/extension-elevenlabs-mcp",[540],"perceive-and-act-ready chatbots",[956,3659,3661,3664],{"className":3660,"dataFootnotes":461},[3098],[59,3662,3103],{"className":3663,"id":660},[3102],[1706,3665,3666,3675,3681,3687],{},[25,3667,3668,3113,3672],{"id":3108},[536,3669,3670],{"href":3670,"rel":3671},"https://inst.eecs.berkeley.edu/~cs188/textbook/textbook_full.pdf",[540],[536,3673,3120],{"href":3116,"ariaLabel":3117,"className":3674,"dataFootnoteBackref":461},[3119],[25,3676,3677,3678],{"id":3123},"A POMDP is a decision process in which the agent cannot see the exact world state, only partial observations of it, and so must choose actions against a probability distribution over the states it might be in. ",[536,3679,3120],{"href":3131,"ariaLabel":3132,"className":3680,"dataFootnoteBackref":461},[3119],[25,3682,3683,3684],{"id":3136},"TF-IDF (term frequency-inverse document frequency) is an information retrieval method that ranks documents by how often a query term occurs in each one, weighted down by how common that term is across the whole collection – so terms that are frequent here but rare elsewhere carry the most weight. ",[536,3685,3120],{"href":3143,"ariaLabel":3144,"className":3686,"dataFootnoteBackref":461},[3119],[25,3688,3689,3113,3692],{"id":3148},[536,3690,3139],{"href":3139,"rel":3691},[540],[536,3693,3120],{"href":3155,"ariaLabel":3156,"className":3694,"dataFootnoteBackref":461},[3119],{"title":461,"searchDepth":462,"depth":462,"links":3696},[3697,3703,3713],{"id":3261,"depth":462,"text":3262,"children":3698},[3699,3700,3701,3702],{"id":3281,"depth":468,"text":3282},{"id":3308,"depth":468,"text":3309},{"id":3321,"depth":468,"text":3322},{"id":3349,"depth":468,"text":3350},{"id":3371,"depth":462,"text":3372,"children":3704},[3705,3706,3707,3708,3709,3710,3711,3712],{"id":3382,"depth":468,"text":3383},{"id":3413,"depth":468,"text":3414},{"id":3455,"depth":468,"text":3456},{"id":3484,"depth":468,"text":3485},{"id":3510,"depth":468,"text":3511},{"id":3530,"depth":468,"text":3531},{"id":3550,"depth":468,"text":3551},{"id":3561,"depth":468,"text":3562},{"id":660,"depth":462,"text":3103},"2025-06-15","Get an idea of agents and how to build AI agents that browse the web: key concepts, terminology, and challenges.",{"homepage":508,"relatedLinks":3717},[3718,3720,3721],{"text":3719,"href":3227},"Serialising Web UI State for LLMs",{"text":3222,"href":3223},{"text":3225,"href":3226,"external":508},"/blog/a-gentle-introduction-to-ai-agents-for-the-web",{"title":3238,"description":3715},{"loc":3722},"blog/1011.a-gentle-introduction-to-ai-agents-for-the-web",[477,3727,514,3232,3233],"browser-agents","65hAoQNete8P3AgO-H42P0eBhVfIkl5vIfZZAkvL-9o",1788255644857]