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