Compiled Viewport Perception: Reading Rendered Signals Instead of Raw DOM Dumps
This project didn't start with a grand AI-agent blueprint. It started with laziness. Originally, I was just trying to run a content channel, which meant pulling public data reliably every week. Naturally I wrote scraper
This project didn't start with a grand AI-agent blueprint. It started with laziness.
Originally, I was just trying to run a content channel, which meant pulling public data reliably every week. Naturally I wrote scrapers β and immediately got dragged into a maintenance war of attrition that a solo developer can't afford. Tired of poking backend endpoints, I swung to pure vision: YOLO. I spent three full days, morning to night, hand-drawing boxes for scroll cues and clipped regions. The first time the model ran, reality hit immediately: even the exact same person jitters and shifts box boundaries from Tuesday to Thursday.
After falling down a weak-supervision rabbit hole (morphology, OCR completion, even training a GNN to score box quality), I came back to the DOM as a "strict teacher." Three days of manual labeling compressed into three hours, and those boxes stopped acting like training data and started acting as live signals (complete β read; clipped β scroll). By the time I had adapted six sites β each dragging around ~200KB of JSON configs β I stopped. As long as you're still writing per-site configs, you're still just maintaining a scraper in disguise.
The real turning point started when I decided to build a desktop assistant that could read arbitrary webpages. The hardest question was obvious: how do you onboard any brand-new site with zero configs and let perception run on its own? Throw raw screenshots at a VLM? Small controls get misread, pixel coordinates drift on resize and zoom, and it costs a fortune. Even hybrid Set-of-Mark (SoM) approaches that stamp numbered tags onto screenshots still tag occluded buttons behind modals whenever the tagger pulls from unverified DOM geometry β while still paying vision token overhead on every frame.
To answer that question, I forced myself back to square one: what actually is a webpage?
The more I thought about it, the more it felt like a fragmented magazine whose ultimate goal is helping a human find and use information. No matter what frontend framework is underneath or how many layers of code are nested inside, the entire web stack serves one final consumer: human vision.
So when a non-human consumer (like an AI agent) shows up, how should it use a system engineered specifically for human eyes?
Traditional scrapers sneak in through the back door β consuming hidden APIs or raw internal structures β which is why every new site means starting over and every redesign breaks everything. Flip that around, though: visual presentation is actually the common convergence point where all those site differences collapse. Looking back at my very first YOLO labeling rules, I realized they had all been serving one thing all along β my own visual intuition for how a human actually looks at a page.
Strip away textures and colors from any webpage, and only two things remain: geometry and semantics. Geometry gives you position, boundaries, and belonging; minimal semantics (like aria / role or table-header associations) distinguish what a number or control means (a like count vs. a comment count vs. a price). Put those two together, and any webpage collapses into three remarkably simple concepts β easy to picture on any feed or list page:
- Geometric navigation: Humans don't see a 100,000-word DOM tree. We see bounded geometric clusters β which elements belong to the same card, and where you can click β forming a live 2D navigation map of the current screen.
- Clipping and exploration: As you scroll down, old items leave the viewport and new ones enter, leaving elements sliced right across the screen edge. Cut off at the bottom is an exploration signal meaning "there's more below"; the same goes for top, left, and right. Overlays work the exact same way: one geometric plane sitting on top of another β resolve the upper layer before reading what's underneath.
- Exploration completion: When you keep exploring the current viewport and no new geometric structures appear, that is your legitimate signal to stop.
Put plainly, this is what your body already does on autopilot every single time you browse the web. You open a page and your eyes instinctively slice the screen into blocks β this is a product card, that's a navigation bar. You catch something cut in half at the bottom edge, so your finger naturally scrolls down. You scroll until you land on the button or fact you wanted. And the moment scrolling stops surfacing anything new, your hand stops.
You didn't "think" once during that entire sequence. Yet break that subconscious loop down, and it maps one-to-one onto those exact three rules. Humans never have to be taught this β and nobody has ever really taught it to machines.
Notice what's missing from those three rules? No colors, no textures, no frontend frameworks. All of that is noise.
You can test this right now. For the first try, let me walk you through it using the exact page you are reading:
The sticky navigation bar at the top is a geometric block holding a few controls; it sits on top of the article, covering part of the text behind it. At the bottom edge of your screen, more text is cut off mid-flow β so your finger naturally scrolls down.
All three rules fit without changing a thing. Now open any unfamiliar website in a new tab and try it a second time. If it holds up both times, then those rules aren't describing "a specific website" β they're describing what a webpage itself actually is.
Notice what just drove your own hand a second ago: you didn't scroll because anyone gave you an instruction β you scrolled because the page gave you a signal: "there's more below." Occlusion, clipping, and spatial belonging are all live signals emitted by the browser's rendered screen right now, and every reading action you take is driven by them.
For humans, those signals go straight into our eyes. For machines, though β who translates those signals faithfully?
How should a non-human system (LLM / Agent) consume these three concepts?
The answer is surprisingly straightforward: machines don't need more raw data β they need the exact same set of signals humans use, translated faithfully without distortion.
The catch is that these signals don't live in source code. Webpages are designed for the human physical viewport, not for DOM trees: what covers what, which card is sliced in half by the screen edge, and which button is actually unreachable right now are not declared in HTML β they are physical facts produced only by the browser's final render state. To read those signals, you have to read them from the rendered result, not guess them from source code.
Most mainstream approaches get this wrong right at the signal source. Feed raw DOM or accessibility trees directly, and the occlusion signal is lost (buttons buried under modals are still marked clickable), the viewport-boundary signal is lost (hundreds of offscreen rows get dumped into the context window), and the clipping signal is lost (cards cut off at the bottom masquerade as complete records). What the model receives is a distorted "fake layout": what is physically visible on screen no longer matches what gets translated to the model. In my view, that mismatch is the root cause of Web Agent action hallucinations β no matter how strong the model's reasoning is, if the world handed to it is fake, it will click dead air, miss rows, or confidently deliver a wrong answer without realizing half the page was cut off.
Here is a slightly counterintuitive conclusion I reached after extensive testing (purely my own subjective takeaway): modern models are already remarkably strong at instruction-following and honesty. What they lack isn't a smarter brain β it's an anchor to a shared layer of ground truth, a set of live signals aligned with what human eyes actually see on screen. Only by holding the line at the human-visible boundary does agent execution truly stabilize.
Once those three concepts are put into practice, what you feed the model is neither raw HTML nor a full-page screenshot, but a structured Compiled Viewport Contract β with every signal from those three primitives compiled straight into it. Below is a small slice captured from a real cross-page comparison task (looking up open-source programming languages on Wikipedia):
[Page] Rust (programming language) β Wikipedia
[Viewport] top Β· ~41 screens total
[Active Surface] 3 occluded targets removed before reasoning
[Frozen Cross-Page Evidence]
E0 "Python Designer: Guido van Rossum" @T0/f1
E3 "Python Website: python.org" @T0/f2
βΈCard[@N337 @J5:N25] β clipped
βΈCard[@N200 @J15:M16]
N199 @J15 label: First appeared
N201 @L15 title*: January 20, 2012; 14 years ago
βΈCard[@N293 @J23:L23]
N291 @J23 label: OS
N294 @L23 OS*: Cross-platform
βΈCard[@N300 @J24:N24]
N305 @J24 label: License
N306 @L24 text: MIT [clickableβ]
N307 @M24 title*: Apache 2.0 [clickableβ]
βΈCard[@N312 @J25:M25] β clipped β incomplete(bottomβ)
N315 @J25 label β cut-bottom (~10 chars): Filename
N316 @L25 text: .rs
Legend: `N = target node ID, E* = frozen cross-page evidence anchor captured from an earlier frame, @J5:N25` = coarse 2D viewport grid cell/span (columns AβS, rows 1β25).*
Looking back
Looking back, this system wasn't really "designed" from a blueprint. It was pushed into its current shape step by step by unsustainable scrapers, jittery hand-drawn YOLO boxes, DOM-versus-vision mismatches, and per-site configs that broke on every frontend redesign.
This work was never about proving how "human-like" a machine can be. The question I actually care about is much simpler: once a machine starts seeing an interface, does it know when to stop?
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.