<!-- Markdown version for AI agents and readers. Canonical: https://pratikdhanave.com/blog/posts/cua-04-grounding-in-the-ui.html -->

# Grounding in the UI — Knowing Exactly Where to Click

*A computer-use agent can perceive the screen and decide "click Submit," but it still has to answer a deceptively hard question: where exactly is Submit, and how do I act on precisely that spot? This UI grounding problem — connecting a decision to a precise screen location and element — is where many computer-use agents stumble, because a click a few pixels off hits the wrong thing. This post is about how agents locate and target UI elements reliably.*

Post 2 covered understanding the screen; post 3 covered acting and the loop. This post is the bridge between them: *grounding* — translating "click Submit" into "click at exactly these coordinates on this element." It's the computer-use analog of the coding-agent grounding problem (post 3 there), and it's a distinct, decisive challenge for GUI agents.

## The grounding problem for UIs

**UI grounding** is connecting the agent's *intent* (an action on a conceptual element — "click the Submit button") to a *precise, actionable target* (the exact location/element to act on). Perception (post 2) tells the agent *that* there's a Submit button; grounding tells it *exactly where* to click. These are distinct, and grounding is its own hard problem:

- **The agent must produce a precise target** — coordinates to click, or a specific element to act on — accurate enough that the action hits the *right* element and not a neighbor. GUIs are visually dense (elements close together), so small targeting errors hit the wrong thing.
- **Elements must be identified unambiguously** — if there are three "Delete" buttons, the agent must target the *right* one (the one for the right item), which requires understanding context, not just matching a label. Disambiguation is part of grounding.
- **The target must be *reachable*** — the element might be off-screen (needs scrolling), inside a menu (needs opening), or occluded (needs dismissing something first), so grounding sometimes requires *actions to reveal* the target before acting on it.

The consequence of bad grounding is immediate and visible: a **mis-click** — the agent acts on the wrong location/element, doing the wrong thing (clicking the wrong button, typing in the wrong field). This is one of the most common and most damaging computer-use failures, because it not only fails the intended action but can trigger *unintended* ones (clicked the wrong button → wrong action happens). Grounding reliability is therefore central to computer-use reliability, exactly as grounding (comprehension) was central for coding agents (post 3 there) — here it's grounding in the *spatial/visual* sense (where exactly), a distinctly hard targeting problem.

## How agents ground in the UI

Agents locate and target elements through approaches that parallel the perception approaches (post 2):

