[{"data":1,"prerenderedAt":3948},["ShallowReactive",2],{"/blog/how-do-i-build-an-ai-agent-that-works-on-a-website-i-dont-own":3,"related-/blog/how-do-i-build-an-ai-agent-that-works-on-a-website-i-dont-own":757},{"id":4,"title":5,"authorId":6,"body":7,"category":705,"created":706,"description":707,"extension":708,"faqs":709,"featurePriority":731,"head":732,"hideCta":733,"landingPath":732,"meta":734,"navigation":746,"ogImage":732,"path":747,"robots":732,"schemaOrg":732,"seo":748,"sitemap":749,"stem":750,"tags":751,"__hash__":756},"blog/blog/1052.how-do-i-build-an-ai-agent-that-works-on-a-website-i-dont-own.md","How Do I Build an AI Agent That Works on a Website I Don't Own?","salome-koshadze",{"type":8,"value":9,"toc":687},"minimark",[10,19,22,56,61,64,67,70,98,101,110,114,117,130,139,149,153,156,164,170,173,196,201,204,208,211,214,219,222,225,246,249,253,256,259,263,266,274,278,281,389,396,400,403,411,414,418,421,424,428,431,434,437,442,445,462,465,469,472,475,495,498,505,509,512,515,518,522,525,528,662,665,669,672,677,680,683],[11,12,13,14,18],"p",{},"You can connect an AI agent to a third-party website through a browser execution layer. The agent reads the current page, chooses an action, sends that action to the browser, checks the result, and repeats. ",[15,16,17],"strong",{},"The target site does not need to expose an API or add code for your agent"," when the execution layer works through the site's existing interface.",[11,20,21],{},"This guide covers the build: what the execution layer has to handle, how to wire an agent to a live session over MCP, how to write the action policy that keeps it inside its lane, and what to test before it touches real users.",[23,24,26,32,38,44,50],"tldr-box",{"title":25},"TL;DR",[11,27,28,31],{},[15,29,30],{},"The model is not the hard part. The execution layer is."," An agent on a site you do not own needs current page evidence, a restricted action set, a check after every change, and a route back to the user.",[11,33,34,37],{},[15,35,36],{},"Decide where the browser runs first."," An isolated browser suits scraping, testing and scheduled work. A live session suits support, onboarding and voice assistance, where the person is already on the page.",[11,39,40,43],{},[15,41,42],{},"With Webfuse the build path is short:"," create a Space, enable the Automation app, protect the Space key, connect an MCP client, bind it to a Session.",[11,45,46,49],{},[15,47,48],{},"Write the action policy before the prompt."," What the agent may read, what it may change, and where it must stop.",[11,51,52,55],{},[15,53,54],{},"Stop before commitment."," Prepare the task, show a review screen, leave submission and payment to the user.",[57,58,60],"h2",{"id":59},"what-a-website-i-dont-control-means-in-practice","What \"a website I don't control\" means in practice",[11,62,63],{},"Ownership changes what you can ask the target site to do. On your own product, your team can add an SDK, publish an API, expose WebMCP tools, add stable element identifiers, or change the interface when automation fails. A third-party site gives you none of those guarantees.",[11,65,66],{},"Your agent still needs a dependable way to observe and act. The site may use a single-page framework, delayed content, embedded frames, custom controls, changing class names, or a login flow that resists a fresh browser.",[11,68,69],{},"A workable setup handles four jobs. Each one affects reliability, response time, and how much access the agent gets.",[71,72,73,80,86,92],"ol",{},[74,75,76,79],"li",{},[15,77,78],{},"Read the active page state."," The model needs useful information about headings, fields, buttons, links, dialogs, validation messages, and loading state.",[74,81,82,85],{},[15,83,84],{},"Take browser actions."," It needs tools for opening URLs, clicking, typing, selecting options, scrolling, and capturing a visual check.",[74,87,88,91],{},[15,89,90],{},"Keep session context."," Most useful tasks happen after login and span more than one page.",[74,93,94,97],{},[15,95,96],{},"Return control to a person."," The user needs a clear way to review, correct, approve, or finish the task.",[11,99,100],{},"The model does not solve these browser problems. It can decide that a form needs a postal code, but an execution layer still has to locate the field, enter the value, detect an error, and report the new state.",[11,102,103,104,109],{},"A script injected straight into the page is the setup that looks easiest and breaks first. Class names move, components render late, overlays cover controls, cross-origin frames close off, and framework state does not always react to a synthetic event the way it reacts to real input. Our write-up on ",[105,106,108],"a",{"href":107},"/blog/challenges-of-building-reliable-voice-ai-agents-on-live-websites","reliability challenges for agents on live websites"," goes through those failure modes in detail. Treat selectors as observations rather than contracts: prefer semantic labels and accessibility information, wait for the page to settle, and check the outcome after every action that can change the interface.",[57,111,113],{"id":112},"where-the-browser-runs","Where the browser runs",[11,115,116],{},"Two decisions shape everything downstream: where the browser runs, and whose session it uses. Those settle authentication, visibility, latency and deployment work before you write a line of code.",[11,118,119,120,124,125,129],{},"A headless browser opens a separate instance. A browser extension connects the agent to a person's local browser. WebMCP depends on tools published by the target site. A live-session system such as Webfuse connects the agent to the browser session the person is already using. We compare all of them in ",[105,121,123],{"href":122},"/blog/how-to-connect-an-ai-agent-to-the-live-web","How to Connect an AI Agent to the Live Web",", and the MCP servers that implement them in ",[105,126,128],{"href":127},"/blog/the-top-5-best-mcp-servers-for-ai-agent-browser-automation","6 Best MCP Servers for Browser Automation",".",[131,132],"nuxt-picture",{":height":133,":width":134,"alt":135,"loading":136,"provider":137,"src":138},"600","880","Comparison diagram titled \"Four execution layers, one target site\" showing headless browser, browser extension, WebMCP and live session as four columns, each with the agent, its execution layer and the target website stacked, and a check or cross against no site change needed, user sees each action, and no install for the user, with the live session column highlighted as the one this guide follows","lazy","none","/blog/how-do-i-build-an-ai-agent-that-works-on-a-website-i-dont-own/3.svg",[11,140,141,142,148],{},"The rest of this guide builds on live-session actuation, because that is the model that fits user-facing work on a site you do not own: no code on the target site, no extension for the user to install, and the person can watch and take over. Webfuse's ",[105,143,147],{"href":144,"rel":145},"https://dev.webfuse.com/session-mcp-server",[146],"nofollow","Session MCP documentation"," covers the tool surface, an MCP-compatible agent can open URLs, read pages, fill forms, click, select text and capture screenshots without changing the underlying site.",[57,150,152],{"id":151},"how-the-webfuse-connection-works","How the Webfuse connection works",[11,154,155],{},"A Webfuse Space holds the configuration for one class of sessions. It controls installed apps, access settings, and the browser tools available to an agent. Each live Session runs from that configuration, so one Space supports many separate user sessions.",[11,157,158,159,129],{},"Inside a Session, the Automation app exposes browser actions. The Session MCP endpoint makes those actions available to an MCP client, giving the model a standard tool interface instead of a custom integration per page. Space creation, Session launch, Automation app setup and MCP connection are documented in the ",[105,160,163],{"href":161,"rel":162},"https://dev.webfuse.com/getting-started",[146],"Webfuse getting-started guide",[131,165],{":height":166,":width":167,"alt":168,"loading":136,"provider":137,"src":169},"570","900","Architecture diagram titled \"Where the execution layer sits\" showing an AI agent connecting through a Session MCP endpoint with a bearer ak_ key into an Automation Space that configures many live Sessions and its enabled browser tools, the person opening the same live Session in their authenticated browser, and the target website receiving no added code","/blog/how-do-i-build-an-ai-agent-that-works-on-a-website-i-dont-own/4.svg",[11,171,172],{},"The action cycle runs like this:",[71,174,175,178,181,184,187,190,193],{},[74,176,177],{},"The user opens a Webfuse Session.",[74,179,180],{},"The agent connects to the Session through MCP.",[74,182,183],{},"The agent requests the current page state.",[74,185,186],{},"The model chooses one browser action.",[74,188,189],{},"Webfuse applies the action in the live page.",[74,191,192],{},"The agent reads the changed state and checks the result.",[74,194,195],{},"The agent continues, asks for help, or hands control back.",[131,197],{":height":198,":width":134,"alt":199,"loading":136,"provider":137,"src":200},"610","Cycle diagram titled \"The agent action loop\" showing observe the current page state, decide on exactly one action, act through Webfuse in the live page, and verify by re-reading state, circling a live session at the centre, with a note to stop and hand control back when the effect cannot be confirmed","/blog/how-do-i-build-an-ai-agent-that-works-on-a-website-i-dont-own/2.svg",[11,202,203],{},"That loop matters more than a long prompt. An agent that fires three clicks off one stale page snapshot will miss the dialog, validation error or route change that the first click produced. Reading state again after each material action gives the model current evidence.",[57,205,207],{"id":206},"a-practical-build-sequence","A practical build sequence",[11,209,210],{},"Start with one narrow task on one known site. \"Help with any task on any website\" creates too many unknowns for a first test. \"Find an appointment, fill the non-sensitive fields, then stop before booking\" gives you a clear path and a measurable result.",[11,212,213],{},"Keep the first workflow short enough to inspect step by step. Once it holds up across normal and error cases, extend the scope.",[215,216,218],"h3",{"id":217},"_1-define-the-task-boundary","1. Define the task boundary",[11,220,221],{},"Write down what the agent may read, what it may change, and where it must stop. This boundary becomes the basis for tool access, prompts, tests and human approval.",[11,223,224],{},"Keep each answer concrete enough that a tester can mark it pass or fail.",[226,227,228,231,234,237,240,243],"ul",{},[74,229,230],{},"Which domains and paths may the session open?",[74,232,233],{},"Which fields may the agent read or edit?",[74,235,236],{},"Which actions need user approval?",[74,238,239],{},"Can the agent submit a form, or must it stop on the review screen?",[74,241,242],{},"What happens after a login prompt, CAPTCHA, access denial, or changed layout?",[74,244,245],{},"How does the user take control?",[11,247,248],{},"A shopping assistant might search products and add selected items to a basket, then stop before payment. An HR assistant might read a leave calendar but have no access to salary, banking or medical pages.",[215,250,252],{"id":251},"_2-create-a-space-and-enable-browser-tools","2. Create a Space and enable browser tools",[11,254,255],{},"Create an Automation Space in Webfuse Studio, open a Session, and enable the Automation app. The configuration can expose all browser tools or a reduced set. A read-only helper may need page inspection and screenshots but no typing or clicking.",[11,257,258],{},"For an agent that takes actions, grant only the tools the task requires. Tool access is changed in the Automation app settings and applies across Sessions in that Space.",[215,260,262],{"id":261},"_3-create-and-protect-the-automation-key","3. Create and protect the automation key",[11,264,265],{},"Generate a Space Automation API key in the Space settings. The key grants remote control over Sessions linked to that Space, so store it in a secret manager and keep it out of client-side code, URLs, prompts and logs.",[11,267,268,269,273],{},"Webfuse marks this key with the ",[270,271,272],"code",{},"ak_"," prefix and uses it as a bearer token for the Session MCP endpoint. It is full remote-control access, which makes key scope and storage part of the security design rather than a setup detail.",[215,275,277],{"id":276},"_4-connect-the-mcp-client","4. Connect the MCP client",[11,279,280],{},"An MCP-compatible host connects to the Session endpoint over HTTP. Replace the hostname and secret placeholders with values from your Space, and keep the secret in an environment-backed input rather than a checked-in file.",[282,283,288],"pre",{"className":284,"code":285,"language":286,"meta":287,"style":287},"language-json shiki shiki-themes github-dark github-dark","{\n  \"servers\": {\n    \"webfuse-session\": {\n      \"type\": \"http\",\n      \"url\": \"https://session-mcp.HOSTNAME/mcp\",\n      \"headers\": {\n        \"Authorization\": \"Bearer ${input:automation_key}\"\n      }\n    }\n  }\n}\n","json","",[270,289,290,299,309,317,333,346,354,365,371,377,383],{"__ignoreMap":287},[291,292,295],"span",{"class":293,"line":294},"line",1,[291,296,298],{"class":297},"suv1-","{\n",[291,300,302,306],{"class":293,"line":301},2,[291,303,305],{"class":304},"s8ozJ","  \"servers\"",[291,307,308],{"class":297},": {\n",[291,310,312,315],{"class":293,"line":311},3,[291,313,314],{"class":304},"    \"webfuse-session\"",[291,316,308],{"class":297},[291,318,320,323,326,330],{"class":293,"line":319},4,[291,321,322],{"class":304},"      \"type\"",[291,324,325],{"class":297},": ",[291,327,329],{"class":328},"s4wv1","\"http\"",[291,331,332],{"class":297},",\n",[291,334,336,339,341,344],{"class":293,"line":335},5,[291,337,338],{"class":304},"      \"url\"",[291,340,325],{"class":297},[291,342,343],{"class":328},"\"https://session-mcp.HOSTNAME/mcp\"",[291,345,332],{"class":297},[291,347,349,352],{"class":293,"line":348},6,[291,350,351],{"class":304},"      \"headers\"",[291,353,308],{"class":297},[291,355,357,360,362],{"class":293,"line":356},7,[291,358,359],{"class":304},"        \"Authorization\"",[291,361,325],{"class":297},[291,363,364],{"class":328},"\"Bearer ${input:automation_key}\"\n",[291,366,368],{"class":293,"line":367},8,[291,369,370],{"class":297},"      }\n",[291,372,374],{"class":293,"line":373},9,[291,375,376],{"class":297},"    }\n",[291,378,380],{"class":293,"line":379},10,[291,381,382],{"class":297},"  }\n",[291,384,386],{"class":293,"line":385},11,[291,387,388],{"class":297},"}\n",[11,390,391,392,395],{},"The agent needs a Session ID for each browser it controls. Webfuse supports a standard mode, where every tool call carries a ",[270,393,394],{},"session_id",", and a dynamic mode, where the MCP connection binds to a Session before loading the full tool set.",[215,397,399],{"id":398},"_5-give-the-agent-an-action-policy","5. Give the agent an action policy",[11,401,402],{},"Tool access defines what the agent can technically do. The action policy defines what it may do in the workflow, and when it has to ask. Keep the policy shorter than the website instructions: browser state changes, the policy should not.",[282,404,409],{"className":405,"code":407,"language":408},[406],"language-text","Goal: Find the requested service and prepare the form for review.\n\nAllowed:\n- Open pages within the approved domain.\n- Read labels, availability, and validation messages.\n- Fill non-sensitive fields supplied by the user.\n\nAsk before:\n- Accepting terms.\n- Uploading a file.\n- Sending personal data not already visible in the Session.\n\nStop before:\n- Final submission.\n- Payment.\n- Account or password changes.\n\nIf blocked:\n- Report the visible message.\n- Ask the user to take control.\n- Do not retry the same action more than once without new page evidence.\n","text",[270,410,407],{"__ignoreMap":287},[11,412,413],{},"Back the policy with technical restrictions: reduced tool access, domain controls, data masking, approval gates and session logs.",[215,415,417],{"id":416},"_6-verify-each-material-action","6. Verify each material action",[11,419,420],{},"After typing, read the field value or nearby confirmation. After clicking, check the new heading, URL, dialog or status message. After adding an item, check the basket count and item details.",[11,422,423],{},"This observe-act-check pattern catches wrong targets early, before one incorrect click turns into a chain of later mistakes.",[57,425,427],{"id":426},"logged-in-sessions-and-user-credentials","Logged-in sessions and user credentials",[11,429,430],{},"Most useful workflows start after authentication. A headless browser needs its own login flow or a transferred browser profile, which is extra work and more exposure of session material.",[11,432,433],{},"A live session takes another route. The user signs in through the session, then the agent acts in that same context. The model works on the resulting interface without ever seeing the raw password.",[11,435,436],{},"That is not the same as the agent having no access to sensitive data. Once logged in, pages can expose names, addresses, account records, tokens in URLs and private messages. Limit page scope, mask sensitive elements before model access where the platform supports it, and do not log full snapshots without a reason.",[131,438],{":height":439,":width":167,"alt":440,"loading":136,"provider":137,"src":441},"540","Sequence diagram titled \"Who holds control, and where the agent stops\" showing the agent opening the login page, the person signing in so credentials and 2FA never reach the model, the agent resuming to fill approved fields, and a red stop line before payment, submission and account changes that the agent never crosses on its own","/blog/how-do-i-build-an-ai-agent-that-works-on-a-website-i-dont-own/1.svg",[11,443,444],{},"For login and other high-risk steps, this pattern is easy to test and keeps account ownership with the user:",[71,446,447,450,453,456,459],{},[74,448,449],{},"The agent opens the login page.",[74,451,452],{},"The user takes control and authenticates.",[74,454,455],{},"The user returns control once the account page loads.",[74,457,458],{},"The agent completes the approved low-risk steps.",[74,460,461],{},"The agent stops at the final review or transaction screen.",[11,463,464],{},"It fits forms, support portals, benefit systems and e-commerce tasks where a person needs help but should keep control over authentication and final commitment.",[57,466,468],{"id":467},"human-handoff-is-part-of-the-design","Human handoff is part of the design",[11,470,471],{},"An agent working on a live site will meet cases its prompt did not cover. The page changes, a product is unavailable, a policy choice needs judgment, or the user wants a different option.",[11,473,474],{},"In a user-visible Session the person sees the same page and takes over. Define the handoff triggers before testing, because an agent should not keep guessing once it has lost reliable evidence:",[226,476,477,480,483,486,489,492],{},[74,478,479],{},"The page asks for information the user did not supply.",[74,481,482],{},"A login, CAPTCHA, consent step, payment or legal acceptance appears.",[74,484,485],{},"Two actions fail against the same page state.",[74,487,488],{},"The available options differ materially from the request.",[74,490,491],{},"The agent cannot confirm the effect of its last action.",[74,493,494],{},"The site shows a warning, lockout notice or access error.",[11,496,497],{},"A good handoff message states what the agent attempted, what changed, and what the user needs to do next. \"I'm stuck\" is worth less than \"The site requires a one-time code sent to your phone. Please take control, enter it, and return the session to me on the account page.\"",[11,499,500,501,129],{},"For the approval side of this, see ",[105,502,504],{"href":503},"/blog/human-approval-checkpoints-for-ai-agents","Human Approval Checkpoints for AI Agents",[57,506,508],{"id":507},"when-this-is-the-wrong-approach","When this is the wrong approach",[11,510,511],{},"A live Session adds nothing when no person needs to watch, guide or take over. For nightly extraction, load testing, screenshot generation and deterministic checks, a headless browser is simpler.",[11,513,514],{},"Some sites expose direct APIs or WebMCP tools for the exact task. Structured functions give clearer inputs, outputs and error handling than UI interaction, so use them when the site offers them and the workflow does not need visible browser action.",[11,516,517],{},"And check the target site's terms, access rules and your own data obligations before deployment. Technical access is not permission.",[57,519,521],{"id":520},"testing-an-agent-on-a-third-party-site","Testing an agent on a third-party site",[11,523,524],{},"A working happy path proves very little. Readiness depends on how the workflow behaves after delays, layout changes, unavailable options, expired sessions and incomplete user data.",[11,526,527],{},"Build a small test set before broadening the task. For each case, record the expected stop point and the evidence that marks success.",[529,530,531,548],"table",{},[532,533,534],"thead",{},[535,536,537,542,545],"tr",{},[538,539,541],"th",{"align":540},"left","Test",[538,543,544],{"align":540},"Expected behaviour",[538,546,547],{"align":540},"Evidence",[549,550,551,563,574,585,596,607,618,629,640,651],"tbody",{},[535,552,553,557,560],{},[554,555,556],"td",{"align":540},"Normal path",[554,558,559],{"align":540},"Completes approved steps and stops for review",[554,561,562],{"align":540},"Correct page, fields, and summary",[535,564,565,568,571],{},[554,566,567],{"align":540},"Slow content",[554,569,570],{"align":540},"Waits, rereads, then acts",[554,572,573],{"align":540},"No click before target loads",[535,575,576,579,582],{},[554,577,578],{"align":540},"Changed label",[554,580,581],{"align":540},"Uses page meaning instead of a fixed class name",[554,583,584],{"align":540},"Correct control selected",[535,586,587,590,593],{},[554,588,589],{"align":540},"Missing user data",[554,591,592],{"align":540},"Requests the missing value",[554,594,595],{"align":540},"No guessed personal data",[535,597,598,601,604],{},[554,599,600],{"align":540},"Login expires",[554,602,603],{"align":540},"Hands control to the user",[554,605,606],{"align":540},"No repeated login attempts",[535,608,609,612,615],{},[554,610,611],{"align":540},"CAPTCHA appears",[554,613,614],{"align":540},"Stops for human input",[554,616,617],{"align":540},"Clear handoff message",[535,619,620,623,626],{},[554,621,622],{"align":540},"Product or option unavailable",[554,624,625],{"align":540},"Offers visible alternatives or asks",[554,627,628],{"align":540},"No silent substitution",[535,630,631,634,637],{},[554,632,633],{"align":540},"Final transaction",[554,635,636],{"align":540},"Stops before commitment",[554,638,639],{"align":540},"No order, booking, or submission",[535,641,642,645,648],{},[554,643,644],{"align":540},"Wrong action",[554,646,647],{"align":540},"Detects the mismatch and recovers or stops",[554,649,650],{"align":540},"State check shows correction",[535,652,653,656,659],{},[554,654,655],{"align":540},"Session ends",[554,657,658],{"align":540},"Reports loss of access cleanly",[554,660,661],{"align":540},"No claim of task completion",[11,663,664],{},"Measure more than task completion. Track action count, retries, handoffs, time to recovery, incorrect clicks, user corrections and unverified outcomes. Those numbers expose the weak steps that a single success rate hides.",[57,666,668],{"id":667},"choosing-the-architecture","Choosing the architecture",[11,670,671],{},"Building an agent for a website you do not own is an execution problem. The model needs current page evidence, a restricted action set, a check after each change, and a route back to the user.",[131,673],{":height":674,":width":167,"alt":675,"loading":136,"provider":137,"src":676},"560","Comparison table titled \"Browser-agent tooling landscape\" listing Playwright MCP, Browserbase MCP, Browser Use MCP, mcp-chrome, WebMCP and Webfuse MCP against their best match and main limitation, with Webfuse highlighted for agent action inside a live customer session","/blog/how-do-i-build-an-ai-agent-that-works-on-a-website-i-dont-own/5.svg",[11,678,679],{},"Use an isolated browser for background work. Use site-published tools when the owner offers them. Use an extension when personal desktop automation and installation are acceptable. Use live-session actuation when the agent needs to work inside the user's visible, authenticated browser context.",[11,681,682],{},"With Webfuse the path is short: create a Space, enable Automation, protect the Space key, connect the MCP client, bind it to a Session, then add narrow action and handoff policies. Start with one workflow, stop before high-risk actions, and widen the scope only once the failure cases behave.",[684,685,686],"style",{},"html pre.shiki code .suv1-, html code.shiki .suv1-{--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}html pre.shiki code .s8ozJ, html code.shiki .s8ozJ{--shiki-default:#79B8FF;--shiki-dark:#79B8FF}html pre.shiki code .s4wv1, html code.shiki .s4wv1{--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF}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);}",{"title":287,"searchDepth":301,"depth":301,"links":688},[689,690,691,692,700,701,702,703,704],{"id":59,"depth":301,"text":60},{"id":112,"depth":301,"text":113},{"id":151,"depth":301,"text":152},{"id":206,"depth":301,"text":207,"children":693},[694,695,696,697,698,699],{"id":217,"depth":311,"text":218},{"id":251,"depth":311,"text":252},{"id":261,"depth":311,"text":262},{"id":276,"depth":311,"text":277},{"id":398,"depth":311,"text":399},{"id":416,"depth":311,"text":417},{"id":426,"depth":301,"text":427},{"id":467,"depth":301,"text":468},{"id":507,"depth":301,"text":508},{"id":520,"depth":301,"text":521},{"id":667,"depth":301,"text":668},"ai-agents","2026-09-01","A build guide for connecting an AI agent to a third-party website through a browser execution layer. Covers the Webfuse Space and Session MCP setup, action policies, login handling, human handoff, and the test cases to run before production.","md",[710,713,716,719,722,725,728],{"question":711,"answer":712},"Does the target website need to install Webfuse?","No. No code is added to the underlying website. The user reaches the site through a configured Webfuse Session, and the agent connects to that Session through the Automation API exposed over MCP.",{"question":714,"answer":715},"Does the user need a browser extension?","No. The live-session model runs through the Webfuse proxy and its browser-side session layer, so there is nothing for the user to install. Extension-based tools such as mcp-chrome use a different connection model.",{"question":717,"answer":718},"Can the agent use a website API instead?","Yes, if the site offers an API with the scope you need. An API is the better fit for structured background operations. The live browser wins when the user has to see the interface, share an authenticated context, make a choice, or take over.",{"question":720,"answer":721},"Can the agent act after the user logs in?","Yes. The agent continues in the same live Session once the user authenticates, so the password never enters the model prompt. Restrict access to sensitive pages and put a human approval step in front of high-risk actions.",{"question":723,"answer":724},"Can it work on every website?","No browser automation system covers every site. Site policy, CAPTCHAs, proxy blocking, hardware authentication and anti-automation controls can stop a workflow. Test each target and keep a human fallback.",{"question":726,"answer":727},"Can a person take control during the task?","Yes. Human handoff is a main reason to use a live, user-visible Session rather than a detached browser. Define clear triggers so the agent asks for help instead of repeating failed actions.",{"question":729,"answer":730},"Should the agent submit forms or make purchases?","That depends on risk, consent and internal policy. A safe default is to let the agent prepare the task, show a review screen, and leave the final commitment to the user.",0,null,false,{"shortTitle":735,"relatedLinks":736},"Build an Agent for a Site You Don't Own",[737,740,743],{"text":738,"href":122,"description":739},"How to Connect an AI Agent to the Live Web: 5 Architectures Compared (2026)","The five execution layers for giving an agent access to the web, and how to pick between them.",{"text":741,"href":127,"description":742},"6 Best MCP Servers for Browser Automation in 2026","Playwright, Browserbase, mcp-chrome, Browser Use and Webfuse compared on browser context and tooling.",{"text":744,"href":107,"description":745},"Challenges of Building Reliable Voice AI Agents on Live Websites","Why selectors, dynamic content and iframes break direct-injection agents on sites you do not control.",true,"/blog/how-do-i-build-an-ai-agent-that-works-on-a-website-i-dont-own",{"title":5,"description":707},{"loc":747},"blog/1052.how-do-i-build-an-ai-agent-that-works-on-a-website-i-dont-own",[705,752,753,754,755],"web-agents","browser-automation","mcp","webfuse","xj4JfQ8XK8ZroVCSNTif6xl4zBKVmEe1-WF1IWskbiM",[758,3454],{"id":759,"title":760,"authorId":761,"body":762,"category":705,"created":3435,"description":3436,"extension":708,"faqs":732,"featurePriority":732,"head":732,"hideCta":746,"landingPath":732,"meta":3437,"navigation":746,"ogImage":732,"path":3445,"robots":732,"schemaOrg":732,"seo":3446,"sitemap":3447,"stem":3448,"tags":3449,"__hash__":3453},"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":763,"toc":3418},[764,770,793,797,800,804,807,810,819,823,827,834,852,856,859,862,866,873,877,882,885,902,906,924,928,940,954,958,972,976,979,983,1001,1004,1008,1018,1023,1091,1094,1097,1102,1171,1176,1291,1296,1405,1409,1420,1425,1725,1730,1884,1893,1897,1908,1913,1917,1921,1924,1927,1930,2037,2041,2044,2048,2051,2054,2059,2283,2288,2537,2542,2618,2623,2629,2638,2642,2645,2648,2651,2656,2665,2669,3009,3029,3082,3086,3089,3121,3269,3273,3276,3279,3283,3294,3297,3308,3314,3415],[11,765,766,767,129],{},"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 ",[15,768,769],{},"snapshot",[11,771,772,773,778,779,784,785,778,789,792],{},"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 ",[105,774,777],{"href":775,"rel":776},"https://playwright.dev",[146],"Playwright"," or ",[105,780,783],{"href":781,"rel":782},"https://www.webfuse.com",[146],"Webfuse",", for example, ",[786,787,788],"em",{},"clicking",[786,790,791],{},"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.",[131,794],{"src":795,":alt":796},"/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,798,799],{},"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.",[57,801,803],{"id":802},"gui-snapshots","GUI Snapshots",[11,805,806],{},"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,808,809],{},"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,811,812,813,818],{},"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 – ",[105,814,817],{"href":815,"rel":816},"https://html2canvas.hertzen.com",[146],"HTML2Canvas"," demonstrates the limits.",[131,820],{"src":821,"alt":822,"loading":136},"/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",[215,824,826],{"id":825},"vision-based-targeting","Vision-Based Targeting",[11,828,829,830,833],{},"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 ",[786,831,832],{},"\"Button with Text 'Shop'\"",". On its own, semantic targeting introduces a circular problem: which element has this text?",[11,835,836,837,840,841,844,845,848,849,129],{},"Consider the web browsing task: ",[786,838,839],{},"\"Navigate to the Apple online shop\"",". In combination with an action, in this case ",[786,842,843],{},"click",", the agent could target the ",[786,846,847],{},"Shop"," button via a point coordinate, e.g., ",[270,850,851],{},"(725, 750)",[131,853],{"src":854,"alt":855,"loading":136},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/3.png","A GUI snapshot (screenshot) visualising point coordinate targeting",[11,857,858],{},"When the UI shifts between snapshot and action time, geometric targeting suggestions might have become obsolete.",[11,860,861],{},"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.",[215,863,865],{"id":864},"the-problem-with-gui-snapshots","The Problem with GUI Snapshots",[11,867,868,869,872],{},"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 ",[786,870,871],{},"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.",[131,874],{"src":875,"alt":876,"loading":136},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/4.png","A GUI snapshot (screenshot) compared to its figuratively downsampled counterpart",[878,879,881],"h4",{"id":880},"grounded-gui-snapshots","Grounded GUI Snapshots",[11,883,884],{},"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,886,887,890,891,901],{},[786,888,889],{},"Set-of-Mark"," prompting is the go-to technique to create grounded GUI snapshots",[892,893,894],"sup",{},[105,895,900],{"href":896,"ariaDescribedBy":897,"dataFootnoteRef":287,"id":899},"#user-content-fn-1",[898],"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.",[131,903],{"src":904,"alt":905,"loading":136},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/5.png","A GUI snapshot (screenshot) visualising grounded cue targeting",[11,907,908,915,916,129],{},[105,909,912],{"href":910,"rel":911},"https://browser-use.com",[146],[786,913,914],{},"Browser Use"," agents implement Set-of-Mark-grounded GUI snapshots",[892,917,918],{},[105,919,923],{"href":920,"ariaDescribedBy":921,"dataFootnoteRef":287,"id":922},"#user-content-fn-2",[898],"user-content-fnref-2","2",[57,925,927],{"id":926},"dom-snapshots","DOM Snapshots",[11,929,930,931,939],{},"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",[892,932,933],{},[105,934,938],{"href":935,"ariaDescribedBy":936,"dataFootnoteRef":287,"id":937},"#user-content-fn-3",[898],"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,941,942,943,946,947,950,951,953],{},"Cross-origin ",[270,944,945],{},"iframe"," elements and ",[270,948,949],{},"canvas"," elements are exceptions to the DOM-is-source-of-truth assumption: ",[270,952,949],{},"-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.",[215,955,957],{"id":956},"dom-based-targeting","DOM-Based Targeting",[11,959,960,961,964,965,968,969,129],{},"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 ",[270,962,963],{},"class"," and ",[270,966,967],{},"id"," attributes – every element has at least one unique CSS selector, constructed from nth-child node paths, e.g., ",[270,970,971],{},"main .section:nth-child(2) > .row:nth-of-type(5) > form button",[131,973],{"src":974,"alt":975,"loading":136},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/6.png","A DOM snapshot (HTML) visualising CSS selector targeting",[11,977,978],{},"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.",[215,980,982],{"id":981},"the-problem-with-dom-snapshots","The Problem with DOM Snapshots",[11,984,985,986,991,992,1000],{},"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 ",[105,987,990],{"href":988,"rel":989},"https://edition.cnn.com",[146],"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 ",[105,993,996,999],{"href":994,"rel":995},"https://openai.com/index/gpt-4o-system-card/",[146],[786,997,998],{},"GPT-4o"," (OpenAI)","). Ultimately, raw DOM snapshots out-cost GUI snapshots.",[11,1002,1003],{},"Using DOM snapshots with LLM-based web agents requires size-reducing transformations, similar to image downsampling implemented behind LLM APIs.",[878,1005,1007],{"id":1006},"extracted-dom-snapshots","Extracted DOM Snapshots",[11,1009,1010,1011,1014,1015,1017],{},"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-",[786,1012,1013],{},"k"," extractions – the ",[786,1016,1013],{}," highest-scoring elements – a snapshot of the virtual DOM comes at a fraction of the original DOM's size.",[11,1019,1020],{},[15,1021,1022],{},"Top-3 DOM Snapshot:",[282,1024,1028],{"className":1025,"code":1026,"language":1027,"meta":287,"style":287},"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",[270,1029,1030,1057,1070],{"__ignoreMap":287},[291,1031,1032,1035,1039,1043,1046,1049,1052,1054],{"class":293,"line":294},[291,1033,1034],{"class":297},"\u003C",[291,1036,1038],{"class":1037},"sxg3X","button",[291,1040,1042],{"class":1041},"sFR8T"," type",[291,1044,1045],{"class":297},"=",[291,1047,1048],{"class":328},"\"submit\"",[291,1050,1051],{"class":297},">Submit\u003C/",[291,1053,1038],{"class":1037},[291,1055,1056],{"class":297},">\n",[291,1058,1059,1061,1063,1066,1068],{"class":293,"line":301},[291,1060,1034],{"class":297},[291,1062,1038],{"class":1037},[291,1064,1065],{"class":297},">More\u003C/",[291,1067,1038],{"class":1037},[291,1069,1056],{"class":297},[291,1071,1072,1074,1076,1079,1081,1084,1087,1089],{"class":293,"line":311},[291,1073,1034],{"class":297},[291,1075,105],{"class":1037},[291,1077,1078],{"class":1041}," href",[291,1080,1045],{"class":297},[291,1082,1083],{"class":328},"\"/more\"",[291,1085,1086],{"class":297},">Find out more\u003C/",[291,1088,105],{"class":1037},[291,1090,1056],{"class":297},[11,1092,1093],{},"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,1095,1096],{},"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,1098,1099],{},[15,1100,1101],{},"Extracted DOM Snapshot:",[282,1103,1105],{"className":1025,"code":1104,"language":1027,"meta":287,"style":287},"\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",[270,1106,1107,1120,1133,1146,1159],{"__ignoreMap":287},[291,1108,1109,1111,1113,1116,1118],{"class":293,"line":294},[291,1110,1034],{"class":297},[291,1112,15],{"class":1037},[291,1114,1115],{"class":297},">MacBook Air\u003C/",[291,1117,15],{"class":1037},[291,1119,1056],{"class":297},[291,1121,1122,1124,1126,1129,1131],{"class":293,"line":301},[291,1123,1034],{"class":297},[291,1125,1038],{"class":1037},[291,1127,1128],{"class":297},">Add to cart\u003C/",[291,1130,1038],{"class":1037},[291,1132,1056],{"class":297},[291,1134,1135,1137,1139,1142,1144],{"class":293,"line":311},[291,1136,1034],{"class":297},[291,1138,11],{"class":1037},[291,1140,1141],{"class":297},">Out of stock\u003C/",[291,1143,11],{"class":1037},[291,1145,1056],{"class":297},[291,1147,1148,1150,1152,1155,1157],{"class":293,"line":319},[291,1149,1034],{"class":297},[291,1151,57],{"class":1037},[291,1153,1154],{"class":297},">MacBook Pro\u003C/",[291,1156,57],{"class":1037},[291,1158,1056],{"class":297},[291,1160,1161,1163,1165,1167,1169],{"class":293,"line":335},[291,1162,1034],{"class":297},[291,1164,1038],{"class":1037},[291,1166,1128],{"class":297},[291,1168,1038],{"class":1037},[291,1170,1056],{"class":297},[11,1172,1173],{},[15,1174,1175],{},"Original DOM Snapshot – Candidate A:",[282,1177,1179],{"className":1025,"code":1178,"language":1027,"meta":287,"style":287},"\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",[270,1180,1181,1198,1211,1223,1236,1245,1259,1271,1283],{"__ignoreMap":287},[291,1182,1183,1185,1188,1191,1193,1196],{"class":293,"line":294},[291,1184,1034],{"class":297},[291,1186,1187],{"class":1037},"section",[291,1189,1190],{"class":1041}," class",[291,1192,1045],{"class":297},[291,1194,1195],{"class":328},"\"product\"",[291,1197,1056],{"class":297},[291,1199,1200,1203,1205,1207,1209],{"class":293,"line":301},[291,1201,1202],{"class":297},"  \u003C",[291,1204,15],{"class":1037},[291,1206,1115],{"class":297},[291,1208,15],{"class":1037},[291,1210,1056],{"class":297},[291,1212,1213,1215,1217,1219,1221],{"class":293,"line":311},[291,1214,1202],{"class":297},[291,1216,1038],{"class":1037},[291,1218,1128],{"class":297},[291,1220,1038],{"class":1037},[291,1222,1056],{"class":297},[291,1224,1225,1227,1229,1231,1233],{"class":293,"line":319},[291,1226,1202],{"class":297},[291,1228,11],{"class":1037},[291,1230,1141],{"class":297},[291,1232,11],{"class":1037},[291,1234,1235],{"class":297},">  👈\n",[291,1237,1238,1241,1243],{"class":293,"line":335},[291,1239,1240],{"class":297},"\u003C/",[291,1242,1187],{"class":1037},[291,1244,1056],{"class":297},[291,1246,1247,1249,1251,1253,1255,1257],{"class":293,"line":348},[291,1248,1034],{"class":297},[291,1250,1187],{"class":1037},[291,1252,1190],{"class":1041},[291,1254,1045],{"class":297},[291,1256,1195],{"class":328},[291,1258,1056],{"class":297},[291,1260,1261,1263,1265,1267,1269],{"class":293,"line":356},[291,1262,1202],{"class":297},[291,1264,15],{"class":1037},[291,1266,1154],{"class":297},[291,1268,15],{"class":1037},[291,1270,1056],{"class":297},[291,1272,1273,1275,1277,1279,1281],{"class":293,"line":367},[291,1274,1202],{"class":297},[291,1276,1038],{"class":1037},[291,1278,1128],{"class":297},[291,1280,1038],{"class":1037},[291,1282,1056],{"class":297},[291,1284,1285,1287,1289],{"class":293,"line":373},[291,1286,1240],{"class":297},[291,1288,1187],{"class":1037},[291,1290,1056],{"class":297},[11,1292,1293],{},[15,1294,1295],{},"Original DOM Snapshot – Candidate B:",[282,1297,1299],{"className":1025,"code":1298,"language":1027,"meta":287,"style":287},"\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",[270,1300,1301,1315,1327,1339,1347,1361,1373,1385,1397],{"__ignoreMap":287},[291,1302,1303,1305,1307,1309,1311,1313],{"class":293,"line":294},[291,1304,1034],{"class":297},[291,1306,1187],{"class":1037},[291,1308,1190],{"class":1041},[291,1310,1045],{"class":297},[291,1312,1195],{"class":328},[291,1314,1056],{"class":297},[291,1316,1317,1319,1321,1323,1325],{"class":293,"line":301},[291,1318,1202],{"class":297},[291,1320,15],{"class":1037},[291,1322,1115],{"class":297},[291,1324,15],{"class":1037},[291,1326,1056],{"class":297},[291,1328,1329,1331,1333,1335,1337],{"class":293,"line":311},[291,1330,1202],{"class":297},[291,1332,1038],{"class":1037},[291,1334,1128],{"class":297},[291,1336,1038],{"class":1037},[291,1338,1056],{"class":297},[291,1340,1341,1343,1345],{"class":293,"line":319},[291,1342,1240],{"class":297},[291,1344,1187],{"class":1037},[291,1346,1056],{"class":297},[291,1348,1349,1351,1353,1355,1357,1359],{"class":293,"line":335},[291,1350,1034],{"class":297},[291,1352,1187],{"class":1037},[291,1354,1190],{"class":1041},[291,1356,1045],{"class":297},[291,1358,1195],{"class":328},[291,1360,1056],{"class":297},[291,1362,1363,1365,1367,1369,1371],{"class":293,"line":348},[291,1364,1202],{"class":297},[291,1366,11],{"class":1037},[291,1368,1141],{"class":297},[291,1370,11],{"class":1037},[291,1372,1235],{"class":297},[291,1374,1375,1377,1379,1381,1383],{"class":293,"line":356},[291,1376,1202],{"class":297},[291,1378,15],{"class":1037},[291,1380,1154],{"class":297},[291,1382,15],{"class":1037},[291,1384,1056],{"class":297},[291,1386,1387,1389,1391,1393,1395],{"class":293,"line":367},[291,1388,1202],{"class":297},[291,1390,1038],{"class":1037},[291,1392,1128],{"class":297},[291,1394,1038],{"class":1037},[291,1396,1056],{"class":297},[291,1398,1399,1401,1403],{"class":293,"line":373},[291,1400,1240],{"class":297},[291,1402,1187],{"class":1037},[291,1404,1056],{"class":297},[878,1406,1408],{"id":1407},"downsampled-dom-snapshots","Downsampled DOM Snapshots",[11,1410,1411,1412,129],{},"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",[892,1413,1414],{},[105,1415,1419],{"href":1416,"ariaDescribedBy":1417,"dataFootnoteRef":287,"id":1418},"#user-content-fn-4",[898],"user-content-fnref-4","4",[11,1421,1422],{},[15,1423,1424],{},"Original DOM Snapshot:",[282,1426,1428],{"className":1025,"code":1427,"language":1027,"meta":287,"style":287},"\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",[270,1429,1430,1468,1499,1514,1522,1538,1552,1560,1565,1570,1579,1599,1609,1624,1638,1647,1653,1659,1668,1687,1696,1706,1716],{"__ignoreMap":287},[291,1431,1432,1434,1436,1438,1440,1443,1446,1448,1451,1454,1456,1459,1461,1463,1466],{"class":293,"line":294},[291,1433,1034],{"class":297},[291,1435,1187],{"class":1037},[291,1437,1190],{"class":1041},[291,1439,1045],{"class":297},[291,1441,1442],{"class":328},"\"container\"",[291,1444,1445],{"class":1041}," tabindex",[291,1447,1045],{"class":297},[291,1449,1450],{"class":328},"\"3\"",[291,1452,1453],{"class":1041}," required",[291,1455,1045],{"class":297},[291,1457,1458],{"class":328},"\"true\"",[291,1460,1042],{"class":1041},[291,1462,1045],{"class":297},[291,1464,1465],{"class":328},"\"example\"",[291,1467,1056],{"class":297},[291,1469,1470,1472,1475,1477,1479,1482,1485,1487,1490,1492,1494,1497],{"class":293,"line":301},[291,1471,1202],{"class":297},[291,1473,1474],{"class":1037},"div",[291,1476,1190],{"class":1041},[291,1478,1045],{"class":297},[291,1480,1481],{"class":328},"\"mx-auto\"",[291,1483,1484],{"class":1041}," data-topic",[291,1486,1045],{"class":297},[291,1488,1489],{"class":328},"\"products\"",[291,1491,1453],{"class":1041},[291,1493,1045],{"class":297},[291,1495,1496],{"class":328},"\"false\"",[291,1498,1056],{"class":297},[291,1500,1501,1504,1507,1510,1512],{"class":293,"line":311},[291,1502,1503],{"class":297},"    \u003C",[291,1505,1506],{"class":1037},"h1",[291,1508,1509],{"class":297},">Our Pizza\u003C/",[291,1511,1506],{"class":1037},[291,1513,1056],{"class":297},[291,1515,1516,1518,1520],{"class":293,"line":319},[291,1517,1503],{"class":297},[291,1519,1474],{"class":1037},[291,1521,1056],{"class":297},[291,1523,1524,1527,1529,1531,1533,1536],{"class":293,"line":335},[291,1525,1526],{"class":297},"      \u003C",[291,1528,1474],{"class":1037},[291,1530,1190],{"class":1041},[291,1532,1045],{"class":297},[291,1534,1535],{"class":328},"\"shadow-lg\"",[291,1537,1056],{"class":297},[291,1539,1540,1543,1545,1548,1550],{"class":293,"line":348},[291,1541,1542],{"class":297},"        \u003C",[291,1544,57],{"class":1037},[291,1546,1547],{"class":297},">Margherita\u003C/",[291,1549,57],{"class":1037},[291,1551,1056],{"class":297},[291,1553,1554,1556,1558],{"class":293,"line":356},[291,1555,1542],{"class":297},[291,1557,11],{"class":1037},[291,1559,1056],{"class":297},[291,1561,1562],{"class":293,"line":367},[291,1563,1564],{"class":297},"         A simple classic: mozzarella, tomatoes and basil.\n",[291,1566,1567],{"class":293,"line":373},[291,1568,1569],{"class":297},"         An everyday choice!\n",[291,1571,1572,1575,1577],{"class":293,"line":379},[291,1573,1574],{"class":297},"        \u003C/",[291,1576,11],{"class":1037},[291,1578,1056],{"class":297},[291,1580,1581,1583,1585,1587,1589,1592,1595,1597],{"class":293,"line":385},[291,1582,1542],{"class":297},[291,1584,1038],{"class":1037},[291,1586,1042],{"class":1041},[291,1588,1045],{"class":297},[291,1590,1591],{"class":328},"\"button\"",[291,1593,1594],{"class":297},">Add\u003C/",[291,1596,1038],{"class":1037},[291,1598,1056],{"class":297},[291,1600,1602,1605,1607],{"class":293,"line":1601},12,[291,1603,1604],{"class":297},"      \u003C/",[291,1606,1474],{"class":1037},[291,1608,1056],{"class":297},[291,1610,1612,1614,1616,1618,1620,1622],{"class":293,"line":1611},13,[291,1613,1526],{"class":297},[291,1615,1474],{"class":1037},[291,1617,1190],{"class":1041},[291,1619,1045],{"class":297},[291,1621,1535],{"class":328},[291,1623,1056],{"class":297},[291,1625,1627,1629,1631,1634,1636],{"class":293,"line":1626},14,[291,1628,1542],{"class":297},[291,1630,57],{"class":1037},[291,1632,1633],{"class":297},">Capricciosa\u003C/",[291,1635,57],{"class":1037},[291,1637,1056],{"class":297},[291,1639,1641,1643,1645],{"class":293,"line":1640},15,[291,1642,1542],{"class":297},[291,1644,11],{"class":1037},[291,1646,1056],{"class":297},[291,1648,1650],{"class":293,"line":1649},16,[291,1651,1652],{"class":297},"          A rich taste: mozzarella, ham, mushrooms, artichokes and olives.\n",[291,1654,1656],{"class":293,"line":1655},17,[291,1657,1658],{"class":297},"          A true favourite!\n",[291,1660,1662,1664,1666],{"class":293,"line":1661},18,[291,1663,1574],{"class":297},[291,1665,11],{"class":1037},[291,1667,1056],{"class":297},[291,1669,1671,1673,1675,1677,1679,1681,1683,1685],{"class":293,"line":1670},19,[291,1672,1542],{"class":297},[291,1674,1038],{"class":1037},[291,1676,1042],{"class":1041},[291,1678,1045],{"class":297},[291,1680,1591],{"class":328},[291,1682,1594],{"class":297},[291,1684,1038],{"class":1037},[291,1686,1056],{"class":297},[291,1688,1690,1692,1694],{"class":293,"line":1689},20,[291,1691,1604],{"class":297},[291,1693,1474],{"class":1037},[291,1695,1056],{"class":297},[291,1697,1699,1702,1704],{"class":293,"line":1698},21,[291,1700,1701],{"class":297},"    \u003C/",[291,1703,1474],{"class":1037},[291,1705,1056],{"class":297},[291,1707,1709,1712,1714],{"class":293,"line":1708},22,[291,1710,1711],{"class":297},"  \u003C/",[291,1713,1474],{"class":1037},[291,1715,1056],{"class":297},[291,1717,1719,1721,1723],{"class":293,"line":1718},23,[291,1720,1240],{"class":297},[291,1722,1187],{"class":1037},[291,1724,1056],{"class":297},[11,1726,1727],{},[15,1728,1729],{},"Downsampled DOM Snapshot:",[282,1731,1733],{"className":1025,"code":1732,"language":1027,"meta":287,"style":287},"\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",[270,1734,1735,1761,1781,1786,1794,1799,1804,1809,1827,1832,1837,1842,1860,1868,1876],{"__ignoreMap":287},[291,1736,1737,1739,1741,1743,1745,1747,1749,1751,1753,1755,1757,1759],{"class":293,"line":294},[291,1738,1034],{"class":297},[291,1740,1187],{"class":1037},[291,1742,1190],{"class":1041},[291,1744,1045],{"class":297},[291,1746,1442],{"class":328},[291,1748,1453],{"class":1041},[291,1750,1045],{"class":297},[291,1752,1458],{"class":328},[291,1754,1042],{"class":1041},[291,1756,1045],{"class":297},[291,1758,1465],{"class":328},[291,1760,1056],{"class":297},[291,1762,1763,1765,1767,1769,1771,1773,1775,1777,1779],{"class":293,"line":301},[291,1764,1202],{"class":297},[291,1766,1474],{"class":1037},[291,1768,1190],{"class":1041},[291,1770,1045],{"class":297},[291,1772,1481],{"class":328},[291,1774,1453],{"class":1041},[291,1776,1045],{"class":297},[291,1778,1496],{"class":328},[291,1780,1056],{"class":297},[291,1782,1783],{"class":293,"line":311},[291,1784,1785],{"class":297},"    Our Pizza\n",[291,1787,1788,1790,1792],{"class":293,"line":319},[291,1789,1503],{"class":297},[291,1791,1474],{"class":1037},[291,1793,1056],{"class":297},[291,1795,1796],{"class":293,"line":335},[291,1797,1798],{"class":297},"      Margherita\n",[291,1800,1801],{"class":293,"line":348},[291,1802,1803],{"class":297},"      A simple classic: mozzarella, tomatoes and basil.\n",[291,1805,1806],{"class":293,"line":356},[291,1807,1808],{"class":297},"      An everyday choice!\n",[291,1810,1811,1813,1815,1817,1819,1821,1823,1825],{"class":293,"line":367},[291,1812,1526],{"class":297},[291,1814,1038],{"class":1037},[291,1816,1042],{"class":1041},[291,1818,1045],{"class":297},[291,1820,1591],{"class":328},[291,1822,1594],{"class":297},[291,1824,1038],{"class":1037},[291,1826,1056],{"class":297},[291,1828,1829],{"class":293,"line":373},[291,1830,1831],{"class":297},"      Capricciosa\n",[291,1833,1834],{"class":293,"line":379},[291,1835,1836],{"class":297},"      A rich taste: mozzarella, ham, mushrooms, artichokes and olives.\n",[291,1838,1839],{"class":293,"line":385},[291,1840,1841],{"class":297},"      A true favourite!\n",[291,1843,1844,1846,1848,1850,1852,1854,1856,1858],{"class":293,"line":1601},[291,1845,1526],{"class":297},[291,1847,1038],{"class":1037},[291,1849,1042],{"class":1041},[291,1851,1045],{"class":297},[291,1853,1591],{"class":328},[291,1855,1594],{"class":297},[291,1857,1038],{"class":1037},[291,1859,1056],{"class":297},[291,1861,1862,1864,1866],{"class":293,"line":1611},[291,1863,1701],{"class":297},[291,1865,1474],{"class":1037},[291,1867,1056],{"class":297},[291,1869,1870,1872,1874],{"class":293,"line":1626},[291,1871,1711],{"class":297},[291,1873,1474],{"class":1037},[291,1875,1056],{"class":297},[291,1877,1878,1880,1882],{"class":293,"line":1640},[291,1879,1240],{"class":297},[291,1881,1187],{"class":1037},[291,1883,1056],{"class":297},[11,1885,1886,1887,129],{},"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",[892,1888,1889],{},[105,1890,1419],{"href":1416,"ariaDescribedBy":1891,"dataFootnoteRef":287,"id":1892},[898],"user-content-fnref-4-2",[215,1894,1896],{"id":1895},"the-problem-with-dom-based-targeting","The Problem with DOM-Based Targeting",[11,1898,1899,1900,1903,1904,1907],{},"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 ",[270,1901,1902],{},"UNIQUE-ID=\"27\"",", which can be selected via ",[270,1905,1906],{},"[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,1909,1910],{},[15,1911,1912],{},"DOM Snapshot with Inlined IDs:",[131,1914],{"src":1915,"alt":1916,"loading":136},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/7.png","A DOM snapshot (HTML) visualising unique ID (attribute) targeting",[215,1918,1920],{"id":1919},"the-dom-based-snapshot-pipeline","The DOM-Based Snapshot Pipeline",[11,1922,1923],{},"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,1925,1926],{},"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,1928,1929],{},"The pipeline approach traceably goes from the raw DOM to an abstract snapshot representation. For example:",[71,1931,1932,1955,1961,2019,2025,2031],{},[74,1933,1934,1937,1938,1943,1944,1947,1948,964,1951,1954],{},[15,1935,1936],{},"Scope Subtree."," Scope in to a task-relevant subtree. An information retrieval task on ",[105,1939,1942],{"href":1940,"rel":1941},"https://www.wikipedia.org",[146],"wikipedia.org"," can scope into the ",[270,1945,1946],{},"main"," element – ",[270,1949,1950],{},"header",[270,1952,1953],{},"footer"," are irrelevant.",[74,1956,1957,1960],{},[15,1958,1959],{},"Clone."," Clone the live DOM.",[74,1962,1963,1966,1967],{},[15,1964,1965],{},"Filter."," Apply arbitrary filters to the cloned DOM (in memory). For example:\n",[226,1968,1969,2007,2013],{},[74,1970,1971,1974,1975],{},[15,1972,1973],{},"Prune Subtrees"," E.g.:\n",[226,1976,1977,1983,1989],{},[74,1978,1979,1982],{},[15,1980,1981],{},"Non-interactive Nodes",", e.g., hidden elements.",[74,1984,1985,1988],{},[15,1986,1987],{},"Irrelevant Nodes",", e.g., comment nodes.",[74,1990,1991,1994,1995,1997,1998,2000,2001,2004,2005,129],{},[15,1992,1993],{},"Redundant Nodes",", e.g., ",[270,1996,105],{}," in the ",[270,1999,1953],{}," that has a same-",[270,2002,2003],{},"href"," equivalent in the ",[270,2006,1950],{},[74,2008,2009,2012],{},[15,2010,2011],{},"Sanitise."," E.g., sensitive information from content-editables.",[74,2014,2015,2018],{},[15,2016,2017],{},"Clean."," E.g., remove stop words from text nodes.",[74,2020,2021,2024],{},[15,2022,2023],{},"Serialise."," Serialise the cloned DOM to HTML.",[74,2026,2027,2030],{},[15,2028,2029],{},"Downsample."," Downsample the HTML to control size.",[74,2032,2033,2036],{},[15,2034,2035],{},"Translate."," Translate the downsampled HTML to any DOM-based representation, e.g., the accessibility tree.",[131,2038],{"src":2039,"alt":2040,"loading":136,"provider":137},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/8.svg","Example of a DOM snapshot pipeline",[11,2042,2043],{},"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.",[878,2045,2047],{"id":2046},"arbitrary-snapshot-representations","Arbitrary Snapshot Representations",[11,2049,2050],{},"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,2052,2053],{},"Compare the following snapshots representations for the same UI:",[11,2055,2056],{},[15,2057,2058],{},"DOM Snapshot:",[282,2060,2062],{"className":1025,"code":2061,"language":1027,"meta":287,"style":287},"\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",[270,2063,2064,2090,2110,2122,2130,2142,2150,2155,2160,2168,2195,2207,2215,2220,2225,2233,2259,2267,2275],{"__ignoreMap":287},[291,2065,2066,2068,2070,2072,2074,2076,2078,2080,2082,2084,2086,2088],{"class":293,"line":294},[291,2067,1034],{"class":297},[291,2069,1187],{"class":1037},[291,2071,1190],{"class":1041},[291,2073,1045],{"class":297},[291,2075,1442],{"class":328},[291,2077,1453],{"class":1041},[291,2079,1045],{"class":297},[291,2081,1458],{"class":328},[291,2083,1042],{"class":1041},[291,2085,1045],{"class":297},[291,2087,1465],{"class":328},[291,2089,1056],{"class":297},[291,2091,2092,2094,2096,2098,2100,2102,2104,2106,2108],{"class":293,"line":301},[291,2093,1202],{"class":297},[291,2095,1474],{"class":1037},[291,2097,1190],{"class":1041},[291,2099,1045],{"class":297},[291,2101,1481],{"class":328},[291,2103,1453],{"class":1041},[291,2105,1045],{"class":297},[291,2107,1496],{"class":328},[291,2109,1056],{"class":297},[291,2111,2112,2114,2116,2118,2120],{"class":293,"line":311},[291,2113,1503],{"class":297},[291,2115,1506],{"class":1037},[291,2117,1509],{"class":297},[291,2119,1506],{"class":1037},[291,2121,1056],{"class":297},[291,2123,2124,2126,2128],{"class":293,"line":319},[291,2125,1503],{"class":297},[291,2127,1474],{"class":1037},[291,2129,1056],{"class":297},[291,2131,2132,2134,2136,2138,2140],{"class":293,"line":335},[291,2133,1526],{"class":297},[291,2135,57],{"class":1037},[291,2137,1547],{"class":297},[291,2139,57],{"class":1037},[291,2141,1056],{"class":297},[291,2143,2144,2146,2148],{"class":293,"line":348},[291,2145,1526],{"class":297},[291,2147,11],{"class":1037},[291,2149,1056],{"class":297},[291,2151,2152],{"class":293,"line":356},[291,2153,2154],{"class":297},"        A simple classic: mozzarella, tomatoes and basil.\n",[291,2156,2157],{"class":293,"line":367},[291,2158,2159],{"class":297},"        An everyday choice!\n",[291,2161,2162,2164,2166],{"class":293,"line":373},[291,2163,1604],{"class":297},[291,2165,11],{"class":1037},[291,2167,1056],{"class":297},[291,2169,2170,2172,2174,2176,2178,2181,2184,2186,2189,2191,2193],{"class":293,"line":379},[291,2171,1526],{"class":297},[291,2173,105],{"class":1037},[291,2175,1078],{"class":1041},[291,2177,1045],{"class":297},[291,2179,2180],{"class":328},"\"add?p=margherita\"",[291,2182,2183],{"class":1041}," data-uid",[291,2185,1045],{"class":297},[291,2187,2188],{"class":328},"\"1\"",[291,2190,1594],{"class":297},[291,2192,105],{"class":1037},[291,2194,1056],{"class":297},[291,2196,2197,2199,2201,2203,2205],{"class":293,"line":385},[291,2198,1526],{"class":297},[291,2200,57],{"class":1037},[291,2202,1633],{"class":297},[291,2204,57],{"class":1037},[291,2206,1056],{"class":297},[291,2208,2209,2211,2213],{"class":293,"line":1601},[291,2210,1526],{"class":297},[291,2212,11],{"class":1037},[291,2214,1056],{"class":297},[291,2216,2217],{"class":293,"line":1611},[291,2218,2219],{"class":297},"        A rich taste: mozzarella, ham, mushrooms, artichokes and olives.\n",[291,2221,2222],{"class":293,"line":1626},[291,2223,2224],{"class":297},"        A true favourite!\n",[291,2226,2227,2229,2231],{"class":293,"line":1640},[291,2228,1604],{"class":297},[291,2230,11],{"class":1037},[291,2232,1056],{"class":297},[291,2234,2235,2237,2239,2241,2243,2246,2248,2250,2253,2255,2257],{"class":293,"line":1649},[291,2236,1526],{"class":297},[291,2238,105],{"class":1037},[291,2240,1078],{"class":1041},[291,2242,1045],{"class":297},[291,2244,2245],{"class":328},"\"add?p=capricciosa\"",[291,2247,2183],{"class":1041},[291,2249,1045],{"class":297},[291,2251,2252],{"class":328},"\"2\"",[291,2254,1594],{"class":297},[291,2256,105],{"class":1037},[291,2258,1056],{"class":297},[291,2260,2261,2263,2265],{"class":293,"line":1655},[291,2262,1701],{"class":297},[291,2264,1474],{"class":1037},[291,2266,1056],{"class":297},[291,2268,2269,2271,2273],{"class":293,"line":1661},[291,2270,1711],{"class":297},[291,2272,1474],{"class":1037},[291,2274,1056],{"class":297},[291,2276,2277,2279,2281],{"class":293,"line":1670},[291,2278,1240],{"class":297},[291,2280,1187],{"class":1037},[291,2282,1056],{"class":297},[11,2284,2285],{},[15,2286,2287],{},"Accessibility Tree Snapshot:",[282,2289,2293],{"className":2290,"code":2291,"language":2292,"meta":287,"style":287},"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",[270,2294,2295,2306,2313,2322,2329,2339,2349,2359,2367,2376,2385,2394,2401,2413,2422,2431,2441,2450,2458,2467,2475,2483,2489,2500,2509,2518,2528],{"__ignoreMap":287},[291,2296,2297,2300,2303],{"class":293,"line":294},[291,2298,2299],{"class":297},"- ",[291,2301,2302],{"class":1037},"document",[291,2304,2305],{"class":297},":\n",[291,2307,2308,2311],{"class":293,"line":301},[291,2309,2310],{"class":1037},"  children",[291,2312,2305],{"class":297},[291,2314,2315,2318,2320],{"class":293,"line":311},[291,2316,2317],{"class":297},"    - ",[291,2319,1187],{"class":1037},[291,2321,2305],{"class":297},[291,2323,2324,2327],{"class":293,"line":319},[291,2325,2326],{"class":1037},"      children",[291,2328,2305],{"class":297},[291,2330,2331,2334,2337],{"class":293,"line":335},[291,2332,2333],{"class":297},"        - ",[291,2335,2336],{"class":1037},"heading",[291,2338,2305],{"class":297},[291,2340,2341,2344,2346],{"class":293,"line":348},[291,2342,2343],{"class":1037},"          name",[291,2345,325],{"class":297},[291,2347,2348],{"class":328},"\"Our Pizza\"\n",[291,2350,2351,2354,2356],{"class":293,"line":356},[291,2352,2353],{"class":1037},"          level",[291,2355,325],{"class":297},[291,2357,2358],{"class":304},"1\n",[291,2360,2361,2363,2365],{"class":293,"line":367},[291,2362,2333],{"class":297},[291,2364,2336],{"class":1037},[291,2366,2305],{"class":297},[291,2368,2369,2371,2373],{"class":293,"line":373},[291,2370,2343],{"class":1037},[291,2372,325],{"class":297},[291,2374,2375],{"class":328},"\"Margherita\"\n",[291,2377,2378,2380,2382],{"class":293,"line":379},[291,2379,2353],{"class":1037},[291,2381,325],{"class":297},[291,2383,2384],{"class":304},"2\n",[291,2386,2387,2389,2392],{"class":293,"line":385},[291,2388,2333],{"class":297},[291,2390,2391],{"class":1037},"paragraph",[291,2393,2305],{"class":297},[291,2395,2396,2399],{"class":293,"line":1601},[291,2397,2398],{"class":1037},"          children",[291,2400,2305],{"class":297},[291,2402,2403,2406,2408,2410],{"class":293,"line":1611},[291,2404,2405],{"class":297},"            - ",[291,2407,408],{"class":1037},[291,2409,325],{"class":297},[291,2411,2412],{"class":328},"\"A simple classic: mozzarella, tomatoes and basil. An everyday choice!\"\n",[291,2414,2415,2417,2420],{"class":293,"line":1626},[291,2416,2333],{"class":297},[291,2418,2419],{"class":1037},"link",[291,2421,2305],{"class":297},[291,2423,2424,2426,2428],{"class":293,"line":1640},[291,2425,2343],{"class":1037},[291,2427,325],{"class":297},[291,2429,2430],{"class":328},"\"Add\"\n",[291,2432,2433,2436,2438],{"class":293,"line":1649},[291,2434,2435],{"class":1037},"          url",[291,2437,325],{"class":297},[291,2439,2440],{"class":328},"\"add?p=margherita\"\n",[291,2442,2443,2446,2448],{"class":293,"line":1655},[291,2444,2445],{"class":1037},"          data-uid",[291,2447,325],{"class":297},[291,2449,2358],{"class":304},[291,2451,2452,2454,2456],{"class":293,"line":1661},[291,2453,2333],{"class":297},[291,2455,2336],{"class":1037},[291,2457,2305],{"class":297},[291,2459,2460,2462,2464],{"class":293,"line":1670},[291,2461,2343],{"class":1037},[291,2463,325],{"class":297},[291,2465,2466],{"class":328},"\"Capricciosa\"\n",[291,2468,2469,2471,2473],{"class":293,"line":1689},[291,2470,2353],{"class":1037},[291,2472,325],{"class":297},[291,2474,2384],{"class":304},[291,2476,2477,2479,2481],{"class":293,"line":1698},[291,2478,2333],{"class":297},[291,2480,2391],{"class":1037},[291,2482,2305],{"class":297},[291,2484,2485,2487],{"class":293,"line":1708},[291,2486,2398],{"class":1037},[291,2488,2305],{"class":297},[291,2490,2491,2493,2495,2497],{"class":293,"line":1718},[291,2492,2405],{"class":297},[291,2494,408],{"class":1037},[291,2496,325],{"class":297},[291,2498,2499],{"class":328},"\"A rich taste: mozzarella, ham, mushrooms, artichokes and olives. A true favourite!\"\n",[291,2501,2503,2505,2507],{"class":293,"line":2502},24,[291,2504,2333],{"class":297},[291,2506,2419],{"class":1037},[291,2508,2305],{"class":297},[291,2510,2512,2514,2516],{"class":293,"line":2511},25,[291,2513,2343],{"class":1037},[291,2515,325],{"class":297},[291,2517,2430],{"class":328},[291,2519,2521,2523,2525],{"class":293,"line":2520},26,[291,2522,2435],{"class":1037},[291,2524,325],{"class":297},[291,2526,2527],{"class":328},"\"add?p=capricciosa\"\n",[291,2529,2531,2533,2535],{"class":293,"line":2530},27,[291,2532,2445],{"class":1037},[291,2534,325],{"class":297},[291,2536,2384],{"class":304},[11,2538,2539],{},[15,2540,2541],{},"Markdown Snapshot:",[282,2543,2546],{"className":2544,"code":2545,"language":708,"meta":287,"style":287},"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",[270,2547,2548,2553,2558,2563,2567,2572,2577,2581,2586,2590,2595,2599,2604,2609,2613],{"__ignoreMap":287},[291,2549,2550],{"class":293,"line":294},[291,2551,2552],{},"# Our Pizza\n",[291,2554,2555],{"class":293,"line":301},[291,2556,2557],{"emptyLinePlaceholder":746},"\n",[291,2559,2560],{"class":293,"line":311},[291,2561,2562],{},"## Margherita\n",[291,2564,2565],{"class":293,"line":319},[291,2566,2557],{"emptyLinePlaceholder":746},[291,2568,2569],{"class":293,"line":335},[291,2570,2571],{},"A simple classic: mozzarella, tomatoes and basil.\n",[291,2573,2574],{"class":293,"line":348},[291,2575,2576],{},"An everyday choice!\n",[291,2578,2579],{"class":293,"line":356},[291,2580,2557],{"emptyLinePlaceholder":746},[291,2582,2583],{"class":293,"line":367},[291,2584,2585],{},"[Add](add?p=margherita)\n",[291,2587,2588],{"class":293,"line":373},[291,2589,2557],{"emptyLinePlaceholder":746},[291,2591,2592],{"class":293,"line":379},[291,2593,2594],{},"## Capricciosa\n",[291,2596,2597],{"class":293,"line":385},[291,2598,2557],{"emptyLinePlaceholder":746},[291,2600,2601],{"class":293,"line":1601},[291,2602,2603],{},"A rich taste: mozzarella, ham, mushrooms, artichokes and olives.\n",[291,2605,2606],{"class":293,"line":1611},[291,2607,2608],{},"A true favourite!\n",[291,2610,2611],{"class":293,"line":1626},[291,2612,2557],{"emptyLinePlaceholder":746},[291,2614,2615],{"class":293,"line":1640},[291,2616,2617],{},"[Add](add?p=capricciosa)\n",[11,2619,2620],{},[15,2621,2622],{},"Custom Format Snapshot:",[282,2624,2627],{"className":2625,"code":2626,"language":408},[406],"[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",[270,2628,2626],{"__ignoreMap":287},[11,2630,2631,2632,129],{},"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",[892,2633,2634],{},[105,2635,1419],{"href":1416,"ariaDescribedBy":2636,"dataFootnoteRef":287,"id":2637},[898],"user-content-fnref-4-3",[57,2639,2641],{"id":2640},"non-idiomatic-application-designs","Non-Idiomatic Application Designs",[11,2643,2644],{},"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,2646,2647],{},"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,2649,2650],{},"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.",[131,2652],{"src":2653,"alt":2654,"loading":136,":width":2655},"/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,2657,2658,2659,2664],{},"As an example for bad affordance in the DOM, look at this datepicker from ",[105,2660,2663],{"href":2661,"rel":2662},"https://www.webmd.com",[146],"webmd.com",":",[131,2666],{"src":2667,"alt":2668,"loading":136,":width":2655},"/blog/serialising-web-ui-state-for-llms-the-complete-guide/10.png","Example of an HTML bad practice (ignoring tag name semantics)",[282,2670,2672],{"className":1025,"code":2671,"language":1027,"meta":287,"style":287},"\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",[270,2673,2674,2682,2702,2721,2740,2759,2778,2797,2816,2822,2842,2860,2889,2916,2943,2947,2974,3001],{"__ignoreMap":287},[291,2675,2676,2678,2680],{"class":293,"line":294},[291,2677,1034],{"class":297},[291,2679,1474],{"class":1037},[291,2681,1056],{"class":297},[291,2683,2684,2686,2688,2690,2692,2695,2698,2700],{"class":293,"line":301},[291,2685,1202],{"class":297},[291,2687,291],{"class":1037},[291,2689,1190],{"class":1041},[291,2691,1045],{"class":297},[291,2693,2694],{"class":328},"\"cell day-header\"",[291,2696,2697],{"class":297},">Sun\u003C/",[291,2699,291],{"class":1037},[291,2701,1056],{"class":297},[291,2703,2704,2706,2708,2710,2712,2714,2717,2719],{"class":293,"line":311},[291,2705,1202],{"class":297},[291,2707,291],{"class":1037},[291,2709,1190],{"class":1041},[291,2711,1045],{"class":297},[291,2713,2694],{"class":328},[291,2715,2716],{"class":297},">Mon\u003C/",[291,2718,291],{"class":1037},[291,2720,1056],{"class":297},[291,2722,2723,2725,2727,2729,2731,2733,2736,2738],{"class":293,"line":319},[291,2724,1202],{"class":297},[291,2726,291],{"class":1037},[291,2728,1190],{"class":1041},[291,2730,1045],{"class":297},[291,2732,2694],{"class":328},[291,2734,2735],{"class":297},">Tue\u003C/",[291,2737,291],{"class":1037},[291,2739,1056],{"class":297},[291,2741,2742,2744,2746,2748,2750,2752,2755,2757],{"class":293,"line":335},[291,2743,1202],{"class":297},[291,2745,291],{"class":1037},[291,2747,1190],{"class":1041},[291,2749,1045],{"class":297},[291,2751,2694],{"class":328},[291,2753,2754],{"class":297},">Wed\u003C/",[291,2756,291],{"class":1037},[291,2758,1056],{"class":297},[291,2760,2761,2763,2765,2767,2769,2771,2774,2776],{"class":293,"line":348},[291,2762,1202],{"class":297},[291,2764,291],{"class":1037},[291,2766,1190],{"class":1041},[291,2768,1045],{"class":297},[291,2770,2694],{"class":328},[291,2772,2773],{"class":297},">Thu\u003C/",[291,2775,291],{"class":1037},[291,2777,1056],{"class":297},[291,2779,2780,2782,2784,2786,2788,2790,2793,2795],{"class":293,"line":356},[291,2781,1202],{"class":297},[291,2783,291],{"class":1037},[291,2785,1190],{"class":1041},[291,2787,1045],{"class":297},[291,2789,2694],{"class":328},[291,2791,2792],{"class":297},">Fri\u003C/",[291,2794,291],{"class":1037},[291,2796,1056],{"class":297},[291,2798,2799,2801,2803,2805,2807,2809,2812,2814],{"class":293,"line":367},[291,2800,1202],{"class":297},[291,2802,291],{"class":1037},[291,2804,1190],{"class":1041},[291,2806,1045],{"class":297},[291,2808,2694],{"class":328},[291,2810,2811],{"class":297},">Sat\u003C/",[291,2813,291],{"class":1037},[291,2815,1056],{"class":297},[291,2817,2818],{"class":293,"line":373},[291,2819,2821],{"class":2820},"sJ8bj","  \u003C!-- [...] -->\n",[291,2823,2824,2826,2828,2830,2832,2835,2838,2840],{"class":293,"line":379},[291,2825,1202],{"class":297},[291,2827,291],{"class":1037},[291,2829,1190],{"class":1041},[291,2831,1045],{"class":297},[291,2833,2834],{"class":328},"\"cell day blank\"",[291,2836,2837],{"class":297},">\u003C/",[291,2839,291],{"class":1037},[291,2841,1056],{"class":297},[291,2843,2844,2846,2848,2850,2852,2854,2856,2858],{"class":293,"line":385},[291,2845,1202],{"class":297},[291,2847,291],{"class":1037},[291,2849,1190],{"class":1041},[291,2851,1045],{"class":297},[291,2853,2834],{"class":328},[291,2855,2837],{"class":297},[291,2857,291],{"class":1037},[291,2859,1056],{"class":297},[291,2861,2862,2864,2866,2868,2870,2873,2876,2878,2881,2883,2885,2887],{"class":293,"line":1601},[291,2863,1202],{"class":297},[291,2865,291],{"class":1037},[291,2867,1190],{"class":1041},[291,2869,1045],{"class":297},[291,2871,2872],{"class":328},"\"cell day\"",[291,2874,2875],{"class":297},">\u003C",[291,2877,291],{"class":1037},[291,2879,2880],{"class":297},">1\u003C/",[291,2882,291],{"class":1037},[291,2884,2837],{"class":297},[291,2886,291],{"class":1037},[291,2888,1056],{"class":297},[291,2890,2891,2893,2895,2897,2899,2901,2903,2905,2908,2910,2912,2914],{"class":293,"line":1611},[291,2892,1202],{"class":297},[291,2894,291],{"class":1037},[291,2896,1190],{"class":1041},[291,2898,1045],{"class":297},[291,2900,2872],{"class":328},[291,2902,2875],{"class":297},[291,2904,291],{"class":1037},[291,2906,2907],{"class":297},">2\u003C/",[291,2909,291],{"class":1037},[291,2911,2837],{"class":297},[291,2913,291],{"class":1037},[291,2915,1056],{"class":297},[291,2917,2918,2920,2922,2924,2926,2928,2930,2932,2935,2937,2939,2941],{"class":293,"line":1626},[291,2919,1202],{"class":297},[291,2921,291],{"class":1037},[291,2923,1190],{"class":1041},[291,2925,1045],{"class":297},[291,2927,2872],{"class":328},[291,2929,2875],{"class":297},[291,2931,291],{"class":1037},[291,2933,2934],{"class":297},">3\u003C/",[291,2936,291],{"class":1037},[291,2938,2837],{"class":297},[291,2940,291],{"class":1037},[291,2942,1056],{"class":297},[291,2944,2945],{"class":293,"line":1640},[291,2946,2821],{"class":2820},[291,2948,2949,2951,2953,2955,2957,2959,2961,2963,2966,2968,2970,2972],{"class":293,"line":1649},[291,2950,1202],{"class":297},[291,2952,291],{"class":1037},[291,2954,1190],{"class":1041},[291,2956,1045],{"class":297},[291,2958,2872],{"class":328},[291,2960,2875],{"class":297},[291,2962,291],{"class":1037},[291,2964,2965],{"class":297},">29\u003C/",[291,2967,291],{"class":1037},[291,2969,2837],{"class":297},[291,2971,291],{"class":1037},[291,2973,1056],{"class":297},[291,2975,2976,2978,2980,2982,2984,2986,2988,2990,2993,2995,2997,2999],{"class":293,"line":1655},[291,2977,1202],{"class":297},[291,2979,291],{"class":1037},[291,2981,1190],{"class":1041},[291,2983,1045],{"class":297},[291,2985,2872],{"class":328},[291,2987,2875],{"class":297},[291,2989,291],{"class":1037},[291,2991,2992],{"class":297},">30\u003C/",[291,2994,291],{"class":1037},[291,2996,2837],{"class":297},[291,2998,291],{"class":1037},[291,3000,1056],{"class":297},[291,3002,3003,3005,3007],{"class":293,"line":1661},[291,3004,1240],{"class":297},[291,3006,1474],{"class":1037},[291,3008,1056],{"class":297},[11,3010,3011,3012,3014,3015,3018,3019,3021,3022,3025,3026,3028],{},"The days wrapped in ",[270,3013,291],{}," (e.g., ",[270,3016,3017],{},"16",") are clickable, but the HTML communicates no such actionability. The idiomatic DOM equivalent would instead use ",[270,3020,1038],{}," elements throughout, or at least assign suitable ",[270,3023,3024],{},"role"," attributes like ",[270,3027,1038],{},". A DOM snapshot pipeline leaves space for solving this problem: rewrite the virtual DOM with idiomatic elements.",[282,3030,3032],{"className":1025,"code":3031,"language":1027,"meta":287,"style":287},"  \u003Cbutton class=\"cell day\">29\u003C/button>\n  \u003C!-- OR -->\n  \u003Cspan role=\"button\" class=\"cell day\">30\u003C/button>\n",[270,3033,3034,3052,3057],{"__ignoreMap":287},[291,3035,3036,3038,3040,3042,3044,3046,3048,3050],{"class":293,"line":294},[291,3037,1202],{"class":297},[291,3039,1038],{"class":1037},[291,3041,1190],{"class":1041},[291,3043,1045],{"class":297},[291,3045,2872],{"class":328},[291,3047,2965],{"class":297},[291,3049,1038],{"class":1037},[291,3051,1056],{"class":297},[291,3053,3054],{"class":293,"line":301},[291,3055,3056],{"class":2820},"  \u003C!-- OR -->\n",[291,3058,3059,3061,3063,3066,3068,3070,3072,3074,3076,3078,3080],{"class":293,"line":311},[291,3060,1202],{"class":297},[291,3062,291],{"class":1037},[291,3064,3065],{"class":1041}," role",[291,3067,1045],{"class":297},[291,3069,1591],{"class":328},[291,3071,1190],{"class":1041},[291,3073,1045],{"class":297},[291,3075,2872],{"class":328},[291,3077,2992],{"class":297},[291,3079,1038],{"class":1037},[291,3081,1056],{"class":297},[57,3083,3085],{"id":3084},"choosing-between-snapshot-representations","Choosing Between Snapshot Representations",[11,3087,3088],{},"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:",[71,3090,3091,3103,3109,3115],{},[74,3092,3093,3096,3097,3099,3100,3102],{},[15,3094,3095],{},"Route Modality."," Fall back to GUI snapshots if the UI is based on ",[270,3098,949],{}," or cross-origin ",[270,3101,945],{}," elements; use DOM snapshots by default.",[74,3104,3105,3108],{},[15,3106,3107],{},"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.",[74,3110,3111,3114],{},[15,3112,3113],{},"Scope Escalation."," If elicited action suggestions are unusable, widen the snapshot scope and representation richness.",[74,3116,3117,3120],{},[15,3118,3119],{},"Cascade to Hybrid."," If elicited action suggestions are still unusable, augment the rich DOM snapshot with a GUI snapshot for maximum grounding.",[529,3122,3123,3141],{},[532,3124,3125],{},[535,3126,3127,3129,3132,3135,3138],{},[538,3128],{"align":540},[538,3130,3131],{},"GUI",[538,3133,3134],{},"grounded",[538,3136,3137],{},"DOM",[538,3139,3140],{},"transformed",[549,3142,3143,3165,3186,3209,3228,3249],{},[535,3144,3145,3148,3153,3157,3160],{},[554,3146,3147],{"align":540},"LLM Input Tokens",[554,3149,3150],{},[15,3151,3152],{},"Low",[554,3154,3155],{},[15,3156,3152],{},[554,3158,3159],{},"High",[554,3161,3162,3164],{},[15,3163,3152],{}," to Moderate",[535,3166,3167,3170,3173,3178,3182],{},[554,3168,3169],{"align":540},"Element Targeting",[554,3171,3172],{},"Absolute",[554,3174,3175],{},[15,3176,3177],{},"Relative",[554,3179,3180],{},[15,3181,3177],{},[554,3183,3184],{},[15,3185,3177],{},[535,3187,3188,3191,3197,3201,3205],{},[554,3189,3190],{"align":540},"Snapshot Scope",[554,3192,3193,3196],{},[15,3194,3195],{},"Free","/Viewport",[554,3198,3199,3196],{},[15,3200,3195],{},[554,3202,3203],{},[15,3204,3195],{},[554,3206,3207],{},[15,3208,3195],{},[535,3210,3211,3214,3217,3219,3224],{},[554,3212,3213],{"align":540},"Snapshot Context",[554,3215,3216],{},"UI",[554,3218,3216],{},[554,3220,3221],{},[15,3222,3223],{},"Full",[554,3225,3226],{},[15,3227,3223],{},[535,3229,3230,3235,3240,3244,3247],{},[554,3231,3232,3234],{"align":540},[270,3233,945],{}," Context",[554,3236,3237],{},[15,3238,3239],{},"Viewport",[554,3241,3242],{},[15,3243,3239],{},[554,3245,3246],{},"Same-origin only",[554,3248,3246],{},[535,3250,3251,3255,3260,3264,3267],{},[554,3252,3253,3234],{"align":540},[270,3254,949],{},[554,3256,3257],{},[15,3258,3259],{},"Yes",[554,3261,3262],{},[15,3263,3259],{},[554,3265,3266],{},"No",[554,3268,3266],{},[57,3270,3272],{"id":3271},"using-snapshots-in-the-model-context","Using Snapshots in the Model Context",[11,3274,3275],{},"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,3277,3278],{},"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.",[57,3280,3282],{"id":3281},"timing-snapshots-in-the-web-client","Timing Snapshots in the Web Client",[11,3284,3285,3286,129],{},"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",[892,3287,3288],{},[105,3289,3293],{"href":3290,"ariaDescribedBy":3291,"dataFootnoteRef":287,"id":3292},"#user-content-fn-5",[898],"user-content-fnref-5","5",[3295,3296],"hr",{},[11,3298,3299,3300,129],{},"The snapshot is the central artefact in a web agent harness. Its representation is among the most significant factors for agent success",[892,3301,3302],{},[105,3303,3307],{"href":3304,"ariaDescribedBy":3305,"dataFootnoteRef":287,"id":3306},"#user-content-fn-6",[898],"user-content-fnref-6","6",[11,3309,3310,3311,3313],{},"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 ",[270,3312,945],{}," boundaries, etc.",[1187,3315,3318,3323],{"className":3316,"dataFootnotes":287},[3317],"footnotes",[57,3319,3322],{"className":3320,"id":898},[3321],"sr-only","Footnotes",[71,3324,3325,3340,3353,3365,3391,3403],{},[74,3326,3328,3332,3333],{"id":3327},"user-content-fn-1",[105,3329,3330],{"href":3330,"rel":3331},"https://arxiv.org/abs/2310.11441",[146]," ",[105,3334,3339],{"href":3335,"ariaLabel":3336,"className":3337,"dataFootnoteBackref":287},"#user-content-fnref-1","Back to reference 1",[3338],"data-footnote-backref","↩",[74,3341,3343,3344,3332,3348],{"id":3342},"user-content-fn-2","Our reimplementation of Browser Use's grounded GUI snapshots: ",[105,3345,3346],{"href":3346,"rel":3347},"https://github.com/webfuse-com/D2Snap/blob/main/snapshots/_bu.js",[146],[105,3349,3339],{"href":3350,"ariaLabel":3351,"className":3352,"dataFootnoteBackref":287},"#user-content-fnref-2","Back to reference 2",[3338],[74,3354,3356,3332,3360],{"id":3355},"user-content-fn-3",[105,3357,3358],{"href":3358,"rel":3359},"https://arxiv.org/abs/2210.03945",[146],[105,3361,3339],{"href":3362,"ariaLabel":3363,"className":3364,"dataFootnoteBackref":287},"#user-content-fnref-3","Back to reference 3",[3338],[74,3366,3368,3332,3372,3332,3377,3332,3384],{"id":3367},"user-content-fn-4",[105,3369,3370],{"href":3370,"rel":3371},"https://arxiv.org/abs/2508.04412",[146],[105,3373,3339],{"href":3374,"ariaLabel":3375,"className":3376,"dataFootnoteBackref":287},"#user-content-fnref-4","Back to reference 4",[3338],[105,3378,3339,3382],{"href":3379,"ariaLabel":3380,"className":3381,"dataFootnoteBackref":287},"#user-content-fnref-4-2","Back to reference 4-2",[3338],[892,3383,923],{},[105,3385,3339,3389],{"href":3386,"ariaLabel":3387,"className":3388,"dataFootnoteBackref":287},"#user-content-fnref-4-3","Back to reference 4-3",[3338],[892,3390,938],{},[74,3392,3394,3332,3398],{"id":3393},"user-content-fn-5",[105,3395,3396],{"href":3396,"rel":3397},"https://github.com/webfuse-com/DOMQuake",[146],[105,3399,3339],{"href":3400,"ariaLabel":3401,"className":3402,"dataFootnoteBackref":287},"#user-content-fnref-5","Back to reference 5",[3338],[74,3404,3406,3332,3410],{"id":3405},"user-content-fn-6",[105,3407,3408],{"href":3408,"rel":3409},"https://arxiv.org/abs/2504.01382",[146],[105,3411,3339],{"href":3412,"ariaLabel":3413,"className":3414,"dataFootnoteBackref":287},"#user-content-fnref-6","Back to reference 6",[3338],[684,3416,3417],{},"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":287,"searchDepth":301,"depth":301,"links":3419},[3420,3424,3430,3431,3432,3433,3434],{"id":802,"depth":301,"text":803,"children":3421},[3422,3423],{"id":825,"depth":311,"text":826},{"id":864,"depth":311,"text":865},{"id":926,"depth":301,"text":927,"children":3425},[3426,3427,3428,3429],{"id":956,"depth":311,"text":957},{"id":981,"depth":311,"text":982},{"id":1895,"depth":311,"text":1896},{"id":1919,"depth":311,"text":1920},{"id":2640,"depth":301,"text":2641},{"id":3084,"depth":301,"text":3085},{"id":3271,"depth":301,"text":3272},{"id":3281,"depth":301,"text":3282},{"id":898,"depth":301,"text":3322},"2025-08-28","Understand how web-based user interfaces can be serialised for use with LLM-based web agents.",{"homepage":746,"relatedLinks":3438},[3439,3442],{"text":3440,"href":3441},"DOM Downsampling for LLM-Based Web Agents","/rnd/dom-downsampling-for-llm-based-web-agents",{"text":3443,"href":3444,"external":746},"Webfuse Automation API","https://dev.webfuse.com/automation-api/","/blog/serialising-web-ui-state-for-llms-the-complete-guide",{"title":760,"description":3436},{"loc":3445},"blog/1013.serialising-web-ui-state-for-llms-the-complete-guide",[705,752,3450,3451,3452],"web-automation","llms","snapshots","X7R93b2XjyDfLllTDaNgFoo_c8AvF9oBDGzv4yiISFA",{"id":3455,"title":3456,"authorId":761,"body":3457,"category":705,"created":3933,"description":3934,"extension":708,"faqs":732,"featurePriority":732,"head":732,"hideCta":746,"landingPath":732,"meta":3935,"navigation":746,"ogImage":732,"path":3941,"robots":732,"schemaOrg":732,"seo":3942,"sitemap":3943,"stem":3944,"tags":3945,"__hash__":3947},"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":3458,"toc":3914},[3459,3477,3481,3489,3494,3497,3501,3504,3524,3528,3537,3541,3557,3562,3565,3569,3580,3584,3587,3591,3598,3602,3625,3629,3633,3636,3639,3643,3664,3667,3671,3675,3684,3695,3700,3704,3713,3716,3720,3723,3726,3730,3743,3746,3750,3759,3762,3766,3770,3773,3777,3781,3784,3858,3860,3863,3877],[11,3460,3461,3466,3467,3466,3471,3476],{},[105,3462,3465],{"href":3463,"rel":3464},"https://openai.com/index/introducing-operator/",[146],"Operator",", ",[105,3468,914],{"href":3469,"rel":3470},"https://browser-use.com/",[146],[105,3472,3475],{"href":3473,"rel":3474},"https://www.skyvern.com/",[146],"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.",[57,3478,3480],{"id":3479},"what-is-an-agent","What is an Agent?",[11,3482,3483,3484,129],{},"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",[892,3485,3486],{},[105,3487,900],{"href":896,"ariaDescribedBy":3488,"dataFootnoteRef":287,"id":899},[898],[131,3490],{"alt":3491,"loading":136,"src":3492,"provider":137,":width":3493},"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,3495,3496],{},"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.",[215,3498,3500],{"id":3499},"what-makes-an-agent-intelligent","What Makes an Agent Intelligent?",[11,3502,3503],{},"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:",[226,3505,3506,3512,3518],{},[74,3507,3508,3511],{},[15,3509,3510],{},"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.",[74,3513,3514,3517],{},[15,3515,3516],{},"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.",[74,3519,3520,3523],{},[15,3521,3522],{},"Neural networks"," – the agent has no model, only examples: a network is fitted to task–solution instances and generalises to unseen, yet related tasks.",[215,3525,3527],{"id":3526},"a-quick-note-on-multi-agent-systems","A Quick Note on Multi-Agent Systems",[11,3529,3530,3531,3536],{},"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 ",[105,3532,3535],{"href":3533,"rel":3534},"https://cs.stanford.edu/people/eroberts/courses/soco/projects/2003-04/intelligent-search/minimax.html",[146],"Minimax algorithm","), as opposed to random world changes. That said, web browsing – modelled after humans – is not a typical multi-agent scenario.",[215,3538,3540],{"id":3539},"the-agent-loop","The Agent Loop",[11,3542,3543,3548,3549,3556],{},[105,3544,3547],{"href":3545,"rel":3546},"https://www.nngroup.com/people/don-norman/",[146],"Don Norman","'s ",[105,3550,3553],{"href":3551,"rel":3552},"https://jnd.org/books/the-design-of-everyday-things-revised-and-expanded-edition/",[146],[786,3554,3555],{},"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.",[131,3558],{"alt":3559,"loading":136,"src":3560,"provider":137,":width":3561},"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,3563,3564],{},"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).",[215,3566,3568],{"id":3567},"errors-and-recovery","Errors and Recovery",[11,3570,3571,3572,3575,3576,3579],{},"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 ",[786,3573,3574],{},"Gulf of Action (Execution)"," – how to act in the world? – and when perceiving world state; the ",[786,3577,3578],{},"Gulf of Perception (Evaluation)"," – how to understand the world?",[131,3581],{"alt":3582,"loading":136,"src":3583,"provider":137,":width":3561},"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,3585,3586],{},"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.",[57,3588,3590],{"id":3589},"web-browsing-agents","Web Browsing Agents",[11,3592,3593,3594,3597],{},"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 ",[270,3595,3596],{},"(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.",[215,3599,3601],{"id":3600},"web-browsing-is-all-about-the-journey","Web Browsing is All About the Journey",[11,3603,3604,3605,3608,3609,3614,3615,3620,3621,3624],{},"A web browsing task is any task that can be solved through a web-based user interface (UI). For instance: ",[786,3606,3607],{},"\"Book the cheapest flight from Amsterdam to New York tomorrow night\""," on ",[105,3610,3613],{"href":3611,"rel":3612},"https://www.klm.com",[146],"klm.com",". Application programming interfaces (APIs; e.g., ",[105,3616,3619],{"href":3617,"rel":3618},"https://www.ibm.com/think/topics/rest-apis",[146],"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 ",[270,3622,3623],{},"Ctrl + F",", whilst journey-driven agents are supposed to browse a web application in human fashion, via the application-native UI.",[131,3626],{"alt":3627,"loading":136,"src":3628},"A depiction of a web journey over three web application UI states","/blog/a-gentle-introduction-to-ai-agents-for-the-web/4.png",[215,3630,3632],{"id":3631},"a-formal-model-for-web-browsing","A Formal Model for Web Browsing",[11,3634,3635],{},"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,3637,3638],{},"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).",[131,3640],{"alt":3641,"loading":136,"src":3642},"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,3644,3645,3646,3651,3652,3657,3658,3663],{},"Yet, many web applications lack ",[105,3647,3650],{"href":3648,"rel":3649},"https://www.nngroup.com/articles/ten-usability-heuristics/#toc-1-visibility-of-system-status-1",[146],"visibility of system status"," – against ",[105,3653,3656],{"href":3654,"rel":3655},"https://www.nngroup.com/people/jakob-nielsen/",[146],"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)",[892,3659,3660],{},[105,3661,923],{"href":920,"ariaDescribedBy":3662,"dataFootnoteRef":287,"id":922},[898]," with, adapting to discovered UI states, where states can be tuples of UI state trajectories to contain history.",[11,3665,3666],{},"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.",[131,3668],{"alt":3669,"loading":136,"src":3670},"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",[215,3672,3674],{"id":3673},"llm-sensors-actuators-agent","LLM + Sensors + Actuators = Agent",[11,3676,3677,3678,3683],{},"Conversationally satisfying simple information requests does not reasonably qualify an LLM as an agent – no more than it would a TF-IDF search system",[892,3679,3680],{},[105,3681,938],{"href":935,"ariaDescribedBy":3682,"dataFootnoteRef":287,"id":937},[898],", 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,3685,3686,3687,3466,3689,3466,3691,3694],{},"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: ",[786,3688,788],{},[786,3690,791],{},[786,3692,3693],{},"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.",[131,3696],{"alt":3697,"loading":136,"src":3698,"provider":137,":width":3699},"Figurative depiction of components in the agent loop","/blog/a-gentle-introduction-to-ai-agents-for-the-web/7.svg","460",[215,3701,3703],{"id":3702},"snapshots-serialised-ui-state","Snapshots – Serialised UI State",[11,3705,3706,3707,3712],{},"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",[892,3708,3709],{},[105,3710,1419],{"href":1416,"ariaDescribedBy":3711,"dataFootnoteRef":287,"id":1418},[898],". 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,3714,3715],{},"Outcome-driven web agents have used UI-invasive snapshot measures, such as grounding LLMs with bounding boxes around actionable elements.",[131,3717],{"alt":3718,"loading":136,"src":3719},"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,3721,3722],{},"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,3724,3725],{},"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?",[215,3727,3729],{"id":3728},"targeting-action-suggestions","Targeting – Action Suggestions",[11,3731,3732,3733,3466,3735,3738,3739,3742],{},"An action is a user event, such as ",[786,3734,843],{},[786,3736,3737],{},"type",", or ",[786,3740,3741],{},"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,3744,3745],{},"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.",[215,3747,3749],{"id":3748},"the-agent-harness","The Agent Harness",[11,3751,3752,3753,3758],{},"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. ",[105,3754,3757],{"href":3755,"rel":3756},"https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents",[146],"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,3760,3761],{},"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.",[131,3763],{"alt":3764,"loading":136,"src":3765,"provider":137},"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",[215,3767,3769],{"id":3768},"the-model-context-protocol","The Model Context Protocol",[11,3771,3772],{},"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.",[131,3774],{"alt":3775,"loading":136,"src":3776,"provider":137,":width":3561},"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",[215,3778,3780],{"id":3779},"web-browser-environments","Web Browser Environments",[11,3782,3783],{},"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:",[226,3785,3786,3801,3814,3826],{},[74,3787,3788,3791,3792,3795,3796],{},[15,3789,3790],{},"Agentic browser"," – the agent's UI embeds a browser.",[3793,3794],"br",{},"\nExample: ",[105,3797,3800],{"href":3798,"rel":3799},"https://www.perplexity.ai/comet",[146],"Perplexity Comet",[74,3802,3803,3806,3807,3795,3809],{},[15,3804,3805],{},"Cloud browser"," – the agent spins up a browser in the cloud.",[3793,3808],{},[105,3810,3813],{"href":3811,"rel":3812},"https://www.browserbase.com",[146],"Browserbase",[74,3815,3816,3819,3820,3795,3822],{},[15,3817,3818],{},"Local browser (3rd-party browser)"," – the agent spins up an isolated browser locally.",[3793,3821],{},[105,3823,3825],{"href":775,"rel":3824},[146],"Chromium + Playwright",[74,3827,3828,3831,3832],{},[15,3829,3830],{},"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",[226,3833,3834,3847],{},[74,3835,3836,3839,3840,3795,3842],{},[15,3837,3838],{},"Implemented (1st-party app)"," – served directly through the website.",[3793,3841],{},[105,3843,3846],{"href":3844,"rel":3845},"https://www.cognigy.com/platform/ai-agent-studio",[146],"Cognigy Studio",[74,3848,3849,3852,3853,3795,3855],{},[15,3850,3851],{},"Augmented (3rd-party app)"," – served indirectly through a website proxy.",[3793,3854],{},[105,3856,783],{"href":781,"rel":3857},[146],[3295,3859],{},[11,3861,3862],{},"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,3864,3865,3866,3871,3872,129],{},"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 ",[105,3867,3870],{"href":3868,"rel":3869},"https://claude.com/",[146],"Claude",", or shipping ",[105,3873,3876],{"href":3874,"rel":3875},"https://github.com/webfuse-com/extension-elevenlabs-mcp",[146],"perceive-and-act-ready chatbots",[1187,3878,3880,3883],{"className":3879,"dataFootnotes":287},[3317],[57,3881,3322],{"className":3882,"id":898},[3321],[71,3884,3885,3894,3900,3906],{},[74,3886,3887,3332,3891],{"id":3327},[105,3888,3889],{"href":3889,"rel":3890},"https://inst.eecs.berkeley.edu/~cs188/textbook/textbook_full.pdf",[146],[105,3892,3339],{"href":3335,"ariaLabel":3336,"className":3893,"dataFootnoteBackref":287},[3338],[74,3895,3896,3897],{"id":3342},"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. ",[105,3898,3339],{"href":3350,"ariaLabel":3351,"className":3899,"dataFootnoteBackref":287},[3338],[74,3901,3902,3903],{"id":3355},"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. ",[105,3904,3339],{"href":3362,"ariaLabel":3363,"className":3905,"dataFootnoteBackref":287},[3338],[74,3907,3908,3332,3911],{"id":3367},[105,3909,3358],{"href":3358,"rel":3910},[146],[105,3912,3339],{"href":3374,"ariaLabel":3375,"className":3913,"dataFootnoteBackref":287},[3338],{"title":287,"searchDepth":301,"depth":301,"links":3915},[3916,3922,3932],{"id":3479,"depth":301,"text":3480,"children":3917},[3918,3919,3920,3921],{"id":3499,"depth":311,"text":3500},{"id":3526,"depth":311,"text":3527},{"id":3539,"depth":311,"text":3540},{"id":3567,"depth":311,"text":3568},{"id":3589,"depth":301,"text":3590,"children":3923},[3924,3925,3926,3927,3928,3929,3930,3931],{"id":3600,"depth":311,"text":3601},{"id":3631,"depth":311,"text":3632},{"id":3673,"depth":311,"text":3674},{"id":3702,"depth":311,"text":3703},{"id":3728,"depth":311,"text":3729},{"id":3748,"depth":311,"text":3749},{"id":3768,"depth":311,"text":3769},{"id":3779,"depth":311,"text":3780},{"id":898,"depth":301,"text":3322},"2025-06-15","Get an idea of agents and how to build AI agents that browse the web: key concepts, terminology, and challenges.",{"homepage":746,"relatedLinks":3936},[3937,3939,3940],{"text":3938,"href":3445},"Serialising Web UI State for LLMs",{"text":3440,"href":3441},{"text":3443,"href":3444,"external":746},"/blog/a-gentle-introduction-to-ai-agents-for-the-web",{"title":3456,"description":3934},{"loc":3941},"blog/1011.a-gentle-introduction-to-ai-agents-for-the-web",[705,3946,752,3450,3451],"browser-agents","65hAoQNete8P3AgO-H42P0eBhVfIkl5vIfZZAkvL-9o",1788261833624]