[{"data":1,"prerenderedAt":4035},["ShallowReactive",2],{"/blog/building-a-voice-agent-with-vapi-and-webfuse":3,"related-/blog/building-a-voice-agent-with-vapi-and-webfuse":1683},{"id":4,"title":5,"authorId":6,"body":7,"category":1638,"created":1639,"description":1640,"extension":1641,"faqs":1642,"featurePriority":1652,"head":1653,"landingPath":1653,"meta":1654,"navigation":1656,"ogImage":1653,"path":1671,"robots":1653,"schemaOrg":1653,"seo":1672,"sitemap":1673,"stem":1674,"tags":1675,"__hash__":1682},"blog/blog/1037.building-a-voice-agent-with-vapi-and-webfuse.md","Building a Voice Agent with Vapi and Webfuse","ajoy-gonsalves",{"type":8,"value":9,"toc":1623},"minimark",[10,27,30,48,54,92,103,108,115,124,128,164,171,208,212,262,266,277,306,309,312,316,319,326,331,334,338,417,431,435,438,740,751,757,866,869,873,888,891,1016,1025,1169,1177,1180,1184,1279,1283,1290,1293,1380,1386,1390,1399,1490,1503,1505,1509,1512,1555,1562,1566,1614,1619],[11,12,13,14,19,20,26],"p",{},"Voice agents that can control a live website represent a new frontier in human-computer interaction. Instead of clicking through menus and forms, a user simply speaks - and the agent navigates, clicks, types, and reads on their behalf. In a ",[15,16,18],"a",{"href":17},"/blog/building-a-website-controlling-voice-agent-with-elevenlabs-and-webfuse","previous tutorial",", we explored how to achieve this with ElevenLabs. In this guide, we take the same concept and build it with ",[15,21,25],{"href":22,"rel":23},"https://vapi.ai",[24],"nofollow","Vapi",", a developer-focused voice AI platform that supports client-side tool calling out of the box.",[11,28,29],{},"By the end of this tutorial, you will have a working Webfuse Extension that:",[31,32,33,37,40],"ul",{},[34,35,36],"li",{},"Renders a floating voice orb on any proxied website",[34,38,39],{},"Connects to a Vapi-powered voice assistant on click",[34,41,42,43],{},"Gives the assistant the ability to read the page, click elements, type into fields, press keys, and navigate - all through the ",[15,44,47],{"href":45,"rel":46},"https://dev.webfu.se/automation-api",[24],"Webfuse Automation API",[11,49,50],{},[51,52,53],"strong",{},"What You Will Need:",[31,55,56,71,82],{},[34,57,58,61,62,66,67,70],{},[51,59,60],{},"A Vapi Account:"," Free tier available at ",[15,63,65],{"href":22,"rel":64},[24],"vapi.ai",". You will need your ",[51,68,69],{},"Public Key",".",[34,72,73,76,77,70],{},[51,74,75],{},"A Webfuse Account:"," Required to create a Space and deploy the extension. Sign up at ",[15,78,81],{"href":79,"rel":80},"https://webfuse.com",[24],"webfuse.com",[34,83,84,87,88,91],{},[51,85,86],{},"Node.js 18+"," and ",[51,89,90],{},"pnpm"," (or npm/yarn) installed locally.",[11,93,94,97,98,70],{},[51,95,96],{},"The Full Source Code"," is available on ",[15,99,102],{"href":100,"rel":101},"https://github.com/webfuse-com/extension-vapi-voice-agent",[24],"GitHub",[104,105,107],"h2",{"id":106},"why-vapi","Why Vapi?",[11,109,110,111,114],{},"Vapi is a voice AI platform built for developers. Unlike platforms that abstract away the model layer, Vapi gives you full control over the LLM provider, system prompt, voice, transcriber, and - critically - ",[51,112,113],{},"client-side tools",". This means the voice agent's tool calls can be handled entirely within the browser, with no server-side relay required.",[11,116,117,118,123],{},"For our use case, this is ideal. The Webfuse Automation API is a client-side API available within ",[15,119,122],{"href":120,"rel":121},"https://dev.webfu.se/extension-guide",[24],"Session Extensions",". When the voice agent decides to click a button, it issues a tool call that executes directly in the browser session - no round-trip to a server. No assistant needs to be pre-configured in the Vapi Dashboard - the model, prompt, voice, and tools are all defined inline in code.",[104,125,127],{"id":126},"step-1-clone-install-and-build","Step 1: Clone, Install, and Build",[129,130,135],"pre",{"className":131,"code":132,"language":133,"meta":134,"style":134},"language-console shiki shiki-themes catppuccin-latte night-owl","git clone https://github.com/webfuse-com/extension-vapi-voice-agent.git\ncd extension-vapi-voice-agent\npnpm install\npnpm build\n","console","",[136,137,138,146,152,158],"code",{"__ignoreMap":134},[139,140,143],"span",{"class":141,"line":142},"line",1,[139,144,145],{},"git clone https://github.com/webfuse-com/extension-vapi-voice-agent.git\n",[139,147,149],{"class":141,"line":148},2,[139,150,151],{},"cd extension-vapi-voice-agent\n",[139,153,155],{"class":141,"line":154},3,[139,156,157],{},"pnpm install\n",[139,159,161],{"class":141,"line":160},4,[139,162,163],{},"pnpm build\n",[11,165,166,167,170],{},"That's it. The build produces a ",[136,168,169],{},"dist/"," folder with everything Webfuse needs:",[129,172,174],{"className":131,"code":173,"language":133,"meta":134,"style":134},"dist/\n  background.js    # Auto-opens the popup on session start\n  content.js       # Automation API relay\n  popup.html       # Orb widget UI\n  popup.js         # Vapi SDK + tools (bundled)\n  manifest.json    # Extension manifest\n",[136,175,176,181,186,191,196,202],{"__ignoreMap":134},[139,177,178],{"class":141,"line":142},[139,179,180],{},"dist/\n",[139,182,183],{"class":141,"line":148},[139,184,185],{},"  background.js    # Auto-opens the popup on session start\n",[139,187,188],{"class":141,"line":154},[139,189,190],{},"  content.js       # Automation API relay\n",[139,192,193],{"class":141,"line":160},[139,194,195],{},"  popup.html       # Orb widget UI\n",[139,197,199],{"class":141,"line":198},5,[139,200,201],{},"  popup.js         # Vapi SDK + tools (bundled)\n",[139,203,205],{"class":141,"line":204},6,[139,206,207],{},"  manifest.json    # Extension manifest\n",[104,209,211],{"id":210},"step-2-deploy-to-webfuse","Step 2: Deploy to Webfuse",[213,214,215,231,249],"ol",{},[34,216,217,218,223,224],{},"Go to ",[15,219,222],{"href":220,"rel":221},"https://webfuse.com/studio",[24],"Webfuse Studio"," and create a Space (Solo is perfect for this use-case)",[225,226],"nuxt-picture",{"alt":227,"loading":228,"src":229,"format":230},"Create a Webfuse SPACE","lazy","/blog/building-a-voice-agent-with-vapi-and-webfuse/1.png","png",[34,232,233,234,237,238,241,242,245],{},"In the Space, open ",[51,235,236],{},"Settings"," (gear icon) > ",[51,239,240],{},"Extensions"," > ",[51,243,244],{},"Install extension",[225,246],{"alt":247,"loading":228,"src":248,"format":230},"Install extension on Webfuse","/blog/building-a-voice-agent-with-vapi-and-webfuse/2.png",[34,250,251,252,255,256,258,259],{},"Click ",[51,253,254],{},"Load unpacked in Default Storage"," and select the ",[136,257,169],{}," folder",[225,260],{"alt":247,"loading":228,"src":261,"format":230},"/blog/building-a-voice-agent-with-vapi-and-webfuse/3.png",[104,263,265],{"id":264},"step-3-configure-your-api-key","Step 3: Configure Your API Key",[11,267,268,269,272,273,276],{},"You can set your ",[136,270,271],{},"VAPI_PUBLIC_KEY"," either in the ",[136,274,275],{},"manifest.json"," before building, or directly in Webfuse Studio after uploading:",[213,278,279,285,294],{},[34,280,281,282],{},"In the Extensions panel, click on ",[51,283,284],{},"Vapi Voice Widget",[34,286,251,287,290,291],{},[51,288,289],{},"Configure"," next to Environment Variables",[225,292],{"alt":247,"loading":228,"src":293,"format":230},"/blog/building-a-voice-agent-with-vapi-and-webfuse/4.png",[34,295,296,297,299,300,305],{},"Set ",[136,298,271],{}," to your Vapi public key (found in the ",[15,301,304],{"href":302,"rel":303},"https://dashboard.vapi.ai",[24],"Vapi Dashboard",")",[11,307,308],{},"Open a Session in your Space. The orb appears automatically. Click it, grant microphone access, and start talking.",[310,311],"hr",{},[104,313,315],{"id":314},"how-it-works","How It Works",[11,317,318],{},"With the extension running, let's look under the hood at how the pieces fit together.",[225,320],{"alt":321,"loading":228,"src":322,":height":323,":width":324,"provider":325},"Diagram showing how the Vapi voice extension fits together with Webfuse","/blog/building-a-voice-agent-with-vapi-and-webfuse/5.svg","450","800","none",[327,328,330],"h3",{"id":329},"architecture","Architecture",[11,332,333],{},"The extension is structured around three components, each running in a distinct context within Webfuse:",[225,335],{"alt":336,"loading":228,"src":337,":height":323,":width":324,"provider":325},"Architecture diagram of the three extension components - popup, content script, and background worker","/blog/building-a-voice-agent-with-vapi-and-webfuse/6.svg",[339,340,341,345],"details",{},[342,343,344],"summary",{},"View table data",[346,347,348,364],"table",{},[349,350,351],"thead",{},[352,353,354,358,361],"tr",{},[355,356,357],"th",{},"Component",[355,359,360],{},"Context",[355,362,363],{},"Role",[365,366,367,385,401],"tbody",{},[352,368,369,379,382],{},[370,371,372,375,376,305],"td",{},[51,373,374],{},"Popup"," (",[136,377,378],{},"popup.ts",[370,380,381],{},"Extension page",[370,383,384],{},"Runs the Vapi SDK, handles voice + audio, renders the orb UI, processes tool calls",[352,386,387,395,398],{},[370,388,389,375,392,305],{},[51,390,391],{},"Content",[136,393,394],{},"content.ts",[370,396,397],{},"Tab page",[370,399,400],{},"Thin automation relay - receives tool call messages and executes them via the Webfuse Automation API",[352,402,403,411,414],{},[370,404,405,375,408,305],{},[51,406,407],{},"Background",[136,409,410],{},"background.ts",[370,412,413],{},"Service worker",[370,415,416],{},"Auto-opens the popup when the session starts",[418,419,420],"blockquote",{},[11,421,422,423,426,427,70],{},"For a detailed investigation into why this architecture is necessary, see the ",[136,424,425],{},"REPORT.md"," file in the ",[15,428,430],{"href":100,"rel":429},[24],"github repository",[327,432,434],{"id":433},"the-voice-connection","The Voice Connection",[11,436,437],{},"The popup initializes the Vapi SDK and starts a call with a fully inline assistant configuration:",[129,439,443],{"className":440,"code":441,"language":442,"meta":134,"style":134},"language-typescript shiki shiki-themes catppuccin-latte night-owl","vapi.start({\n  model: {\n    provider: \"openai\",\n    model: \"gpt-4o\",\n    messages: [{ role: \"system\", content: systemPrompt }],\n    tools: vapiTools,\n  },\n  transcriber: { provider: \"deepgram\", model: \"nova-2\", language: \"en\" },\n  voice: { provider: \"vapi\", voiceId: \"Elliot\" },\n  name: \"Webfuse Assistant\",\n  firstMessage: \"Hey! I can help you interact with this page. What would you like to do?\",\n  clientMessages: [\"tool-calls\", \"transcript\"],\n});\n","typescript",[136,444,445,465,477,498,514,558,570,576,630,666,683,700,730],{"__ignoreMap":134},[139,446,447,451,454,458,461],{"class":141,"line":142},[139,448,450],{"class":449},"s2kId","vapi",[139,452,70],{"class":453},"s5FwJ",[139,455,457],{"class":456},"sNstc","start",[139,459,460],{"class":449},"(",[139,462,464],{"class":463},"scGhl","{\n",[139,466,467,470,474],{"class":141,"line":148},[139,468,469],{"class":449},"  model",[139,471,473],{"class":472},"sVS64",":",[139,475,476],{"class":463}," {\n",[139,478,479,482,484,488,492,495],{"class":141,"line":154},[139,480,481],{"class":449},"    provider",[139,483,473],{"class":472},[139,485,487],{"class":486},"sbuKk"," \"",[139,489,491],{"class":490},"sfrMT","openai",[139,493,494],{"class":486},"\"",[139,496,497],{"class":463},",\n",[139,499,500,503,505,507,510,512],{"class":141,"line":160},[139,501,502],{"class":449},"    model",[139,504,473],{"class":472},[139,506,487],{"class":486},[139,508,509],{"class":490},"gpt-4o",[139,511,494],{"class":486},[139,513,497],{"class":463},[139,515,516,519,521,524,527,530,532,534,537,539,542,545,547,550,553,556],{"class":141,"line":198},[139,517,518],{"class":449},"    messages",[139,520,473],{"class":472},[139,522,523],{"class":449}," [",[139,525,526],{"class":463},"{",[139,528,529],{"class":449}," role",[139,531,473],{"class":472},[139,533,487],{"class":486},[139,535,536],{"class":490},"system",[139,538,494],{"class":486},[139,540,541],{"class":463},",",[139,543,544],{"class":449}," content",[139,546,473],{"class":472},[139,548,549],{"class":449}," systemPrompt ",[139,551,552],{"class":463},"}",[139,554,555],{"class":449},"]",[139,557,497],{"class":463},[139,559,560,563,565,568],{"class":141,"line":204},[139,561,562],{"class":449},"    tools",[139,564,473],{"class":472},[139,566,567],{"class":449}," vapiTools",[139,569,497],{"class":463},[139,571,573],{"class":141,"line":572},7,[139,574,575],{"class":463},"  },\n",[139,577,579,582,584,587,590,592,594,597,599,601,604,606,608,611,613,615,618,620,622,625,627],{"class":141,"line":578},8,[139,580,581],{"class":449},"  transcriber",[139,583,473],{"class":472},[139,585,586],{"class":463}," {",[139,588,589],{"class":449}," provider",[139,591,473],{"class":472},[139,593,487],{"class":486},[139,595,596],{"class":490},"deepgram",[139,598,494],{"class":486},[139,600,541],{"class":463},[139,602,603],{"class":449}," model",[139,605,473],{"class":472},[139,607,487],{"class":486},[139,609,610],{"class":490},"nova-2",[139,612,494],{"class":486},[139,614,541],{"class":463},[139,616,617],{"class":449}," language",[139,619,473],{"class":472},[139,621,487],{"class":486},[139,623,624],{"class":490},"en",[139,626,494],{"class":486},[139,628,629],{"class":463}," },\n",[139,631,633,636,638,640,642,644,646,648,650,652,655,657,659,662,664],{"class":141,"line":632},9,[139,634,635],{"class":449},"  voice",[139,637,473],{"class":472},[139,639,586],{"class":463},[139,641,589],{"class":449},[139,643,473],{"class":472},[139,645,487],{"class":486},[139,647,450],{"class":490},[139,649,494],{"class":486},[139,651,541],{"class":463},[139,653,654],{"class":449}," voiceId",[139,656,473],{"class":472},[139,658,487],{"class":486},[139,660,661],{"class":490},"Elliot",[139,663,494],{"class":486},[139,665,629],{"class":463},[139,667,669,672,674,676,679,681],{"class":141,"line":668},10,[139,670,671],{"class":449},"  name",[139,673,473],{"class":472},[139,675,487],{"class":486},[139,677,678],{"class":490},"Webfuse Assistant",[139,680,494],{"class":486},[139,682,497],{"class":463},[139,684,686,689,691,693,696,698],{"class":141,"line":685},11,[139,687,688],{"class":449},"  firstMessage",[139,690,473],{"class":472},[139,692,487],{"class":486},[139,694,695],{"class":490},"Hey! I can help you interact with this page. What would you like to do?",[139,697,494],{"class":486},[139,699,497],{"class":463},[139,701,703,706,708,710,712,715,717,719,721,724,726,728],{"class":141,"line":702},12,[139,704,705],{"class":449},"  clientMessages",[139,707,473],{"class":472},[139,709,523],{"class":449},[139,711,494],{"class":486},[139,713,714],{"class":490},"tool-calls",[139,716,494],{"class":486},[139,718,541],{"class":463},[139,720,487],{"class":486},[139,722,723],{"class":490},"transcript",[139,725,494],{"class":486},[139,727,555],{"class":449},[139,729,497],{"class":463},[139,731,733,735,737],{"class":141,"line":732},13,[139,734,552],{"class":463},[139,736,305],{"class":449},[139,738,739],{"class":463},";\n",[11,741,742,743,746,747,750],{},"The critical field is ",[136,744,745],{},"clientMessages: [\"tool-calls\", \"transcript\"]",". This tells Vapi to deliver tool call events to the client SDK rather than routing them server-side. When the model decides to call ",[136,748,749],{},"click_element",", the event arrives as a message in the popup, where our handler executes it locally.",[11,752,753,754,473],{},"When a tool call completes, the result is injected back into the conversation as a system message using ",[136,755,756],{},"vapi.send()",[129,758,760],{"className":440,"code":759,"language":442,"meta":134,"style":134},"vapi?.send({\n  type: \"add-message\",\n  message: {\n    role: \"system\",\n    content: `[Tool \"${name}\" result]: ${resultStr}`,\n  },\n});\n",[136,761,762,776,792,801,816,854,858],{"__ignoreMap":134},[139,763,764,766,769,772,774],{"class":141,"line":142},[139,765,450],{"class":449},[139,767,768],{"class":453},"?.",[139,770,771],{"class":456},"send",[139,773,460],{"class":449},[139,775,464],{"class":463},[139,777,778,781,783,785,788,790],{"class":141,"line":148},[139,779,780],{"class":449},"  type",[139,782,473],{"class":472},[139,784,487],{"class":486},[139,786,787],{"class":490},"add-message",[139,789,494],{"class":486},[139,791,497],{"class":463},[139,793,794,797,799],{"class":141,"line":154},[139,795,796],{"class":449},"  message",[139,798,473],{"class":472},[139,800,476],{"class":463},[139,802,803,806,808,810,812,814],{"class":141,"line":160},[139,804,805],{"class":449},"    role",[139,807,473],{"class":472},[139,809,487],{"class":486},[139,811,536],{"class":490},[139,813,494],{"class":486},[139,815,497],{"class":463},[139,817,818,821,823,827,830,834,837,839,842,844,847,849,852],{"class":141,"line":198},[139,819,820],{"class":449},"    content",[139,822,473],{"class":472},[139,824,826],{"class":825},"sizNf"," `",[139,828,829],{"class":490},"[Tool \"",[139,831,833],{"class":832},"sDF9U","${",[139,835,836],{"class":449},"name",[139,838,552],{"class":832},[139,840,841],{"class":490},"\" result]: ",[139,843,833],{"class":832},[139,845,846],{"class":449},"resultStr",[139,848,552],{"class":832},[139,850,851],{"class":825},"`",[139,853,497],{"class":463},[139,855,856],{"class":141,"line":204},[139,857,575],{"class":463},[139,859,860,862,864],{"class":141,"line":572},[139,861,552],{"class":463},[139,863,305],{"class":449},[139,865,739],{"class":463},[11,867,868],{},"This ensures the model can read the output of its own tool calls - for example, after taking a DOM snapshot, the model receives the HTML and can describe what it sees or decide which element to target next.",[327,870,872],{"id":871},"automation-tools","Automation Tools",[11,874,875,876,879,880,883,884,887],{},"The file ",[136,877,878],{},"src/tools.ts"," defines the bridge between Vapi's tool calling system and the Webfuse Automation API. Each tool has a ",[51,881,882],{},"handler"," (the function that executes) and a ",[51,885,886],{},"definition"," (the schema Vapi sends to the LLM).",[11,889,890],{},"Here is the tool handler for clicking an element:",[129,892,894],{"className":440,"code":893,"language":442,"meta":134,"style":134},"case \"click_element\": {\n  await delegateAutomation(\"act\", \"click\", params.target, {\n    moveMouse: true,\n    scrollIntoView: true,\n  });\n  return `Clicked \"${params.target}\"`;\n}\n",[136,895,896,913,949,962,973,982,1011],{"__ignoreMap":134},[139,897,898,902,904,906,908,911],{"class":141,"line":142},[139,899,901],{"class":900},"s76yb","case",[139,903,487],{"class":486},[139,905,749],{"class":490},[139,907,494],{"class":486},[139,909,910],{"class":449},": ",[139,912,464],{"class":463},[139,914,915,918,921,924,926,929,931,933,935,938,940,942,945,947],{"class":141,"line":148},[139,916,917],{"class":449},"  await ",[139,919,920],{"class":456},"delegateAutomation",[139,922,460],{"class":923},"sMtgK",[139,925,494],{"class":486},[139,927,928],{"class":490},"act",[139,930,494],{"class":486},[139,932,541],{"class":463},[139,934,487],{"class":486},[139,936,937],{"class":490},"click",[139,939,494],{"class":486},[139,941,541],{"class":463},[139,943,944],{"class":449}," params.target",[139,946,541],{"class":463},[139,948,476],{"class":463},[139,950,951,954,956,960],{"class":141,"line":154},[139,952,953],{"class":449},"    moveMouse",[139,955,473],{"class":463},[139,957,959],{"class":958},"sIhCM"," true",[139,961,497],{"class":463},[139,963,964,967,969,971],{"class":141,"line":160},[139,965,966],{"class":449},"    scrollIntoView",[139,968,473],{"class":463},[139,970,959],{"class":958},[139,972,497],{"class":463},[139,974,975,978,980],{"class":141,"line":198},[139,976,977],{"class":463},"  }",[139,979,305],{"class":923},[139,981,739],{"class":449},[139,983,984,987,989,992,994,997,999,1003,1005,1007,1009],{"class":141,"line":204},[139,985,986],{"class":449},"  return ",[139,988,851],{"class":825},[139,990,991],{"class":490},"Clicked \"",[139,993,833],{"class":832},[139,995,996],{"class":449},"params",[139,998,70],{"class":453},[139,1000,1002],{"class":1001},"sL4Ga","target",[139,1004,552],{"class":832},[139,1006,494],{"class":490},[139,1008,851],{"class":825},[139,1010,739],{"class":449},[139,1012,1013],{"class":141,"line":572},[139,1014,1015],{"class":449},"}\n",[11,1017,1018,1019,1021,1022,473],{},"The ",[136,1020,920],{}," helper sends a message from the popup to the content script, which calls the corresponding method on ",[136,1023,1024],{},"browser.webfuseSession.automation",[129,1026,1028],{"className":440,"code":1027,"language":442,"meta":134,"style":134},"function delegateAutomation(\n  automationScope: string,\n  automationMethod: string,\n  ...automationArgs: any[]\n): Promise\u003Cany> {\n  return browser.tabs.sendMessage(0, {\n    automationScope,\n    automationMethod,\n    automationArgs,\n  });\n}\n",[136,1029,1030,1041,1055,1066,1083,1105,1136,1143,1150,1157,1165],{"__ignoreMap":134},[139,1031,1032,1035,1038],{"class":141,"line":142},[139,1033,1034],{"class":900},"function",[139,1036,1037],{"class":456}," delegateAutomation",[139,1039,1040],{"class":923},"(\n",[139,1042,1043,1046,1049,1053],{"class":141,"line":148},[139,1044,1045],{"class":958},"  automationScope",[139,1047,473],{"class":1048},"s9rnR",[139,1050,1052],{"class":1051},"scrte"," string",[139,1054,497],{"class":463},[139,1056,1057,1060,1062,1064],{"class":141,"line":154},[139,1058,1059],{"class":958},"  automationMethod",[139,1061,473],{"class":1048},[139,1063,1052],{"class":1051},[139,1065,497],{"class":463},[139,1067,1068,1071,1074,1076,1079],{"class":141,"line":160},[139,1069,1070],{"class":1048},"  ...",[139,1072,1073],{"class":958},"automationArgs",[139,1075,473],{"class":1048},[139,1077,1078],{"class":1051}," any",[139,1080,1082],{"class":1081},"sXbZB","[]\n",[139,1084,1085,1087,1089,1093,1097,1100,1103],{"class":141,"line":198},[139,1086,305],{"class":923},[139,1088,473],{"class":1048},[139,1090,1092],{"class":1091},"s-DR7"," Promise",[139,1094,1096],{"class":1095},"s0xQc","\u003C",[139,1098,1099],{"class":1051},"any",[139,1101,1102],{"class":1095},">",[139,1104,476],{"class":463},[139,1106,1107,1111,1114,1116,1120,1122,1125,1127,1131,1134],{"class":141,"line":204},[139,1108,1110],{"class":1109},"srhcd","  return",[139,1112,1113],{"class":449}," browser",[139,1115,70],{"class":453},[139,1117,1119],{"class":1118},"sHY1S","tabs",[139,1121,70],{"class":453},[139,1123,1124],{"class":456},"sendMessage",[139,1126,460],{"class":449},[139,1128,1130],{"class":1129},"sZ_Zo","0",[139,1132,541],{"class":1133},"sdjIP",[139,1135,476],{"class":463},[139,1137,1138,1141],{"class":141,"line":572},[139,1139,1140],{"class":449},"    automationScope",[139,1142,497],{"class":1133},[139,1144,1145,1148],{"class":141,"line":578},[139,1146,1147],{"class":449},"    automationMethod",[139,1149,497],{"class":1133},[139,1151,1152,1155],{"class":141,"line":632},[139,1153,1154],{"class":449},"    automationArgs",[139,1156,497],{"class":1133},[139,1158,1159,1161,1163],{"class":141,"line":668},[139,1160,977],{"class":463},[139,1162,305],{"class":449},[139,1164,739],{"class":463},[139,1166,1167],{"class":141,"line":685},[139,1168,1015],{"class":463},[11,1170,1171,1172,1176],{},"This delegation is necessary because the ",[15,1173,1175],{"href":45,"rel":1174},[24],"Automation API"," is only available in content scripts - it operates on the live page DOM.",[11,1178,1179],{},"The full set of tools:",[225,1181],{"alt":1182,"loading":228,"src":1183,":height":323,":width":324,"provider":325},"Table of automation tools available to the voice agent - dom snapshot, click, type, key press, navigate","/blog/building-a-voice-agent-with-vapi-and-webfuse/7.svg",[339,1185,1186,1188],{},[342,1187,344],{},[346,1189,1190,1203],{},[349,1191,1192],{},[352,1193,1194,1197,1200],{},[355,1195,1196],{},"Tool",[355,1198,1199],{},"Automation Method",[355,1201,1202],{},"Purpose",[365,1204,1205,1220,1234,1249,1264],{},[352,1206,1207,1212,1217],{},[370,1208,1209],{},[136,1210,1211],{},"take_dom_snapshot",[370,1213,1214],{},[136,1215,1216],{},"see.domSnapshot()",[370,1218,1219],{},"Read the page structure with Webfuse IDs",[352,1221,1222,1226,1231],{},[370,1223,1224],{},[136,1225,749],{},[370,1227,1228],{},[136,1229,1230],{},"act.click()",[370,1232,1233],{},"Click buttons, links, any element",[352,1235,1236,1241,1246],{},[370,1237,1238],{},[136,1239,1240],{},"type_text",[370,1242,1243],{},[136,1244,1245],{},"act.type()",[370,1247,1248],{},"Type into input fields",[352,1250,1251,1256,1261],{},[370,1252,1253],{},[136,1254,1255],{},"press_key",[370,1257,1258],{},[136,1259,1260],{},"act.keyPress()",[370,1262,1263],{},"Press Enter, Escape, Tab, arrow keys",[352,1265,1266,1271,1276],{},[370,1267,1268],{},[136,1269,1270],{},"navigate_to",[370,1272,1273],{},[136,1274,1275],{},"automation.navigate()",[370,1277,1278],{},"Go to a different URL",[327,1280,1282],{"id":1281},"the-orb-ui","The Orb UI",[11,1284,1285,1286,1289],{},"The floating orb widget is defined in ",[136,1287,1288],{},"popup.html",". It uses CSS ping-ring animations to communicate the current call state visually:",[11,1291,1292],{},"These states are driven by CSS classes toggled from the popup script in response to Vapi events:",[129,1294,1296],{"className":440,"code":1295,"language":442,"meta":134,"style":134},"vapi.on(\"speech-start\", () => setState(\"ai-speaking\"));\nvapi.on(\"speech-end\", () => setState(\"connected\"));\n",[136,1297,1298,1342],{"__ignoreMap":134},[139,1299,1300,1302,1304,1307,1309,1311,1314,1316,1318,1321,1325,1328,1330,1332,1335,1337,1340],{"class":141,"line":142},[139,1301,450],{"class":449},[139,1303,70],{"class":453},[139,1305,1306],{"class":456},"on",[139,1308,460],{"class":449},[139,1310,494],{"class":486},[139,1312,1313],{"class":490},"speech-start",[139,1315,494],{"class":486},[139,1317,541],{"class":463},[139,1319,1320],{"class":923}," ()",[139,1322,1324],{"class":1323},"s-_ek"," =>",[139,1326,1327],{"class":456}," setState",[139,1329,460],{"class":449},[139,1331,494],{"class":486},[139,1333,1334],{"class":490},"ai-speaking",[139,1336,494],{"class":486},[139,1338,1339],{"class":449},"))",[139,1341,739],{"class":463},[139,1343,1344,1346,1348,1350,1352,1354,1357,1359,1361,1363,1365,1367,1369,1371,1374,1376,1378],{"class":141,"line":148},[139,1345,450],{"class":449},[139,1347,70],{"class":453},[139,1349,1306],{"class":456},[139,1351,460],{"class":449},[139,1353,494],{"class":486},[139,1355,1356],{"class":490},"speech-end",[139,1358,494],{"class":486},[139,1360,541],{"class":463},[139,1362,1320],{"class":923},[139,1364,1324],{"class":1323},[139,1366,1327],{"class":456},[139,1368,460],{"class":449},[139,1370,494],{"class":486},[139,1372,1373],{"class":490},"connected",[139,1375,494],{"class":486},[139,1377,1339],{"class":449},[139,1379,739],{"class":463},[11,1381,1382,1383,1385],{},"The orb also includes error handling. If a user clicks the orb without configuring their ",[136,1384,271],{},", a toast notification slides in with a clear message guiding them to the extension settings.",[327,1387,1389],{"id":1388},"the-manifest","The Manifest",[11,1391,1018,1392,1394,1395,1398],{},[136,1393,275],{}," includes ",[136,1396,1397],{},"host_permissions"," for all domains the Vapi SDK communicates with:",[129,1400,1404],{"className":1401,"code":1402,"language":1403,"meta":134,"style":134},"language-json shiki shiki-themes catppuccin-latte night-owl","\"host_permissions\": [\n    \"https://cdn.jsdelivr.net/*\",\n    \"https://api.vapi.ai/*\",\n    \"https://*.daily.co/*\",\n    \"https://c.daily.co/*\",\n    \"wss://*.daily.co/*\",\n    \"https://*.ingest.sentry.io/*\"\n]\n","json",[136,1405,1406,1419,1431,1442,1453,1464,1475,1485],{"__ignoreMap":134},[139,1407,1408,1410,1412,1414,1416],{"class":141,"line":142},[139,1409,494],{"class":486},[139,1411,1397],{"class":490},[139,1413,494],{"class":486},[139,1415,910],{"class":449},[139,1417,1418],{"class":463},"[\n",[139,1420,1421,1424,1427,1429],{"class":141,"line":148},[139,1422,1423],{"class":486},"    \"",[139,1425,1426],{"class":490},"https://cdn.jsdelivr.net/*",[139,1428,494],{"class":486},[139,1430,497],{"class":463},[139,1432,1433,1435,1438,1440],{"class":141,"line":154},[139,1434,1423],{"class":486},[139,1436,1437],{"class":490},"https://api.vapi.ai/*",[139,1439,494],{"class":486},[139,1441,497],{"class":463},[139,1443,1444,1446,1449,1451],{"class":141,"line":160},[139,1445,1423],{"class":486},[139,1447,1448],{"class":490},"https://*.daily.co/*",[139,1450,494],{"class":486},[139,1452,497],{"class":463},[139,1454,1455,1457,1460,1462],{"class":141,"line":198},[139,1456,1423],{"class":486},[139,1458,1459],{"class":490},"https://c.daily.co/*",[139,1461,494],{"class":486},[139,1463,497],{"class":463},[139,1465,1466,1468,1471,1473],{"class":141,"line":204},[139,1467,1423],{"class":486},[139,1469,1470],{"class":490},"wss://*.daily.co/*",[139,1472,494],{"class":486},[139,1474,497],{"class":463},[139,1476,1477,1479,1482],{"class":141,"line":572},[139,1478,1423],{"class":486},[139,1480,1481],{"class":490},"https://*.ingest.sentry.io/*",[139,1483,1484],{"class":486},"\"\n",[139,1486,1487],{"class":141,"line":578},[139,1488,1489],{"class":463},"]\n",[11,1491,1492,1493,1495,1496,1499,1500,1502],{},"Note that ",[136,1494,1470],{}," is listed separately - WebSocket Secure URLs require their own permission. The ",[136,1497,1498],{},"env"," array defines ",[136,1501,271],{},", which can be configured per-Space in Webfuse Studio without rebuilding.",[310,1504],{},[104,1506,1508],{"id":1507},"what-happens-next","What Happens Next",[11,1510,1511],{},"This extension is a starting point. From here, you might consider:",[31,1513,1514,1534,1546],{},[34,1515,1516,1519,1520,1523,1524,1527,1528,1531,1532,70],{},[51,1517,1518],{},"Expanding the toolset."," The Webfuse Automation API offers additional methods like ",[136,1521,1522],{},"act.select()"," for dropdowns, ",[136,1525,1526],{},"act.textSelect()"," for highlighting text, and ",[136,1529,1530],{},"see.guiSnapshot()"," for sending a screenshot to the model. Each can be added as a new tool in ",[136,1533,878],{},[34,1535,1536,1539,1540,1545],{},[51,1537,1538],{},"Adding the Session MCP Server."," For more advanced orchestration, you can connect the ",[15,1541,1544],{"href":1542,"rel":1543},"https://dev.webfu.se/session-mcp-server",[24],"Webfuse Session MCP Server"," to route automation through the Model Context Protocol, enabling multi-agent workflows and external tool registries.",[34,1547,1548,1551,1552,1554],{},[51,1549,1550],{},"Refining the system prompt."," The default prompt in ",[136,1553,878],{}," is intentionally minimal. A production agent would benefit from detailed instructions about how to interpret DOM snapshots, when to use Webfuse IDs versus CSS selectors, and how to handle error recovery.",[11,1556,1557,1558,70],{},"The full source code is available at ",[15,1559,1561],{"href":100,"rel":1560},[24],"github.com/webfuse-com/extension-vapi-voice-agent",[104,1563,1565],{"id":1564},"further-reading","Further Reading",[31,1567,1568,1575,1582,1588,1594,1601,1607],{},[34,1569,1570],{},[15,1571,1574],{"href":1572,"rel":1573},"https://docs.vapi.ai/quickstart/web",[24],"Vapi Web SDK Documentation",[34,1576,1577],{},[15,1578,1581],{"href":1579,"rel":1580},"https://docs.vapi.ai/tools/client-side-websdk",[24],"Vapi Client-Side Tools",[34,1583,1584],{},[15,1585,1587],{"href":45,"rel":1586},[24],"Webfuse Automation API Reference",[34,1589,1590],{},[15,1591,1593],{"href":120,"rel":1592},[24],"Webfuse Extension Guide",[34,1595,1596],{},[15,1597,1600],{"href":1598,"rel":1599},"https://dev.webfu.se/agent-guide",[24],"Webfuse Agent Guide",[34,1602,1603],{},[15,1604,1606],{"href":1542,"rel":1605},[24],"About Webfuse Session MCP",[34,1608,1609],{},[15,1610,1613],{"href":1611,"rel":1612},"https://www.webfuse.com/blog/a-gentle-introduction-to-ai-agents-for-the-web",[24],"A Gentle Introduction to AI Agents for the Web",[1615,1616],"article-signup-cta",{"heading":1617,"subtitle":1618},"Build Your Own Voice-Controlled Web Agent","Webfuse lets you proxy any website and give AI agents full control over it - clicks, typing, navigation, and DOM reading. Sign up and deploy your first voice agent in minutes.",[1620,1621,1622],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s2kId, html code.shiki .s2kId{--shiki-default:#4C4F69;--shiki-dark:#D6DEEB}html pre.shiki code .s5FwJ, html code.shiki .s5FwJ{--shiki-default:#179299;--shiki-default-font-style:inherit;--shiki-dark:#C792EA;--shiki-dark-font-style:italic}html pre.shiki code .sNstc, html code.shiki .sNstc{--shiki-default:#1E66F5;--shiki-default-font-style:italic;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic}html pre.shiki code .scGhl, html code.shiki .scGhl{--shiki-default:#7C7F93;--shiki-dark:#D6DEEB}html pre.shiki code .sVS64, html code.shiki .sVS64{--shiki-default:#179299;--shiki-dark:#D6DEEB}html pre.shiki code .sbuKk, html code.shiki .sbuKk{--shiki-default:#40A02B;--shiki-dark:#D9F5DD}html pre.shiki code .sfrMT, html code.shiki .sfrMT{--shiki-default:#40A02B;--shiki-dark:#ECC48D}html pre.shiki code .sizNf, html code.shiki .sizNf{--shiki-default:#40A02B;--shiki-dark:#D6DEEB}html pre.shiki code .sDF9U, html code.shiki .sDF9U{--shiki-default:#7C7F93;--shiki-dark:#D3423E}html pre.shiki code .s76yb, html code.shiki .s76yb{--shiki-default:#8839EF;--shiki-dark:#C792EA}html pre.shiki code .sMtgK, html code.shiki .sMtgK{--shiki-default:#7C7F93;--shiki-dark:#D9F5DD}html pre.shiki code .sIhCM, html code.shiki .sIhCM{--shiki-default:#E64553;--shiki-default-font-style:italic;--shiki-dark:#D7DBE0;--shiki-dark-font-style:inherit}html pre.shiki code .sL4Ga, html code.shiki .sL4Ga{--shiki-default:#4C4F69;--shiki-dark:#BAEBE2}html pre.shiki code .s9rnR, html code.shiki .s9rnR{--shiki-default:#179299;--shiki-dark:#7FDBCA}html pre.shiki code .scrte, html code.shiki .scrte{--shiki-default:#8839EF;--shiki-dark:#C5E478}html pre.shiki code .sXbZB, html code.shiki .sXbZB{--shiki-default:#DF8E1D;--shiki-default-font-style:italic;--shiki-dark:#D6DEEB;--shiki-dark-font-style:inherit}html pre.shiki code .s-DR7, html code.shiki .s-DR7{--shiki-default:#DF8E1D;--shiki-default-font-style:italic;--shiki-dark:#FFCB8B;--shiki-dark-font-style:inherit}html pre.shiki code .s0xQc, html code.shiki .s0xQc{--shiki-default:#04A5E5;--shiki-dark:#D6DEEB}html pre.shiki code .srhcd, html code.shiki .srhcd{--shiki-default:#8839EF;--shiki-default-font-style:inherit;--shiki-dark:#C792EA;--shiki-dark-font-style:italic}html pre.shiki code .sHY1S, html code.shiki .sHY1S{--shiki-default:#4C4F69;--shiki-default-font-style:inherit;--shiki-dark:#FAF39F;--shiki-dark-font-style:italic}html pre.shiki code .sZ_Zo, html code.shiki .sZ_Zo{--shiki-default:#FE640B;--shiki-dark:#F78C6C}html pre.shiki code .sdjIP, html code.shiki .sdjIP{--shiki-default:#7C7F93;--shiki-dark:#5F7E97}html pre.shiki code .s-_ek, html code.shiki .s-_ek{--shiki-default:#179299;--shiki-dark:#C792EA}",{"title":134,"searchDepth":148,"depth":148,"links":1624},[1625,1626,1627,1628,1629,1636,1637],{"id":106,"depth":148,"text":107},{"id":126,"depth":148,"text":127},{"id":210,"depth":148,"text":211},{"id":264,"depth":148,"text":265},{"id":314,"depth":148,"text":315,"children":1630},[1631,1632,1633,1634,1635],{"id":329,"depth":154,"text":330},{"id":433,"depth":154,"text":434},{"id":871,"depth":154,"text":872},{"id":1281,"depth":154,"text":1282},{"id":1388,"depth":154,"text":1389},{"id":1507,"depth":148,"text":1508},{"id":1564,"depth":148,"text":1565},"voice-ai","2026-03-27","A hands-on guide to building a voice-powered AI assistant that can see, click, type, and navigate any website - using the Vapi Web SDK and the Webfuse Automation API.","md",[1643,1646,1649],{"question":1644,"answer":1645},"Do I need to pre-configure an assistant in the Vapi Dashboard?","No. In this tutorial, the model, prompt, voice, and tools are all defined inline in code - no Vapi Dashboard configuration is required.",{"question":1647,"answer":1648},"Why does the Vapi SDK run in the popup context rather than a content script?","The Vapi SDK requires WebRTC connections to Daily.co for audio transport. In Webfuse, host_permissions are only respected in the popup and background contexts - content scripts inherit the proxied page's Content Security Policy and cannot make those connections.",{"question":1650,"answer":1651},"Can I add more automation tools beyond the five included?","Yes. The Webfuse Automation API supports additional methods like act.select() for dropdowns, act.textSelect() for highlighting text, and see.guiSnapshot() for screenshots. Each can be wired up as a new tool in src/tools.ts.",0,null,{"shortTitle":1655,"homepage":1656,"relatedLinks":1657},"Voice Agent with Vapi & Webfuse",true,[1658,1661,1664,1667,1669],{"text":1659,"href":1660},"Part 1: Agent Web Integration Methods","/blog/voice-agent-web-control-3-methods-compared",{"text":1662,"href":1663},"Part 2: The Technical Architecture","/blog/architecture-of-a-web-controlling-voice-agent",{"text":1665,"href":1666},"Part 3: Perception & Action API Tools","/blog/how-voice-agents-see-and-act-a-guide-to-dom-tools",{"text":1668,"href":17},"ElevenLabs + Webfuse Tutorial",{"text":1670,"href":100},"GitHub Repository","/blog/building-a-voice-agent-with-vapi-and-webfuse",{"title":5,"description":1640},{"loc":1671},"blog/1037.building-a-voice-agent-with-vapi-and-webfuse",[1676,1677,1678,1679,1680,1681],"ai-agents","voice-agents","web-agents","web-automation","browser-agents","voice-agent-series","SOJ95WKEo2t4L66Ua4i3Zw_N0OYlFxrQMGsYXUB-45o",[1684,3298],{"id":1685,"title":1686,"authorId":1687,"body":1688,"category":1676,"created":3276,"description":3277,"extension":1641,"faqs":1653,"featurePriority":1653,"head":1653,"landingPath":1653,"meta":3278,"navigation":1656,"ogImage":1653,"path":3290,"robots":1653,"schemaOrg":1653,"seo":3291,"sitemap":3292,"stem":3293,"tags":3294,"__hash__":3297},"blog/blog/1012.dom-downsampling-for-llm-based-web-agents.md","DOM Downsampling for LLM-Based Web Agents","thassilo-schiepanski",{"type":8,"value":1689,"toc":3261},[1690,1696,1719,1723,1730,1734,1750,1754,1760,1764,1782,1807,1810,1814,1817,1828,1834,1865,1868,1887,1898,1903,1918,1932,1935,1939,1959,1963,1971,1983,1987,1990,2361,2367,2374,2538,2545,2636,2643,2715,2724,2730,2739,2743,2749,2759,2771,2989,3006,3028,3034,3077,3081,3093,3102,3106,3111,3114,3118,3124,3129,3167,3171,3177,3181,3191,3195,3198,3258],[225,1691],{":width":1692,"alt":1693,"format":1694,"loading":228,"src":1695},"900","Downsampling visualised for digital images and HTML","webp","/blog/dom-downsampling-for-web-agents/1.png",[11,1697,1698,1703,1704,1703,1709,1714,1715,1718],{},[15,1699,1702],{"href":1700,"rel":1701},"https://operator.chatgpt.com",[24],"Operator (OpenAI)",", ",[15,1705,1708],{"href":1706,"rel":1707},"https://www.director.ai",[24],"Director (Browserbase)",[15,1710,1713],{"href":1711,"rel":1712},"https://browser-use.com",[24],"Browser Use"," – we are currently witnessing the rise of ",[51,1716,1717],{},"web AI agents",". The first iteration of serviceable web agents was enabled by frontier LLMs, which act as instantaneous domain model backends. The domain, hereby, corresponds to the landscape of web application UIs.",[104,1720,1722],{"id":1721},"what-is-a-snapshot","What is a Snapshot?",[11,1724,1725,1726,1729],{},"Web agents provide an LLM with a task, and serialised runtime state of a currently browsed web application (e.g., a screenshot). The LLM is ought to suggest relevant actions to perform in the web application. Serialisation of such runtime state is referred to as a ",[51,1727,1728],{},"snapshot",". And the snapshot technique primarily decides the quality of LLM interaction suggestions.",[327,1731,1733],{"id":1732},"gui-snapshots","GUI Snapshots",[11,1735,1736,1737,1740,1741,1745,1746,1749],{},"Screenshots – for consistency reasons referred to as ",[51,1738,1739],{},"GUI snapshots"," – resemble how humans visually perceive web application UIs. LLM APIs subsidise the use of image input through upstream compression. Compresssion, however, irreversibly affects image dimensions, which takes away pixel precision; no way to suggest interactions like ",[1742,1743,1744],"em",{},"“click at 100, 735”",". As a workaround, early web agents used ",[1742,1747,1748],{},"grounded"," GUI snapshots. Grounding describes adding visual cues to the GUI, such as bounding boxes with numerical identifiers. Grounding lets the LLM refer to specific parts of the page by identifier, so the agent can trace back interaction targets.",[225,1751],{":width":1692,"alt":1752,"format":1694,"loading":228,"src":1753},"Grounded GUI snapshot as implemented by Browser Use","/blog/dom-downsampling-for-web-agents/2.png",[11,1755,1756],{},[1757,1758,1759],"small",{},"Grounded GUI snapshot as implemented by Browser Use.",[327,1761,1763],{"id":1762},"dom-snapshots","DOM Snapshots",[11,1765,1766,1767,1777,1778,1781],{},"LLMs arguably are much better at understanding code than images. Research supports they excel at describing and classifying HTML, and also navigating an inherent UI",[1768,1769,1770],"sup",{},[15,1771,1776],{"href":1772,"ariaDescribedBy":1773,"dataFootnoteRef":134,"id":1775},"#user-content-fn-1",[1774],"footnote-label","user-content-fnref-1","1",". The DOM (document object model) – a web browser's runtime state model of a web application – translates back to HTML. For this reason, ",[51,1779,1780],{},"DOM snapshots"," offer a compelling alternative to GUI snapshots. DOM snapshots offer a handful of key advantages:",[213,1783,1784,1787,1790,1793,1796],{},[34,1785,1786],{},"DOM snapshots connect with LLM code (HTML) interpretation abilities.",[34,1788,1789],{},"DOM snapshots can be compiled from deep clones, hidden from supervision (unlike GUI grounding).",[34,1791,1792],{},"DOM snapshots render text input that on average consume less bandwidth than screnshots.",[34,1794,1795],{},"DOM snapshots allow for exact programmatic targeting of elements (e.g., via CSS selectors).",[34,1797,1798,1799,1802,1803,1806],{},"DOM snapshots are available with the ",[136,1800,1801],{},"DOMContentLoaded"," event (whereas the GUI completes initial rendering with ",[136,1804,1805],{},"load",").",[11,1808,1809],{},"Yet, DOM snapshots have a major problem: potentially exhaustive model context. Whereas GUI snapshot commonly cost four figures of tokens, a raw DOM snapshot can cost into hundreds of thousands of tokens. To connect with LLM code interpretation abilities, however, developers have used element extraction techniques – picking only (likely) important elements from the DOM. Element extraction flattens the DOM tree, which disregards hierarchy as a potential UI feature (how do elements relate to each other?).",[104,1811,1813],{"id":1812},"dom-downsampling-a-novel-approach","DOM Downsampling: A Novel Approach",[11,1815,1816],{},"To enable DOM snapshots for use with web agents, it requires client-side pre-processing – similar to how LLM vision APIs process image input. Downsampling is a fundamental signal processing technique that reduces data that scales out of time or space constraints under the assumption that the majority of relevant features is retained. Picture JPEG compression as an example: put simply, a JPEG image stores only an average colour for patches of pixels. The bigger the patches, the smaller the file. Although some detail is lost, key image features – colours, edges, objects – keep being recognisable – up to a large patch size.",[11,1818,1819,1820,1823,1824,1827],{},"We transfer the concept of ",[51,1821,1822],{},"downsampling"," to ",[51,1825,1826],{},"DOMs",". Particularly, since such an approach retains HTML characteristics that might be valuable for an LLM backend. We define UI features as concepts that, to a substantial degree, facilitate LLM suggestions on how to act in the UI in order to solve related web-based tasks.",[104,1829,1831],{"id":1830},"d2snap",[1742,1832,1833],{},"D2Snap",[11,1835,1836,1837,1845,1853,1861,1862,1864],{},"We recently proposed ",[15,1838,1841],{"href":1839,"rel":1840},"https://arxiv.org/abs/2508.04412",[24],[51,1842,1843],{},[1742,1844,1833],{},[1768,1846,1847],{},[15,1848,1852],{"href":1849,"ariaDescribedBy":1850,"dataFootnoteRef":134,"id":1851},"#user-content-fn-2",[1774],"user-content-fnref-2","2",[1768,1854,1855],{},[15,1856,1860],{"href":1857,"ariaDescribedBy":1858,"dataFootnoteRef":134,"id":1859},"#user-content-fn-3",[1774],"user-content-fnref-3","3"," – a first-of-its-kind downsampling algorithm for DOMs. Herein, we'll briefly explain how the ",[1742,1863,1833],{}," algorithm works, and how it can be utilised to build efficient and performant web agents.",[327,1866,1867],{"id":314},"How it works",[11,1869,1870,1871,1873,1874,1703,1877,1880,1881,375,1884,1806],{},"There are basically three redundant types of DOM nodes, and HTML concepts: elements, text, and attributes. We defined and empirically adjusted three node-specific procedures. ",[1742,1872,1833],{}," downsamples at a variable ratio, configured through procedure-specific parameters  ",[136,1875,1876],{},"k",[136,1878,1879],{},"l",", and ",[136,1882,1883],{},"m",[136,1885,1886],{},"∈ [0, 1]",[418,1888,1889],{},[11,1890,1891,1892,1897],{},"We used ",[15,1893,1896],{"href":1894,"rel":1895},"https://openai.com/index/hello-gpt-4o/",[24],"GPT-4o"," to create a downsampling ground truth dataset by having it classify HTML elements and scoring semantics regarding relevance for understanding the inherent UI – a UI feature degree.",[1899,1900,1902],"h4",{"id":1901},"procedure-elements","Procedure: Elements",[11,1904,1905,1907,1908,87,1911,1914,1915,1917],{},[1742,1906,1833],{}," downsamples (simplifies) elements by merging container elements like ",[136,1909,1910],{},"section",[136,1912,1913],{},"div"," together. A parameter ",[136,1916,1876],{}," controls the merge ratio depending on the total DOM tree height. For competing concepts, such as element name, the ground truth determines which element's characterisitics to keep – comparing UI feature scores.",[11,1919,1920,1921,1703,1923,1925,1926,1931],{},"Elements in content elements (",[136,1922,11],{},[136,1924,418],{},", ...) are translated to a more comprehensive ",[15,1927,1930],{"href":1928,"rel":1929},"https://www.markdownguide.org/basic-syntax/",[24],"Markdown"," representation.",[11,1933,1934],{},"Interactive elements, definite interaction target candidates, are kept as is.",[1899,1936,1938],{"id":1937},"procedure-text","Procedure: Text",[11,1940,1941,1943,1944,1947,1955,1956,1958],{},[1742,1942,1833],{}," downsamples text by dropping a fraction. Natural units of text are space-separated words, or punctuation-separated sentences. We reuse the ",[1742,1945,1946],{},"TextRank",[1768,1948,1949],{},[15,1950,1954],{"href":1951,"ariaDescribedBy":1952,"dataFootnoteRef":134,"id":1953},"#user-content-fn-4",[1774],"user-content-fnref-4","4"," algorithm to rank sentences in text nodes. The lowest-ranking fraction of sentences, denoted by parameter ",[136,1957,1879],{},", is dropped.",[1899,1960,1962],{"id":1961},"procedure-attributes","Procedure: Attributes",[11,1964,1965,1967,1968,1970],{},[1742,1966,1833],{}," downsamples attributes by dropping those with a name that, according to ground truth, holds a UI feature degree below a threshold. Parameter ",[136,1969,1883],{}," denotes this threshold.",[418,1972,1973],{},[11,1974,1975,1976,1982],{},"Check out the ",[15,1977,1979,1981],{"href":1839,"rel":1978},[24],[1742,1980,1833],{}," paper"," to learn about the algorithm in-depth.",[327,1984,1986],{"id":1985},"example-of-a-downsampled-dom","Example of a Downsampled DOM",[11,1988,1989],{},"Consider a partial DOM state, serialised as HTML:",[129,1991,1995],{"className":1992,"code":1993,"language":1994,"meta":134,"style":134},"language-html shiki shiki-themes catppuccin-latte night-owl","\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: mozzarela, 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","html",[136,1996,1997,2056,2099,2119,2127,2147,2165,2173,2178,2183,2192,2220,2229,2247,2265,2274,2280,2286,2296,2323,2332,2342,2352],{"__ignoreMap":134},[139,1998,1999,2001,2004,2008,2011,2013,2016,2018,2021,2023,2025,2027,2029,2032,2034,2036,2039,2041,2044,2046,2048,2051,2053],{"class":141,"line":142},[139,2000,1096],{"class":1048},[139,2002,1910],{"class":2003},"sY2RG",[139,2005,2007],{"class":2006},"swkLt"," class",[139,2009,2010],{"class":1048},"=",[139,2012,494],{"class":486},[139,2014,2015],{"class":490},"container",[139,2017,494],{"class":486},[139,2019,2020],{"class":2006}," tabindex",[139,2022,2010],{"class":1048},[139,2024,494],{"class":486},[139,2026,1860],{"class":490},[139,2028,494],{"class":486},[139,2030,2031],{"class":2006}," required",[139,2033,2010],{"class":1048},[139,2035,494],{"class":486},[139,2037,2038],{"class":490},"true",[139,2040,494],{"class":486},[139,2042,2043],{"class":2006}," type",[139,2045,2010],{"class":1048},[139,2047,494],{"class":486},[139,2049,2050],{"class":490},"example",[139,2052,494],{"class":486},[139,2054,2055],{"class":1048},">\n",[139,2057,2058,2061,2063,2065,2067,2069,2072,2074,2077,2079,2081,2084,2086,2088,2090,2092,2095,2097],{"class":141,"line":148},[139,2059,2060],{"class":1048},"  \u003C",[139,2062,1913],{"class":2003},[139,2064,2007],{"class":2006},[139,2066,2010],{"class":1048},[139,2068,494],{"class":486},[139,2070,2071],{"class":490},"mx-auto",[139,2073,494],{"class":486},[139,2075,2076],{"class":2006}," data-topic",[139,2078,2010],{"class":1048},[139,2080,494],{"class":486},[139,2082,2083],{"class":490},"products",[139,2085,494],{"class":486},[139,2087,2031],{"class":2006},[139,2089,2010],{"class":1048},[139,2091,494],{"class":486},[139,2093,2094],{"class":490},"false",[139,2096,494],{"class":486},[139,2098,2055],{"class":1048},[139,2100,2101,2104,2107,2109,2112,2115,2117],{"class":141,"line":154},[139,2102,2103],{"class":1048},"    \u003C",[139,2105,2106],{"class":2003},"h1",[139,2108,1102],{"class":1048},[139,2110,2111],{"class":449},"Our Pizza",[139,2113,2114],{"class":1048},"\u003C/",[139,2116,2106],{"class":2003},[139,2118,2055],{"class":1048},[139,2120,2121,2123,2125],{"class":141,"line":160},[139,2122,2103],{"class":1048},[139,2124,1913],{"class":2003},[139,2126,2055],{"class":1048},[139,2128,2129,2132,2134,2136,2138,2140,2143,2145],{"class":141,"line":198},[139,2130,2131],{"class":1048},"      \u003C",[139,2133,1913],{"class":2003},[139,2135,2007],{"class":2006},[139,2137,2010],{"class":1048},[139,2139,494],{"class":486},[139,2141,2142],{"class":490},"shadow-lg",[139,2144,494],{"class":486},[139,2146,2055],{"class":1048},[139,2148,2149,2152,2154,2156,2159,2161,2163],{"class":141,"line":204},[139,2150,2151],{"class":1048},"        \u003C",[139,2153,104],{"class":2003},[139,2155,1102],{"class":1048},[139,2157,2158],{"class":449},"Margherita",[139,2160,2114],{"class":1048},[139,2162,104],{"class":2003},[139,2164,2055],{"class":1048},[139,2166,2167,2169,2171],{"class":141,"line":572},[139,2168,2151],{"class":1048},[139,2170,11],{"class":2003},[139,2172,2055],{"class":1048},[139,2174,2175],{"class":141,"line":578},[139,2176,2177],{"class":449},"          A simple classic: mozzarela, tomatoes and basil.\n",[139,2179,2180],{"class":141,"line":632},[139,2181,2182],{"class":449},"          An everyday choice!\n",[139,2184,2185,2188,2190],{"class":141,"line":668},[139,2186,2187],{"class":1048},"        \u003C/",[139,2189,11],{"class":2003},[139,2191,2055],{"class":1048},[139,2193,2194,2196,2199,2201,2203,2205,2207,2209,2211,2214,2216,2218],{"class":141,"line":685},[139,2195,2151],{"class":1048},[139,2197,2198],{"class":2003},"button",[139,2200,2043],{"class":2006},[139,2202,2010],{"class":1048},[139,2204,494],{"class":486},[139,2206,2198],{"class":490},[139,2208,494],{"class":486},[139,2210,1102],{"class":1048},[139,2212,2213],{"class":449},"Add",[139,2215,2114],{"class":1048},[139,2217,2198],{"class":2003},[139,2219,2055],{"class":1048},[139,2221,2222,2225,2227],{"class":141,"line":702},[139,2223,2224],{"class":1048},"      \u003C/",[139,2226,1913],{"class":2003},[139,2228,2055],{"class":1048},[139,2230,2231,2233,2235,2237,2239,2241,2243,2245],{"class":141,"line":732},[139,2232,2131],{"class":1048},[139,2234,1913],{"class":2003},[139,2236,2007],{"class":2006},[139,2238,2010],{"class":1048},[139,2240,494],{"class":486},[139,2242,2142],{"class":490},[139,2244,494],{"class":486},[139,2246,2055],{"class":1048},[139,2248,2250,2252,2254,2256,2259,2261,2263],{"class":141,"line":2249},14,[139,2251,2151],{"class":1048},[139,2253,104],{"class":2003},[139,2255,1102],{"class":1048},[139,2257,2258],{"class":449},"Capricciosa",[139,2260,2114],{"class":1048},[139,2262,104],{"class":2003},[139,2264,2055],{"class":1048},[139,2266,2268,2270,2272],{"class":141,"line":2267},15,[139,2269,2151],{"class":1048},[139,2271,11],{"class":2003},[139,2273,2055],{"class":1048},[139,2275,2277],{"class":141,"line":2276},16,[139,2278,2279],{"class":449},"          A rich taste: mozzarella, ham, mushrooms, artichokes, and olives.\n",[139,2281,2283],{"class":141,"line":2282},17,[139,2284,2285],{"class":449},"          A true favourite!\n",[139,2287,2289,2292,2294],{"class":141,"line":2288},18,[139,2290,2291],{"class":1048},"          \u003C/",[139,2293,11],{"class":2003},[139,2295,2055],{"class":1048},[139,2297,2299,2301,2303,2305,2307,2309,2311,2313,2315,2317,2319,2321],{"class":141,"line":2298},19,[139,2300,2151],{"class":1048},[139,2302,2198],{"class":2003},[139,2304,2043],{"class":2006},[139,2306,2010],{"class":1048},[139,2308,494],{"class":486},[139,2310,2198],{"class":490},[139,2312,494],{"class":486},[139,2314,1102],{"class":1048},[139,2316,2213],{"class":449},[139,2318,2114],{"class":1048},[139,2320,2198],{"class":2003},[139,2322,2055],{"class":1048},[139,2324,2326,2328,2330],{"class":141,"line":2325},20,[139,2327,2224],{"class":1048},[139,2329,1913],{"class":2003},[139,2331,2055],{"class":1048},[139,2333,2335,2338,2340],{"class":141,"line":2334},21,[139,2336,2337],{"class":1048},"    \u003C/",[139,2339,1913],{"class":2003},[139,2341,2055],{"class":1048},[139,2343,2345,2348,2350],{"class":141,"line":2344},22,[139,2346,2347],{"class":1048},"  \u003C/",[139,2349,1913],{"class":2003},[139,2351,2055],{"class":1048},[139,2353,2355,2357,2359],{"class":141,"line":2354},23,[139,2356,2114],{"class":1048},[139,2358,1910],{"class":2003},[139,2360,2055],{"class":1048},[11,2362,2363,2364,2366],{},"Here are some ",[1742,2365,1833],{}," downsampling results, which are based on different parametric configurations. A percentage denotes the reduced size.",[1899,2368,2370,2373],{"id":2369},"k3-l3-m3-55",[136,2371,2372],{},"k=.3, l=.3, m=.3"," (55%)",[129,2375,2377],{"className":1992,"code":2376,"language":1994,"meta":134,"style":134},"\u003Csection tabindex=\"3\" type=\"example\" class=\"container\" required=\"true\">\n  # Our Pizza\n  \u003Cdiv class=\"shadow-lg\">\n    ## Margherita\n    A simple classic: mozzarela, tomatoes, and basil.\n    \u003Cbutton type=\"button\">Add\u003C/button>\n    ## Capricciosa\n    A rich taste: mozzarella, ham, mushrooms, artichokes, and olives.\n    \u003Cbutton type=\"button\">Add\u003C/button>\n  \u003C/div>\n\u003C/section>\n",[136,2378,2379,2427,2432,2450,2455,2460,2486,2491,2496,2522,2530],{"__ignoreMap":134},[139,2380,2381,2383,2385,2387,2389,2391,2393,2395,2397,2399,2401,2403,2405,2407,2409,2411,2413,2415,2417,2419,2421,2423,2425],{"class":141,"line":142},[139,2382,1096],{"class":1048},[139,2384,1910],{"class":2003},[139,2386,2020],{"class":2006},[139,2388,2010],{"class":1048},[139,2390,494],{"class":486},[139,2392,1860],{"class":490},[139,2394,494],{"class":486},[139,2396,2043],{"class":2006},[139,2398,2010],{"class":1048},[139,2400,494],{"class":486},[139,2402,2050],{"class":490},[139,2404,494],{"class":486},[139,2406,2007],{"class":2006},[139,2408,2010],{"class":1048},[139,2410,494],{"class":486},[139,2412,2015],{"class":490},[139,2414,494],{"class":486},[139,2416,2031],{"class":2006},[139,2418,2010],{"class":1048},[139,2420,494],{"class":486},[139,2422,2038],{"class":490},[139,2424,494],{"class":486},[139,2426,2055],{"class":1048},[139,2428,2429],{"class":141,"line":148},[139,2430,2431],{"class":449},"  # Our Pizza\n",[139,2433,2434,2436,2438,2440,2442,2444,2446,2448],{"class":141,"line":154},[139,2435,2060],{"class":1048},[139,2437,1913],{"class":2003},[139,2439,2007],{"class":2006},[139,2441,2010],{"class":1048},[139,2443,494],{"class":486},[139,2445,2142],{"class":490},[139,2447,494],{"class":486},[139,2449,2055],{"class":1048},[139,2451,2452],{"class":141,"line":160},[139,2453,2454],{"class":449},"    ## Margherita\n",[139,2456,2457],{"class":141,"line":198},[139,2458,2459],{"class":449},"    A simple classic: mozzarela, tomatoes, and basil.\n",[139,2461,2462,2464,2466,2468,2470,2472,2474,2476,2478,2480,2482,2484],{"class":141,"line":204},[139,2463,2103],{"class":1048},[139,2465,2198],{"class":2003},[139,2467,2043],{"class":2006},[139,2469,2010],{"class":1048},[139,2471,494],{"class":486},[139,2473,2198],{"class":490},[139,2475,494],{"class":486},[139,2477,1102],{"class":1048},[139,2479,2213],{"class":449},[139,2481,2114],{"class":1048},[139,2483,2198],{"class":2003},[139,2485,2055],{"class":1048},[139,2487,2488],{"class":141,"line":572},[139,2489,2490],{"class":449},"    ## Capricciosa\n",[139,2492,2493],{"class":141,"line":578},[139,2494,2495],{"class":449},"    A rich taste: mozzarella, ham, mushrooms, artichokes, and olives.\n",[139,2497,2498,2500,2502,2504,2506,2508,2510,2512,2514,2516,2518,2520],{"class":141,"line":632},[139,2499,2103],{"class":1048},[139,2501,2198],{"class":2003},[139,2503,2043],{"class":2006},[139,2505,2010],{"class":1048},[139,2507,494],{"class":486},[139,2509,2198],{"class":490},[139,2511,494],{"class":486},[139,2513,1102],{"class":1048},[139,2515,2213],{"class":449},[139,2517,2114],{"class":1048},[139,2519,2198],{"class":2003},[139,2521,2055],{"class":1048},[139,2523,2524,2526,2528],{"class":141,"line":668},[139,2525,2347],{"class":1048},[139,2527,1913],{"class":2003},[139,2529,2055],{"class":1048},[139,2531,2532,2534,2536],{"class":141,"line":685},[139,2533,2114],{"class":1048},[139,2535,1910],{"class":2003},[139,2537,2055],{"class":1048},[1899,2539,2541,2544],{"id":2540},"k4-l6-m8-27",[136,2542,2543],{},"k=.4, l=.6, m=.8"," (27%)",[129,2546,2548],{"className":1992,"code":2547,"language":1994,"meta":134,"style":134},"\u003Csection>\n  # Our Pizza\n  \u003Cdiv>\n    ## Margherita\n    A simple classic:\n    \u003Cbutton>Add\u003C/button>\n    ## Capricciosa\n    A rich taste:\n    \u003Cbutton>Add\u003C/button>\n  \u003C/div>\n\u003C/section>\n",[136,2549,2550,2558,2562,2570,2574,2579,2595,2599,2604,2620,2628],{"__ignoreMap":134},[139,2551,2552,2554,2556],{"class":141,"line":142},[139,2553,1096],{"class":1048},[139,2555,1910],{"class":2003},[139,2557,2055],{"class":1048},[139,2559,2560],{"class":141,"line":148},[139,2561,2431],{"class":449},[139,2563,2564,2566,2568],{"class":141,"line":154},[139,2565,2060],{"class":1048},[139,2567,1913],{"class":2003},[139,2569,2055],{"class":1048},[139,2571,2572],{"class":141,"line":160},[139,2573,2454],{"class":449},[139,2575,2576],{"class":141,"line":198},[139,2577,2578],{"class":449},"    A simple classic:\n",[139,2580,2581,2583,2585,2587,2589,2591,2593],{"class":141,"line":204},[139,2582,2103],{"class":1048},[139,2584,2198],{"class":2003},[139,2586,1102],{"class":1048},[139,2588,2213],{"class":449},[139,2590,2114],{"class":1048},[139,2592,2198],{"class":2003},[139,2594,2055],{"class":1048},[139,2596,2597],{"class":141,"line":572},[139,2598,2490],{"class":449},[139,2600,2601],{"class":141,"line":578},[139,2602,2603],{"class":449},"    A rich taste:\n",[139,2605,2606,2608,2610,2612,2614,2616,2618],{"class":141,"line":632},[139,2607,2103],{"class":1048},[139,2609,2198],{"class":2003},[139,2611,1102],{"class":1048},[139,2613,2213],{"class":449},[139,2615,2114],{"class":1048},[139,2617,2198],{"class":2003},[139,2619,2055],{"class":1048},[139,2621,2622,2624,2626],{"class":141,"line":668},[139,2623,2347],{"class":1048},[139,2625,1913],{"class":2003},[139,2627,2055],{"class":1048},[139,2629,2630,2632,2634],{"class":141,"line":685},[139,2631,2114],{"class":1048},[139,2633,1910],{"class":2003},[139,2635,2055],{"class":1048},[1899,2637,2639,2642],{"id":2638},"k-l0-m-35",[136,2640,2641],{},"k→∞, l=0, ∀m"," (35%)",[129,2644,2646],{"className":1992,"code":2645,"language":1994,"meta":134,"style":134},"# Our Pizza\n## Margherita\nA simple classic: mozzarela, tomatoes, and basil.\nAn everyday choice!\n\u003Cbutton>Add\u003C/button>\n## Capricciosa\nA rich taste: mozzarella, ham, mushrooms, artichokes, and olives.\nA true favourite!\n\u003Cbutton>Add\u003C/button>\n",[136,2647,2648,2653,2658,2663,2668,2684,2689,2694,2699],{"__ignoreMap":134},[139,2649,2650],{"class":141,"line":142},[139,2651,2652],{"class":449},"# Our Pizza\n",[139,2654,2655],{"class":141,"line":148},[139,2656,2657],{"class":449},"## Margherita\n",[139,2659,2660],{"class":141,"line":154},[139,2661,2662],{"class":449},"A simple classic: mozzarela, tomatoes, and basil.\n",[139,2664,2665],{"class":141,"line":160},[139,2666,2667],{"class":449},"An everyday choice!\n",[139,2669,2670,2672,2674,2676,2678,2680,2682],{"class":141,"line":198},[139,2671,1096],{"class":1048},[139,2673,2198],{"class":2003},[139,2675,1102],{"class":1048},[139,2677,2213],{"class":449},[139,2679,2114],{"class":1048},[139,2681,2198],{"class":2003},[139,2683,2055],{"class":1048},[139,2685,2686],{"class":141,"line":204},[139,2687,2688],{"class":449},"## Capricciosa\n",[139,2690,2691],{"class":141,"line":572},[139,2692,2693],{"class":449},"A rich taste: mozzarella, ham, mushrooms, artichokes, and olives.\n",[139,2695,2696],{"class":141,"line":578},[139,2697,2698],{"class":449},"A true favourite!\n",[139,2700,2701,2703,2705,2707,2709,2711,2713],{"class":141,"line":632},[139,2702,1096],{"class":1048},[139,2704,2198],{"class":2003},[139,2706,1102],{"class":1048},[139,2708,2213],{"class":449},[139,2710,2114],{"class":1048},[139,2712,2198],{"class":2003},[139,2714,2055],{"class":1048},[11,2716,2717,2718,2720,2721,2723],{},"Asymptotic ",[136,2719,1876],{}," (kind of 'infinite' ",[136,2722,1876],{},") completely flattens the DOM, that is, leads to a full content linearisation similar to reader views as present in most browsers. Notably, it preserves all interactive elements like buttons – which are essential for a web agent.",[327,2725,2727],{"id":2726},"adaptived2snap",[1742,2728,2729],{},"AdaptiveD2Snap",[11,2731,2732,2733,2735,2736,2738],{},"Fixed parameters might not be ideal for arbitrary DOMs – sourced from a landscape of web applications. We created ",[1742,2734,2729],{}," – a wrapper for ",[1742,2737,1833],{}," that infers suitable parameters from a given DOM in order to hit a certain token budget.",[327,2740,2742],{"id":2741},"implementation-integration","Implementation & Integration",[11,2744,2745,2746,2748],{},"Picture an LLM-based weg agent that is premised on DOM snapshots. Implementing ",[1742,2747,1833],{}," is simple: Deep clone the DOM, and feed it to the algorithm. Now, take the snapshot; this is, serialise the resulting DOM. Done.",[418,2750,2751],{},[11,2752,2753,2754,2758],{},"Read our ",[15,2755,2757],{"href":2756},"/blog/a-gentle-introduction-to-ai-agents-for-the-web","gentle introduction to AI agents for the web"," to get started with high-level web agent concepts.",[11,2760,2761,2762,2764,2765,2770],{},"The open source ",[1742,2763,1833],{}," API, provided as a ",[15,2766,2769],{"href":2767,"rel":2768},"https://github.com/webfuse-com/D2Snap",[24],"package on GitHub"," provides the following signature:",[129,2772,2776],{"className":2773,"code":2774,"language":2775,"meta":134,"style":134},"language-ts shiki shiki-themes catppuccin-latte night-owl","type DOM = Document | Element | string;\ntype Options = {\n  assignUniqueIDs?: boolean; // false\n  debug?: boolean;           // true\n};\n\nD2Snap.d2Snap(\n  dom: DOM,\n  k: number, l: number, m: number,\n  options?: Options\n): Promise\u003Cstring>\n\nD2Snap.adaptiveD2Snap(\n  dom: DOM,\n  maxTokens: number = 4096,\n  maxIterations: number = 5,\n  options?: Options\n): Promise\u003Cstring>\n\n","ts",[136,2777,2778,2803,2814,2833,2847,2852,2857,2868,2879,2896,2906,2922,2926,2937,2945,2957,2969,2977],{"__ignoreMap":134},[139,2779,2780,2783,2786,2788,2791,2794,2797,2799,2801],{"class":141,"line":142},[139,2781,2782],{"class":900},"type",[139,2784,2785],{"class":1081}," DOM ",[139,2787,2010],{"class":1323},[139,2789,2790],{"class":1091}," Document",[139,2792,2793],{"class":1048}," |",[139,2795,2796],{"class":1091}," Element",[139,2798,2793],{"class":1048},[139,2800,1052],{"class":1051},[139,2802,739],{"class":463},[139,2804,2805,2807,2810,2812],{"class":141,"line":148},[139,2806,2782],{"class":900},[139,2808,2809],{"class":1081}," Options ",[139,2811,2010],{"class":1323},[139,2813,476],{"class":463},[139,2815,2816,2820,2823,2826,2829],{"class":141,"line":154},[139,2817,2819],{"class":2818},"swl0y","  assignUniqueIDs",[139,2821,2822],{"class":1048},"?:",[139,2824,2825],{"class":1051}," boolean",[139,2827,2828],{"class":463},";",[139,2830,2832],{"class":2831},"sDmS1"," // false\n",[139,2834,2835,2838,2840,2842,2844],{"class":141,"line":160},[139,2836,2837],{"class":2818},"  debug",[139,2839,2822],{"class":1048},[139,2841,2825],{"class":1051},[139,2843,2828],{"class":463},[139,2845,2846],{"class":2831},"           // true\n",[139,2848,2849],{"class":141,"line":198},[139,2850,2851],{"class":463},"};\n",[139,2853,2854],{"class":141,"line":204},[139,2855,2856],{"emptyLinePlaceholder":1656},"\n",[139,2858,2859,2861,2863,2866],{"class":141,"line":572},[139,2860,1833],{"class":449},[139,2862,70],{"class":453},[139,2864,2865],{"class":456},"d2Snap",[139,2867,1040],{"class":449},[139,2869,2870,2873,2877],{"class":141,"line":578},[139,2871,2872],{"class":449},"  dom: ",[139,2874,2876],{"class":2875},"sqxXB","DOM",[139,2878,497],{"class":463},[139,2880,2881,2884,2886,2889,2891,2894],{"class":141,"line":632},[139,2882,2883],{"class":449},"  k: number",[139,2885,541],{"class":463},[139,2887,2888],{"class":449}," l: number",[139,2890,541],{"class":463},[139,2892,2893],{"class":449}," m: number",[139,2895,497],{"class":463},[139,2897,2898,2901,2903],{"class":141,"line":668},[139,2899,2900],{"class":449},"  options",[139,2902,2822],{"class":1323},[139,2904,2905],{"class":449}," Options\n",[139,2907,2908,2911,2915,2917,2920],{"class":141,"line":685},[139,2909,2910],{"class":449},"): ",[139,2912,2914],{"class":2913},"s8Irk","Promise",[139,2916,1096],{"class":1323},[139,2918,2919],{"class":449},"string",[139,2921,2055],{"class":1323},[139,2923,2924],{"class":141,"line":702},[139,2925,2856],{"emptyLinePlaceholder":1656},[139,2927,2928,2930,2932,2935],{"class":141,"line":732},[139,2929,1833],{"class":449},[139,2931,70],{"class":453},[139,2933,2934],{"class":456},"adaptiveD2Snap",[139,2936,1040],{"class":449},[139,2938,2939,2941,2943],{"class":141,"line":2249},[139,2940,2872],{"class":449},[139,2942,2876],{"class":2875},[139,2944,497],{"class":463},[139,2946,2947,2950,2952,2955],{"class":141,"line":2267},[139,2948,2949],{"class":449},"  maxTokens: number ",[139,2951,2010],{"class":1323},[139,2953,2954],{"class":1129}," 4096",[139,2956,497],{"class":463},[139,2958,2959,2962,2964,2967],{"class":141,"line":2276},[139,2960,2961],{"class":449},"  maxIterations: number ",[139,2963,2010],{"class":1323},[139,2965,2966],{"class":1129}," 5",[139,2968,497],{"class":463},[139,2970,2971,2973,2975],{"class":141,"line":2282},[139,2972,2900],{"class":449},[139,2974,2822],{"class":1323},[139,2976,2905],{"class":449},[139,2978,2979,2981,2983,2985,2987],{"class":141,"line":2288},[139,2980,2910],{"class":449},[139,2982,2914],{"class":2913},[139,2984,1096],{"class":1323},[139,2986,2919],{"class":449},[139,2988,2055],{"class":1323},[11,2990,2991,2992,2994,2995,2999,3000,3005],{},"Moreover, ",[1742,2993,1833],{}," it is available on the ",[15,2996,47],{"href":2997,"rel":2998},"https://dev.webfuse.com/automation-api",[24],". ",[15,3001,3004],{"href":3002,"rel":3003},"https://www.webfuse.com",[24],"Webfuse"," essentially is a proxy to seamlessly serve any existing web application with custom augmentations, such as a web agent widget.",[129,3007,3011],{"className":3008,"code":3009,"language":3010,"meta":134,"style":134},"language-js shiki shiki-themes catppuccin-latte night-owl","const domSnapshot = await browser.webfuseSession\n    .automation\n    .take_dom_snapshot({ modifier: 'downsample' })\n","js",[136,3012,3013,3018,3023],{"__ignoreMap":134},[139,3014,3015],{"class":141,"line":142},[139,3016,3017],{},"const domSnapshot = await browser.webfuseSession\n",[139,3019,3020],{"class":141,"line":148},[139,3021,3022],{},"    .automation\n",[139,3024,3025],{"class":141,"line":154},[139,3026,3027],{},"    .take_dom_snapshot({ modifier: 'downsample' })\n",[11,3029,3030,3031,3033],{},"Need precise control over the underlying ",[1742,3032,1833],{}," invocation? Configure it exactly how you want:",[129,3035,3037],{"className":3008,"code":3036,"language":3010,"meta":134,"style":134},"const domSnapshot = await browser.webfuseSession\n    .automation\n    .take_dom_snapshot({\n        modifier: {\n            name: 'D2Snap',\n            params: { hierarchyRatio: 0.6, textRatio: 0.2, attributeRatio: 0.8 }\n        }\n    })\n",[136,3038,3039,3043,3047,3052,3057,3062,3067,3072],{"__ignoreMap":134},[139,3040,3041],{"class":141,"line":142},[139,3042,3017],{},[139,3044,3045],{"class":141,"line":148},[139,3046,3022],{},[139,3048,3049],{"class":141,"line":154},[139,3050,3051],{},"    .take_dom_snapshot({\n",[139,3053,3054],{"class":141,"line":160},[139,3055,3056],{},"        modifier: {\n",[139,3058,3059],{"class":141,"line":198},[139,3060,3061],{},"            name: 'D2Snap',\n",[139,3063,3064],{"class":141,"line":204},[139,3065,3066],{},"            params: { hierarchyRatio: 0.6, textRatio: 0.2, attributeRatio: 0.8 }\n",[139,3068,3069],{"class":141,"line":572},[139,3070,3071],{},"        }\n",[139,3073,3074],{"class":141,"line":578},[139,3075,3076],{},"    })\n",[327,3078,3080],{"id":3079},"performance-evaluation","Performance Evaluation",[11,3082,3083,3084,3086,3087,3089,3090,3092],{},"Now for the moment of truth: How does ",[1742,3085,1833],{}," stack up against the industry standard? We evaluated ",[1742,3088,1833],{}," in comparison to a grounded GUI snapshot baseline close to those used by ",[1742,3091,1713],{}," – coloured bounding boxes around visible interactive elements.",[11,3094,3095,3096,3101],{},"To evaluate snapshots isolated from specific agent logic, we crafted a dataset that spans all UI states that occur while solving a related task. We sampled our dataset from the existing ",[15,3097,3100],{"href":3098,"rel":3099},"https://github.com/OSU-NLP-Group/Online-Mind2Web",[24],"Online-Mind2Web"," dataset.",[225,3103],{":width":324,"alt":3104,"format":1694,"loading":228,"src":3105},"Exemplary solution UI state trajectory of a defined web-based task","/blog/dom-downsampling-for-web-agents/3.png",[11,3107,3108],{},[1757,3109,3110],{},"Exemplary solution UI state trajectory for the task: “View the pricing plan for 'Business'. Specifically, we have 100 users. We need a 1PB storage quota and a 50 TB transfer quota.”",[11,3112,3113],{},"These are our key findings...",[1899,3115,3117],{"id":3116},"substantial-success-rates","Substantial Success Rates",[11,3119,3120,3121,3123],{},"The results exceeded our expectations. Not only did ",[1742,3122,1833],{}," meet the baseline's performance – our best configuration outperformed it by a significant margin. Full linearisation matches performance, and estimated model input token size order of the baseline.",[225,3125],{":width":3126,"alt":3127,"format":1694,"loading":228,"src":3128},"550","Success rate per web agent snapshot subject evaluated across the dataset","/blog/dom-downsampling-for-web-agents/4.png",[1757,3130,3131,3132,3139,3140,3142,3143,3146,3147,3150,3151,3154,3155,3158,3159,3162,3163,3166],{},"\n  Success rate per web agent snapshot subject evaluated across the dataset.\n  Labels: ",[136,3133,3134,3135],{},"GUI",[3136,3137,3138],"sub",{}," gr.",": Baseline, ",[136,3141,2876],{},": Raw DOM (cut-off at ~8K tokens), ",[136,3144,3145],{},"k( l m)",": Parameter values; e.g., ",[136,3148,3149],{},".9 .3 .6",", or ",[136,3152,3153],{},".4"," if equal). ",[136,3156,3157],{},"∞",": Linearisation,  ",[136,3160,3161],{},"8192 / 32768",": via token-limited (resp.) ",[3164,3165,2729],"i",{},".\n",[1899,3168,3170],{"id":3169},"containable-token-and-byte-size","Containable Token and Byte Size",[11,3172,3173,3174,3176],{},"Even light downsampling delivers dramatic size reductions. Most ",[1742,3175,1833],{}," configurations average just one token order above the baseline – a massive improvement over raw DOM snapshots. Better yet, most DOMs from the dataset could actually be downsampled to the baseline order. And while image data balloons in file size, our text-based approach stays lean and efficient.",[225,3178],{":width":324,"alt":3179,"format":1694,"loading":228,"src":3180},"Comparison of mean input size across and per subject","/blog/dom-downsampling-for-web-agents/5.png",[1757,3182,3183,3184,3187,3188,3190],{},"\n  Left: Comparison of mean input size (tokens vs bytes) across and per subject.",[3185,3186],"br",{},"\n  Right: Estimated input token size across the dataset created by a single ",[3164,3189,1833],{}," evaluation subject.\n",[1899,3192,3194],{"id":3193},"hierarchy-actually-matters","Hierarchy Actually Matters",[11,3196,3197],{},"Which UI feature matters most for LLM web agent backend performance? We alternated parameter configurations to find out. Interestingly, hierarchy reveals itself as the strongest of the three assessed features. Element extraction throws away hierarchy, which suggests that downsampling is a superior technique.",[1910,3199,3202,3207],{"className":3200,"dataFootnotes":134},[3201],"footnotes",[104,3203,3206],{"className":3204,"id":1774},[3205],"sr-only","Footnotes",[213,3208,3209,3224,3235,3246],{},[34,3210,3212,3216,3217],{"id":3211},"user-content-fn-1",[15,3213,3214],{"href":3214,"rel":3215},"https://arxiv.org/abs/2210.03945",[24]," ",[15,3218,3223],{"href":3219,"ariaLabel":3220,"className":3221,"dataFootnoteBackref":134},"#user-content-fnref-1","Back to reference 1",[3222],"data-footnote-backref","↩",[34,3225,3227,3216,3230],{"id":3226},"user-content-fn-2",[15,3228,1839],{"href":1839,"rel":3229},[24],[15,3231,3223],{"href":3232,"ariaLabel":3233,"className":3234,"dataFootnoteBackref":134},"#user-content-fnref-2","Back to reference 2",[3222],[34,3236,3238,3216,3241],{"id":3237},"user-content-fn-3",[15,3239,2767],{"href":2767,"rel":3240},[24],[15,3242,3223],{"href":3243,"ariaLabel":3244,"className":3245,"dataFootnoteBackref":134},"#user-content-fnref-3","Back to reference 3",[3222],[34,3247,3249,3216,3253],{"id":3248},"user-content-fn-4",[15,3250,3251],{"href":3251,"rel":3252},"https://aclanthology.org/W04-3252",[24],[15,3254,3223],{"href":3255,"ariaLabel":3256,"className":3257,"dataFootnoteBackref":134},"#user-content-fnref-4","Back to reference 4",[3222],[1620,3259,3260],{},"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 .s9rnR, html code.shiki .s9rnR{--shiki-default:#179299;--shiki-dark:#7FDBCA}html pre.shiki code .sY2RG, html code.shiki .sY2RG{--shiki-default:#1E66F5;--shiki-dark:#CAECE6}html pre.shiki code .swkLt, html code.shiki .swkLt{--shiki-default:#DF8E1D;--shiki-default-font-style:inherit;--shiki-dark:#C5E478;--shiki-dark-font-style:italic}html pre.shiki code .sbuKk, html code.shiki .sbuKk{--shiki-default:#40A02B;--shiki-dark:#D9F5DD}html pre.shiki code .sfrMT, html code.shiki .sfrMT{--shiki-default:#40A02B;--shiki-dark:#ECC48D}html pre.shiki code .s2kId, html code.shiki .s2kId{--shiki-default:#4C4F69;--shiki-dark:#D6DEEB}html pre.shiki code .s76yb, html code.shiki .s76yb{--shiki-default:#8839EF;--shiki-dark:#C792EA}html pre.shiki code .sXbZB, html code.shiki .sXbZB{--shiki-default:#DF8E1D;--shiki-default-font-style:italic;--shiki-dark:#D6DEEB;--shiki-dark-font-style:inherit}html pre.shiki code .s-_ek, html code.shiki .s-_ek{--shiki-default:#179299;--shiki-dark:#C792EA}html pre.shiki code .s-DR7, html code.shiki .s-DR7{--shiki-default:#DF8E1D;--shiki-default-font-style:italic;--shiki-dark:#FFCB8B;--shiki-dark-font-style:inherit}html pre.shiki code .scrte, html code.shiki .scrte{--shiki-default:#8839EF;--shiki-dark:#C5E478}html pre.shiki code .scGhl, html code.shiki .scGhl{--shiki-default:#7C7F93;--shiki-dark:#D6DEEB}html pre.shiki code .swl0y, html code.shiki .swl0y{--shiki-default:#4C4F69;--shiki-default-font-style:italic;--shiki-dark:#D6DEEB;--shiki-dark-font-style:inherit}html pre.shiki code .sDmS1, html code.shiki .sDmS1{--shiki-default:#7C7F93;--shiki-default-font-style:italic;--shiki-dark:#637777;--shiki-dark-font-style:italic}html pre.shiki code .s5FwJ, html code.shiki .s5FwJ{--shiki-default:#179299;--shiki-default-font-style:inherit;--shiki-dark:#C792EA;--shiki-dark-font-style:italic}html pre.shiki code .sNstc, html code.shiki .sNstc{--shiki-default:#1E66F5;--shiki-default-font-style:italic;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic}html pre.shiki code .sqxXB, html code.shiki .sqxXB{--shiki-default:#4C4F69;--shiki-dark:#82AAFF}html pre.shiki code .s8Irk, html code.shiki .s8Irk{--shiki-default:#DF8E1D;--shiki-default-font-style:italic;--shiki-dark:#C5E478;--shiki-dark-font-style:inherit}html pre.shiki code .sZ_Zo, html code.shiki .sZ_Zo{--shiki-default:#FE640B;--shiki-dark:#F78C6C}",{"title":134,"searchDepth":148,"depth":148,"links":3262},[3263,3267,3268,3275],{"id":1721,"depth":148,"text":1722,"children":3264},[3265,3266],{"id":1732,"depth":154,"text":1733},{"id":1762,"depth":154,"text":1763},{"id":1812,"depth":148,"text":1813},{"id":1830,"depth":148,"text":1833,"children":3269},[3270,3271,3272,3273,3274],{"id":314,"depth":154,"text":1867},{"id":1985,"depth":154,"text":1986},{"id":2726,"depth":154,"text":2729},{"id":2741,"depth":154,"text":2742},{"id":3079,"depth":154,"text":3080},{"id":1774,"depth":148,"text":3206},"2025-08-18","We propose D2Snap – a first-of-its-kind downsampling algorithm for DOMs. D2Snap can be used as a pre-processing technique for DOM snapshots to optimise web agency context quality and token costs.",{"homepage":1656,"relatedLinks":3279},[3280,3284,3287],{"text":3281,"href":3282,"description":3283},"What is a Website Snapshot?","/blog/snapshots-provide-llms-with-website-state","Learn what a website snapshot is and how to utilise it for web agents",{"text":3285,"href":2756,"description":3286},"What is a Web Agent?","Learn the basics of web agents",{"text":47,"href":3288,"external":1656,"description":3289},"https://dev.webfuse.com/automation-api#take_dom_snapshot","Check out the Webfuse Automation API","/blog/dom-downsampling-for-llm-based-web-agents",{"title":1686,"description":3277},{"loc":3290},"blog/1012.dom-downsampling-for-llm-based-web-agents",[1676,1680,3295,3296,1678,1679],"llms","llm-context","bGJtg_9k7O95O2CJswaRFj4ONGhX4hGr_8aL5dhDZms",{"id":3299,"title":1613,"authorId":1687,"body":3300,"category":1676,"created":4019,"description":4020,"extension":1641,"faqs":1653,"featurePriority":148,"head":1653,"landingPath":1653,"meta":4021,"navigation":1656,"ogImage":1653,"path":2756,"robots":1653,"schemaOrg":1653,"seo":4030,"sitemap":4031,"stem":4032,"tags":4033,"__hash__":4034},"blog/blog/1011.a-gentle-introduction-to-ai-agents-for-the-web.md",{"type":8,"value":3301,"toc":4000},[3302,3316,3319,3326,3332,3336,3339,3354,3358,3368,3372,3376,3389,3393,3397,3400,3405,3409,3418,3422,3433,3438,3442,3460,3464,3470,3568,3571,3800,3816,3820,3823,3828,3832,3835,3839,3857,3882,3889,3893,3931,3934,3945,3949,3952,3980,3984,3992,3997],[11,3303,3304,3305,1703,3309,1880,3312,3315],{},"In no time, AI became a natural part of modern web interfaces. AI agents for the web enjoy a recent hype, sparked by the means of ",[15,3306,1702],{"href":3307,"rel":3308},"https://openai.com/index/introducing-operator/",[24],[15,3310,1708],{"href":1706,"rel":3311},[24],[15,3313,1713],{"href":1711,"rel":3314},[24],". By now, it is within reach to automate arbitrary web-based tasks, such as booking the cheapest flight from Berlin to Amsterdam.",[104,3317,3285],{"id":3318},"what-is-a-web-agent",[11,3320,3321,3322,3325],{},"For starters, let us break down the term ",[51,3323,3324],{},"web AI agent",": An agent is an entity that autonomously acts on behalf of another entity. An artificially intelligent agent is an application that acts on behalf of a human. In contrast to non-AI computer agents, it solves complex tasks with at least human-grade effectiveness and efficiency. For a human-centric web, web agents have deliberately been designed to browse the web in a human fashion – through UIs rather than APIs.",[225,3327],{":width":3328,"alt":3329,"format":3330,"loading":228,"src":3331},"610","High-level agent description comparing human and computer agents","svg","/blog/a-gentle-introduction-to-ai-agents-for-the-web/1.svg",[327,3333,3335],{"id":3334},"the-role-of-frontier-llms","The Role of Frontier LLMs",[11,3337,3338],{},"Web agents have been a vague desire for a long time. AI agents used to rely on complete models of a problem domain in order to allow (heuristic) search through problem states. Such models would comprise the problem world (e.g., a chessboard), actors (pawns, rooks, etc.), possible actions per actor (rook moves straight), and constraints (i.a., max one piece per field). A heterogeneous space of web application UIs describes the problem domain of a web agent: how to understand a web page, and how to interact with it to solve the declared task?",[11,3340,3341,3342,3349,3350,3353],{},"Frontier LLMs disrupted the AI agent world: explicit problem domain models beyond feasibility can now be replaced by an LLM. The LLM thereby acts as an instantaneous domain model backend that can be consulted with twofold context: serialised problem state, such as a chess position code (",[1742,3343,3344,3345,3348],{},"“",[139,3346,3347],{},"..."," e4 e5 2. Nc3 f5”","), and the respective task (",[1742,3351,3352],{},"“What is the best move for white?”","). For web agents, problem state corresponds to the currently browsed web application's runtime state, for instance, a screenshot.",[327,3355,3357],{"id":3356},"generalist-web-agents","Generalist Web Agents",[11,3359,3360,3361,1880,3364,3367],{},"Generalist web agents are supposed to solve arbitrary tasks through a web browser. Web-based tasks can be as diverse as ",[1742,3362,3363],{},"“Find a picture of a cat.”",[1742,3365,3366],{},"“Book the cheapest flight from Berlin to Amsterdam tomorrow afternoon (business class, window seat).”"," In reality, generalist agents still fail uncommon or too precise tasks. While they have been critically acclaimed, they mainly act as early proofs-of-concept. Tasks that are indeed solvable with a generalist agent promise great results with an according specialist agent.",[225,3369],{":width":1692,"alt":3370,"format":1694,"loading":228,"src":3371},"Screenshot of a generalist web agent UI (Director)","/blog/a-gentle-introduction-to-ai-agents-for-the-web/2.png",[327,3373,3375],{"id":3374},"specialist-web-agents","Specialist Web Agents",[11,3377,3378,3379,3382,3383,3388],{},"Other than generalist agents, specialist web agents are constrained to a certain task and application domain. Specialist agents bear the major share of commercial value. Most prominently, modal chat agents that provide users with on-page help. Picture a little floating widget that can be chatted to via text or voice input. In most cases, in fact, the term ",[1742,3380,3381],{},"web (AI) agent"," refers to chat agents. Chat agents – text or voice – can be implemented on top of virtually any existing website. Frontier LLMs provide a lot of commonsense out-of-the-box. A ",[15,3384,3387],{"href":3385,"rel":3386},"https://docs.claude.com/en/docs/build-with-claude/prompt-engineering/system-prompts",[24],"system prompt"," can, moreover, be leveraged to drive specialist agent quality for the respective problem domain.",[225,3390],{":width":1692,"alt":3391,"format":1694,"loading":228,"src":3392},"Screenshots of two modal specialist web agent UIs augmenting an underlying website's UI","/blog/a-gentle-introduction-to-ai-agents-for-the-web/3.png",[104,3394,3396],{"id":3395},"how-does-a-web-agent-work","How Does a Web Agent Work?",[11,3398,3399],{},"LLM-based web agents are premised on a more or less uniform architecture. The agent application embodies a mediator between a web browser (environment), and the LLM backend (model).",[225,3401],{":width":3402,"alt":3403,"format":3330,"loading":228,"src":3404},"480","High-level web agent architecture component view","/blog/a-gentle-introduction-to-ai-agents-for-the-web/4.svg",[327,3406,3408],{"id":3407},"the-agent-lifecycle","The Agent Lifecycle",[11,3410,3411,3412,3417],{},"To reduce a user's cognitive load, solving a web-based task is usually chunked into a sequence of UI states. Consider looking for rental apartments on ",[15,3413,3416],{"href":3414,"rel":3415},"https://www.redfin.com",[24],"redfin.com",": In the first step, you specify a location. Only subsequently are you provided with a grid of available apartments for that location.",[225,3419],{":width":1692,"alt":3420,"format":1694,"loading":228,"src":3421},"Example of separated UI states in a rental home search application","/blog/a-gentle-introduction-to-ai-agents-for-the-web/5.png",[11,3423,3424,3425,3432],{},"Web agent logic is iterative; not least for a sequential web interaction model, but also for a conversational agent interaction model. Browsing the web, human and computer agents represent users alike. That said, Norman's well-known ",[15,3426,3429],{"href":3427,"rel":3428},"https://mitpress.mit.edu/9780262640374/the-design-of-everyday-things/",[24],[1742,3430,3431],{},"Seven Stages of Action",", which hierarchically model the human cognition cycle, transfer to the web agent lifecycle. For each UI state in a web browser (environment) and web-based task (action intention); decide where to click, type, etc. (action planning), and perform those clicks, etc. (action execution). Afterwards, perceive, interpret, and evaluate the results of those actions in the web browser (state). As long as there is a mismatch between the evaluated state and the declared goal state, repeat that cycle. Potentially prompt the user with more required information.",[225,3434],{":width":3435,"alt":3436,"format":3330,"loading":228,"src":3437},"580","Donald 'Norman's Seven Stages of Action' model of the human cognition cycle that transfers to non-human agents","/blog/a-gentle-introduction-to-ai-agents-for-the-web/6.svg",[327,3439,3441],{"id":3440},"web-context-for-llms","Web Context for LLMs",[11,3443,3444,3445,3447,3448,3451,3452,3455,3456,3459],{},"The gap from an agent towards the environment, according to ",[1742,3446,3431],{},", is known as the ",[1742,3449,3450],{},"gulf of execution",". In real-world scenarios, how to act in the environment in respect to a planned sequence of actions might be difficult (e.g., how to actually open the trunk of a new car?). Arguably, web agents face a novel ",[1742,3453,3454],{},"gulf of intention"," towards the action planning stage: how to serialise a currently browsed web page's runtime state for LLMs? ",[1742,3457,3458],{},"Snapshot"," is a more comprehensive term to describe the serialisation of a web page's current runtime state. Screenshots, for instance, represent a type of snapshot that closely resembles how humans perceive a web page at a given point in time. But are they as accessible to LLMs?",[327,3461,3463],{"id":3462},"agentic-ui-interaction","Agentic UI Interaction",[11,3465,3466,3467,3469],{},"With a qualified set of well-defined actuation methods, web agents are able to close the ",[1742,3468,3450],{}," quite well. HTML element types strongly afford a certain action (e.g., click a button, type to a field). Below is how an actuation schema to present the LLM backend with could look like:",[129,3471,3473],{"className":2773,"code":3472,"language":2775,"meta":134,"style":134},"interface ActuationSchema = {\n    thought: string;\n    action: \"click\"\n        | \"scroll\"\n        | \"type\";\n    cssSelector: string;\n    data?: string;\n}[];\n",[136,3474,3475,3488,3499,3513,3525,3537,3548,3559],{"__ignoreMap":134},[139,3476,3477,3480,3483,3486],{"class":141,"line":142},[139,3478,3479],{"class":900},"interface",[139,3481,3482],{"class":1081}," ActuationSchema",[139,3484,3485],{"class":449}," = ",[139,3487,464],{"class":463},[139,3489,3490,3493,3495,3497],{"class":141,"line":148},[139,3491,3492],{"class":449},"    thought",[139,3494,473],{"class":1048},[139,3496,1052],{"class":1051},[139,3498,739],{"class":463},[139,3500,3501,3504,3506,3508,3511],{"class":141,"line":154},[139,3502,3503],{"class":449},"    action",[139,3505,473],{"class":1048},[139,3507,487],{"class":486},[139,3509,937],{"class":3510},"sgAC-",[139,3512,1484],{"class":486},[139,3514,3515,3518,3520,3523],{"class":141,"line":160},[139,3516,3517],{"class":1048},"        |",[139,3519,487],{"class":486},[139,3521,3522],{"class":3510},"scroll",[139,3524,1484],{"class":486},[139,3526,3527,3529,3531,3533,3535],{"class":141,"line":198},[139,3528,3517],{"class":1048},[139,3530,487],{"class":486},[139,3532,2782],{"class":3510},[139,3534,494],{"class":486},[139,3536,739],{"class":463},[139,3538,3539,3542,3544,3546],{"class":141,"line":204},[139,3540,3541],{"class":449},"    cssSelector",[139,3543,473],{"class":1048},[139,3545,1052],{"class":1051},[139,3547,739],{"class":463},[139,3549,3550,3553,3555,3557],{"class":141,"line":572},[139,3551,3552],{"class":449},"    data",[139,3554,2822],{"class":1048},[139,3556,1052],{"class":1051},[139,3558,739],{"class":463},[139,3560,3561,3563,3566],{"class":141,"line":578},[139,3562,552],{"class":463},[139,3564,3565],{"class":449},"[]",[139,3567,739],{"class":463},[11,3569,3570],{},"And a suggested actions response could, in turn, look as follows:",[129,3572,3574],{"className":1401,"code":3573,"language":1403,"meta":134,"style":134},"[\n    {\n        \"thought\": \"Scroll newsletter cta into view\",\n        \"action\": \"scroll\",\n        \"cssSelector\": \"section#newsletter\"\n    },\n    {\n        \"thought\": \"Type email address to newsletter cta\",\n        \"action\": \"type\",\n        \"cssSelector\": \"section#newsletter > input\",\n        \"data\": \"user@example.org\"\n    },\n    {\n        \"thought\": \"Submit newsletter sign up\",\n        \"action\": \"click\",\n        \"cssSelector\": \"section#newsletter > button\"\n    }\n]\n",[136,3575,3576,3580,3585,3609,3628,3646,3651,3655,3674,3692,3711,3729,3733,3737,3756,3774,3791,3796],{"__ignoreMap":134},[139,3577,3578],{"class":141,"line":142},[139,3579,1418],{"class":463},[139,3581,3582],{"class":141,"line":148},[139,3583,3584],{"class":463},"    {\n",[139,3586,3587,3591,3595,3597,3599,3601,3605,3607],{"class":141,"line":154},[139,3588,3590],{"class":3589},"srFR9","        \"",[139,3592,3594],{"class":3593},"s30W1","thought",[139,3596,494],{"class":3589},[139,3598,473],{"class":463},[139,3600,487],{"class":486},[139,3602,3604],{"class":3603},"sCC8C","Scroll newsletter cta into view",[139,3606,494],{"class":486},[139,3608,497],{"class":463},[139,3610,3611,3613,3616,3618,3620,3622,3624,3626],{"class":141,"line":160},[139,3612,3590],{"class":3589},[139,3614,3615],{"class":3593},"action",[139,3617,494],{"class":3589},[139,3619,473],{"class":463},[139,3621,487],{"class":486},[139,3623,3522],{"class":3603},[139,3625,494],{"class":486},[139,3627,497],{"class":463},[139,3629,3630,3632,3635,3637,3639,3641,3644],{"class":141,"line":198},[139,3631,3590],{"class":3589},[139,3633,3634],{"class":3593},"cssSelector",[139,3636,494],{"class":3589},[139,3638,473],{"class":463},[139,3640,487],{"class":486},[139,3642,3643],{"class":3603},"section#newsletter",[139,3645,1484],{"class":486},[139,3647,3648],{"class":141,"line":204},[139,3649,3650],{"class":463},"    },\n",[139,3652,3653],{"class":141,"line":572},[139,3654,3584],{"class":463},[139,3656,3657,3659,3661,3663,3665,3667,3670,3672],{"class":141,"line":578},[139,3658,3590],{"class":3589},[139,3660,3594],{"class":3593},[139,3662,494],{"class":3589},[139,3664,473],{"class":463},[139,3666,487],{"class":486},[139,3668,3669],{"class":3603},"Type email address to newsletter cta",[139,3671,494],{"class":486},[139,3673,497],{"class":463},[139,3675,3676,3678,3680,3682,3684,3686,3688,3690],{"class":141,"line":632},[139,3677,3590],{"class":3589},[139,3679,3615],{"class":3593},[139,3681,494],{"class":3589},[139,3683,473],{"class":463},[139,3685,487],{"class":486},[139,3687,2782],{"class":3603},[139,3689,494],{"class":486},[139,3691,497],{"class":463},[139,3693,3694,3696,3698,3700,3702,3704,3707,3709],{"class":141,"line":668},[139,3695,3590],{"class":3589},[139,3697,3634],{"class":3593},[139,3699,494],{"class":3589},[139,3701,473],{"class":463},[139,3703,487],{"class":486},[139,3705,3706],{"class":3603},"section#newsletter > input",[139,3708,494],{"class":486},[139,3710,497],{"class":463},[139,3712,3713,3715,3718,3720,3722,3724,3727],{"class":141,"line":685},[139,3714,3590],{"class":3589},[139,3716,3717],{"class":3593},"data",[139,3719,494],{"class":3589},[139,3721,473],{"class":463},[139,3723,487],{"class":486},[139,3725,3726],{"class":3603},"user@example.org",[139,3728,1484],{"class":486},[139,3730,3731],{"class":141,"line":702},[139,3732,3650],{"class":463},[139,3734,3735],{"class":141,"line":732},[139,3736,3584],{"class":463},[139,3738,3739,3741,3743,3745,3747,3749,3752,3754],{"class":141,"line":2249},[139,3740,3590],{"class":3589},[139,3742,3594],{"class":3593},[139,3744,494],{"class":3589},[139,3746,473],{"class":463},[139,3748,487],{"class":486},[139,3750,3751],{"class":3603},"Submit newsletter sign up",[139,3753,494],{"class":486},[139,3755,497],{"class":463},[139,3757,3758,3760,3762,3764,3766,3768,3770,3772],{"class":141,"line":2267},[139,3759,3590],{"class":3589},[139,3761,3615],{"class":3593},[139,3763,494],{"class":3589},[139,3765,473],{"class":463},[139,3767,487],{"class":486},[139,3769,937],{"class":3603},[139,3771,494],{"class":486},[139,3773,497],{"class":463},[139,3775,3776,3778,3780,3782,3784,3786,3789],{"class":141,"line":2276},[139,3777,3590],{"class":3589},[139,3779,3634],{"class":3593},[139,3781,494],{"class":3589},[139,3783,473],{"class":463},[139,3785,487],{"class":486},[139,3787,3788],{"class":3603},"section#newsletter > button",[139,3790,1484],{"class":486},[139,3792,3793],{"class":141,"line":2282},[139,3794,3795],{"class":463},"    }\n",[139,3797,3798],{"class":141,"line":2288},[139,3799,1489],{"class":463},[418,3801,3802],{},[11,3803,3804,3809,3810,3815],{},[15,3805,3808],{"href":3806,"rel":3807},"https://platform.openai.com/docs/guides/function-calling",[24],"Function Calling"," and the ",[15,3811,3814],{"href":3812,"rel":3813},"https://modelcontextprotocol.io",[24],"Model Context Protocol"," represent two ends to outsource an explicit actuation model – server- and client-side, respectively.",[327,3817,3819],{"id":3818},"agentic-ui-augmentation","Agentic UI Augmentation",[11,3821,3822],{},"An agent represents yet another feature to integrate with an application and its UI. Discoverability and availability, however, are among the most fundamental requirements of a web agent. Evidently, when a user experiences UI/UX friction, at least the agent should be interactive. That said, a scrolling modal web agent UI has been the go-to approach, that is, a little floating widget on top of the underlying application's UI. It comes with a major advantage: the agent application can be decoupled from the underlying, self-contained application.",[225,3824],{":width":3825,"alt":3826,"format":3330,"loading":228,"src":3827},"360","Depiction of a web agent application augmenting an underlying application in an isolated layer","/blog/a-gentle-introduction-to-ai-agents-for-the-web/7.svg",[104,3829,3831],{"id":3830},"how-to-build-a-web-agent","How to Build a Web Agent?",[11,3833,3834],{},"Believe it or not: enhancing an existing web application with a purposeful agent is a lower-hanging fruit. The evolving agent ecosystem provides you with a spectrum of solutions: instantly use a pre-compiled agent, tweak a templated agent, or develop an agent from scratch. Either way, LLMs and web browsers exist for reuse, boiling down agent development to LLM context engineering, and UI augmentation.",[327,3836,3838],{"id":3837},"develop-a-web-agent","Develop a Web Agent",[11,3840,3841,3842,3845,3846,1880,3851,3856],{},"Opting for a ",[51,3843,3844],{},"pre-compiled agent"," does not necessarily involve any actual development step. Instead, pre-compiled agents allow for high-level configuration through an agent-as-a-service provider's interface. Popular agent-as-a-service providers are, i.a., ",[15,3847,3850],{"href":3848,"rel":3849},"https://elevenlabs.io/conversational-ai",[24],"ElevenLabs",[15,3852,3855],{"href":3853,"rel":3854},"https://www.intercom.com/drlp/ai-agent",[24],"Intercom",". Serviced agents hide LLM communication and potentially interaction with a web browser behind the configuration interface.",[11,3858,3859,3860,3863,3864,3869,3870,3875,3876,3881],{},"Using a ",[51,3861,3862],{},"templated agent"," resembles the agent-as-a-service approach on a lower level. Openly sourced from a ",[15,3865,3868],{"href":3866,"rel":3867},"https://github.com/webfuse-com/agent-extension-blueprint",[24],"code repository",", templated agents allow for any kind of development tweaks. Favourably, agent templates shortcut integration with ",[15,3871,3874],{"href":3872,"rel":3873},"https://openai.com/api/",[24],"LLM APIs"," and web ",[15,3877,3880],{"href":3878,"rel":3879},"https://developer.mozilla.org/en-US/docs/Web/API",[24],"browser APIs",". Using a templated agent usually represents the preferable, best-of-both-worlds approach; common- and best-practice code snippets are available from the beginning, but everything can be customised as desired.",[11,3883,3884,3885,3888],{},"Of course, developing an ",[51,3886,3887],{},"agent from scratch"," is always an option. It is preferable whenever agent requirements deviate to a large extent from what exists in the service or template landscape.",[327,3890,3892],{"id":3891},"deploy-a-web-agent","Deploy a Web Agent",[11,3894,3895,3896,87,3901,3906,3907,3912,3913,3918,3919,3924,3925,3930],{},"When web agent code lives side-by-side with the augmented application's code, agent deployment is covered by a generic pipeline. Something like: ",[15,3897,3900],{"href":3898,"rel":3899},"https://eslint.org",[24],"linting",[15,3902,3905],{"href":3903,"rel":3904},"https://prettier.io",[24],"formatting"," agent code, ",[15,3908,3911],{"href":3909,"rel":3910},"https://esbuild.github.io",[24],"transpiling and bundling"," agent modules, ",[15,3914,3917],{"href":3915,"rel":3916},"https://www.cypress.io",[24],"testing"," agent, ",[15,3920,3923],{"href":3921,"rel":3922},"https://pages.cloudflare.com",[24],"hosting"," agent bundle, and ",[15,3926,3929],{"href":3927,"rel":3928},"https://docs.github.com/en/actions/get-started/continuous-integration",[24],"tiggering"," post deployment events. In that case, an agent represents a modular feature component in the application, no different than, for instance, a sign-up component.",[11,3932,3933],{},"Web agent source code right inside the application codebase comes at a cost:",[31,3935,3936,3939,3942],{},[34,3937,3938],{},"Agent developers can manipulate the source code of the underlying application.",[34,3940,3941],{},"Agent functionality could introduce side effects on the underlying application.",[34,3943,3944],{},"Agent changes require deployment of the entire application.",[327,3946,3948],{"id":3947},"best-practices-of-agentic-ux","Best Practices of Agentic UX",[11,3950,3951],{},"When designing user experiences for agent-enhanced applications, there are a few things to consider:",[31,3953,3954,3955,3954,3964,3954,3972],{},"\n    ",[34,3956,3957,3958,3957,3961,3963],{},"\n        ",[51,3959,3960],{},"Stream input and output to reduce latency",[3185,3962],{},"\n        LLMs (re-)introduce noticeable communication round-trip time. To reduce wait time for the human user, stream chunks of data whenever they are available.\n    ",[34,3965,3957,3966,3957,3969,3971],{},[51,3967,3968],{},"Provide fine-grained feedback to bridge high-latency",[3185,3970],{},"\n        Human attention is sensitive to several seconds of [system response time](https://www.nngroup.com/articles/response-times-3-important-limits/). Periodically provide agent _thoughts_ as feedback to perceptibly break down round-trip time.\n    ",[34,3973,3957,3974,3957,3977,3979],{},[51,3975,3976],{},"Always prompt the human user for consent to perform critical actions",[3185,3978],{},"\n        Some actions in a web application lead to irreversible or significant changes of state. Never have the agent perform such actions on behalf of the user without explicitly asking for the permission.\n    ",[327,3981,3983],{"id":3982},"non-invasive-web-agents-with-webfuse","Non-Invasive Web Agents with Webfuse",[11,3985,3986,3991],{},[15,3987,3989],{"href":3002,"rel":3988},[24],[51,3990,3004],{}," is a configurable web proxy that lets you augment any web application. As pictured, web agents represent highly self-contained applications. Moreover, web agents and underlying applications communicate at runtime in the client. This does, in fact, render opportunities to bridge the above-mentioned drawbacks with Webfuse: Develop web agents with a sandbox extension methodology, and deploy them through the low-latency proxy layer. On demand, seamlessly serve users with your agent-enhanced website. Benefit from information hiding, safe code, and fewer deployments.",[1615,3993],{":demoAction":3994,"heading":3995,"subtitle":3996},"{\"text\":\"Read more\",\"showIcon\":false,\"href\":\"https://www.webfuse.com/blog/category/ai-agents\"}","Deploy Web Agents with Webfuse","Develop or deploy web agents in minutes; serve agent-enhanced websites through an isolated application layer.",[1620,3998,3999],{},"html pre.shiki code .s76yb, html code.shiki .s76yb{--shiki-default:#8839EF;--shiki-dark:#C792EA}html pre.shiki code .sXbZB, html code.shiki .sXbZB{--shiki-default:#DF8E1D;--shiki-default-font-style:italic;--shiki-dark:#D6DEEB;--shiki-dark-font-style:inherit}html pre.shiki code .s2kId, html code.shiki .s2kId{--shiki-default:#4C4F69;--shiki-dark:#D6DEEB}html pre.shiki code .scGhl, html code.shiki .scGhl{--shiki-default:#7C7F93;--shiki-dark:#D6DEEB}html pre.shiki code .s9rnR, html code.shiki .s9rnR{--shiki-default:#179299;--shiki-dark:#7FDBCA}html pre.shiki code .scrte, html code.shiki .scrte{--shiki-default:#8839EF;--shiki-dark:#C5E478}html pre.shiki code .sbuKk, html code.shiki .sbuKk{--shiki-default:#40A02B;--shiki-dark:#D9F5DD}html pre.shiki code .sgAC-, html code.shiki .sgAC-{--shiki-default:#40A02B;--shiki-default-font-style:italic;--shiki-dark:#ECC48D;--shiki-dark-font-style:inherit}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 .srFR9, html code.shiki .srFR9{--shiki-default:#7C7F93;--shiki-dark:#7FDBCA}html pre.shiki code .s30W1, html code.shiki .s30W1{--shiki-default:#1E66F5;--shiki-dark:#7FDBCA}html pre.shiki code .sCC8C, html code.shiki .sCC8C{--shiki-default:#40A02B;--shiki-dark:#C789D6}",{"title":134,"searchDepth":148,"depth":148,"links":4001},[4002,4007,4013],{"id":3318,"depth":148,"text":3285,"children":4003},[4004,4005,4006],{"id":3334,"depth":154,"text":3335},{"id":3356,"depth":154,"text":3357},{"id":3374,"depth":154,"text":3375},{"id":3395,"depth":148,"text":3396,"children":4008},[4009,4010,4011,4012],{"id":3407,"depth":154,"text":3408},{"id":3440,"depth":154,"text":3441},{"id":3462,"depth":154,"text":3463},{"id":3818,"depth":154,"text":3819},{"id":3830,"depth":148,"text":3831,"children":4014},[4015,4016,4017,4018],{"id":3837,"depth":154,"text":3838},{"id":3891,"depth":154,"text":3892},{"id":3947,"depth":154,"text":3948},{"id":3982,"depth":154,"text":3983},"2025-06-15","LLMs only recently enabled serviceable web agents: autonomous systems that browse web on behalf of a human. Get started with fundamental methodology, key design challenges, and technological opportunities.",{"homepage":1656,"relatedLinks":4022},[4023,4024,4028],{"text":3281,"href":3282,"description":3283},{"text":4025,"href":4026,"description":4027},"Develop an AI Agent for Any Website with Webfuse","/blog/develop-an-ai-agent-for-any-website-with-webfuse","Learn how to develop and deploy a web agent for any website with Webfuse",{"text":47,"href":4029,"external":1656,"description":3289},"https://dev.webfuse.com/automation-api/",{"title":1613,"description":4020},{"loc":2756},"blog/1011.a-gentle-introduction-to-ai-agents-for-the-web",[1676,1680,3295,1678,1679],"Ky-gggxmZkldeN3wb7OvPpBxNaP72MwefaxFypvbUzY",1777376332566]