- **Coordinate-based (vision grounding).** The vision model, having perceived the screen, outputs *coordinates* for where to act ("click at pixel 420, 315"). This is general (works on any screen) but demands *precise spatial localization* from the model — it must not just recognize the button but pinpoint *where* it is, accurately. Spatial grounding (precise localization) is a known hard capability for vision models (it's harder than recognition — the object-detection/localization problem from the [computer vision](/blog/series/computer-vision-from-first-principles/) series), and imprecise coordinate output is a direct cause of mis-clicks. This is the universal but error-prone path.
- **Element-based (structured grounding).** When the accessibility tree or DOM is available (post 2), the agent targets a *specific element* ("click the element with this ID/role/label") rather than raw coordinates, and the system resolves it to the right place precisely. This is far *more reliable* — targeting a named element avoids pixel-level errors entirely — but requires the structured data (not always available). Where you have it, element-based grounding is much safer than coordinate guessing.
- **Set-of-marks / labeled overlays.** A powerful hybrid technique: overlay numbered/labeled markers on the detected interactive elements (from perception), and have the agent choose *which marked element* to act on ("click element 7") rather than outputting raw coordinates. This turns imprecise coordinate generation into a *selection among identified elements*, which is much more reliable — the agent picks from a list of grounded candidates instead of guessing pixels. This "set-of-marks" approach meaningfully improves grounding reliability and is widely used.

As with perception, the pattern is *prefer structured/identified targeting over raw coordinate guessing*: element-based (from accessibility/DOM) where available, set-of-marks (identified candidates) as a strong vision-based alternative, and raw coordinates as the last resort — because the more the agent *selects among identified elements* rather than *pinpoints pixels*, the fewer mis-clicks. Good grounding is largely about turning the hard "output exact coordinates" problem into the easier "pick the right identified element" problem.

## Why grounding is decisive — and how to improve it

Grounding quality strongly determines computer-use reliability, so understanding it guides both building and using these agents:

- **Mis-clicks are a top failure mode.** Many computer-use failures aren't reasoning failures (the agent knew to click Submit) but *grounding* failures (it clicked the wrong place) — exactly paralleling how coding-agent failures are often comprehension (grounding) failures (post 3 there). Improving grounding is thus high-leverage for reliability.
- **Precise localization is genuinely hard for vision.** Recognizing "there's a button" is easier than pinpointing "the button is exactly here" — localization is a harder vision capability than recognition (the CV detection problem), which is why raw-coordinate grounding is error-prone and why set-of-marks and element-based approaches (which sidestep pixel-precision) help so much. The field's grounding improvements largely come from *avoiding raw coordinate generation*.
- **Structured UIs and good design help.** Accessible UIs (with good accessibility trees) enable reliable element-based grounding, and clean, well-spaced, conventional UIs are easier to ground in (less density, less ambiguity) — again, *good UI design and accessibility make software more agent-operable* (the recurring theme from perception, post 2). Agent-friendliness is largely accessibility-and-clarity.
- **Verification catches grounding errors.** Because grounding can fail (mis-click), the agent should *verify* its action's effect (post 3's loop — look at the new screen: did the right thing happen?) and recover if it mis-clicked. Grounding reliability and the verify-and-adapt loop work together — good grounding reduces mis-clicks, and the loop catches the ones that slip through.

## Key takeaways

- **UI grounding** connects the agent's **intent** ("click the Submit button") to a **precise, actionable target** (exactly where/which element) — distinct from perception (post 2, which tells it *that* a button exists); grounding tells it *exactly where* to click, and a mis-target hits the wrong element.
- Bad grounding → **mis-clicks** (acting on the wrong location/element), one of the most common and damaging computer-use failures (it fails the intended action *and* can trigger unintended ones) — so grounding reliability is central (paralleling comprehension-grounding for coding agents, post 3 there, but here *spatial*).
- Approaches: **coordinate-based** (vision model outputs pixels — universal but error-prone, because precise **localization is harder than recognition**, the CV detection problem — a direct cause of mis-clicks), **element-based** (target a named accessibility/DOM element — far more reliable, no pixel errors, where structured data exists), and **set-of-marks** (overlay labels on detected elements, agent picks "element 7" — turns hard pixel-pinpointing into easier *selection among identified candidates*, meaningfully improving reliability).
- The pattern: **prefer identified-element selection over raw coordinate guessing** (element-based > set-of-marks > raw coordinates) — most grounding improvement comes from *avoiding pixel precision*.
- Grounding is **decisive for reliability** (many "failures" are mis-clicks, not reasoning errors), **improved by accessible/clean/conventional UIs** (good UI design + accessibility make software agent-operable — the recurring theme), and backed by the **verify-and-adapt loop** (post 3 — look at the result, recover from mis-clicks) that catches grounding errors that slip through.

## Further reading

- [Object detection — the localization problem underlying coordinate grounding](https://en.wikipedia.org/wiki/Object_detection)
- [Accessibility — the structured element data that enables reliable grounding](https://en.wikipedia.org/wiki/Computer_accessibility)

---

Author: Pratik Dhanave (https://pratikdhanave.com) | Published: 2026-09-09
Canonical: https://pratikdhanave.com/blog/posts/cua-04-grounding-in-the-ui.html
Attribution: please link the canonical URL when citing or quoting this post.
