Computer-Use and Browser Agents › What the agent sees
Language AI HandbookAll chapters An observation is the subset of interface data that reaches the policy. The underlying environment usually has state the policy cannot see, such as whether a prior request committed on the server, which process owns a dialog, or how long a disabled control will remain unavailable. The wrapper can expose some of that state if the application knows it. Treat missing information as a limit of the observation when choosing the next action.
Pixels. A screenshot contains the geometry and styling that were captured. It can reveal controls drawn on canvas and changes such as an overlay, a moved window or an obscured button. Small fonts, cropping and resizing can remove text or position information. Screenshots can also include personal information outside the task. Crop only where the retained frame still contains the labels and visual context needed to distinguish permitted controls.
DOM and accessibility information. The DOM describes nodes and attributes. A browser accessibility tree exposes a semantic projection for assistive technology, including applicable roles, names and states. Presentation nodes can be omitted, and an accessible name may come from an associated label or a page-specified attribute. See the W3C’s Accessible Name and Description Computation. Absence from the tree does not prove absence on screen. The tree need not say which overlay covers a coordinate or whether the server will accept a change.
A combined observation. Attach structured names and roles to temporary element references and include relevant visual context when layout matters. WebArena describes screenshot, HTML and accessibility-tree representations for its web environment. OSWorld presents screenshots and accessibility information for desktop tasks. Their findings apply to the particular environments and enabled interfaces they evaluate. An application still needs to decide what kind of observation supports its own task.
Three invented counts show the budgeting question. Assume a 1,024-by-768 image is represented by one context unit per 16-by-16 uniform patch, with no extra units and no padding because both dimensions divide by 16. That gives 64 times 48, or 3,072 units. The two text counts are assumed values of 12,000 for a DOM serialization and 320 for a pruned tree. They are comparisons under one hypothetical accounting scheme. An actual tokenizer or vision processor can use different patching, resizing and overhead policies.
PythonIn [3]Expand
SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT = 1024, 768
PATCH_WIDTH = 16
patches = (SCREENSHOT_WIDTH // PATCH_WIDTH) * (SCREENSHOT_HEIGHT // PATCH_WIDTH)
CHANNELS = ("Screenshot", "Full DOM", "Pruned tree")
UNIT_BUDGET = (patches, 12_000, 320)VisualizationOut [4]Expand

For a real run, record the width and height sent, any crops, the model and the actual usage of each input channel. If vision and text have different billing or context semantics, report them separately. Measure the outcome effect of dropping context as well. A shorter tree has no value if pruning removed the parent label needed to locate the right control.
Observation shape and memory
Longer tasks need a record of prior attempts. Keep the current observation, last accepted or rejected action, and any verified state changes needed for the task. Older observations can help diagnose a loop, but their element IDs cannot stand in for references minted by the current observation. Summaries should preserve uncertainty, such as “the request timed out, final state unknown,” so the next step does not mistake a guessed outcome for a confirmed change.
When reducing an observation, keep labels that distinguish similar controls. Two rows can contain identically named buttons. Dropping one row as a duplicate because the button name repeats discards identity you need for grounding. Include a row key, region name or neighboring label. A consistent record ID is more useful for checking a successful state change than an index that merely locates a position in last turn’s list.
Coordinates, viewport, and mapping
Coordinates only have meaning when their frame is known. Assume a screenshot covers the whole viewport, both origins are at the top left, and the image was resized without cropping or padding. A point at in a 1,024-by-768 model image maps to in a 1,280-by-960 viewport. The horizontal scale is , and the vertical scale is . Multiply each coordinate by its own scale. A resized crop additionally needs its offset. Device-pixel and CSS-pixel units need the correct conversion for the browser integration.
Validate the original range, then check the transformed point against the current view. Clamping an invalid proposal to an edge can turn it into an unintended click. A point in a bounding box can also hit a covering element. You can use a fresh hit test or a supported element action, then observe the resulting state. The visible text and the structured name are pieces of evidence. Neither gives a page control authority to perform a write.
Decide which view is authoritative for an action
The same application may supply a DOM representation, a visible raster and a typed record query. They have different failure modes. A DOM node can exist without being a hit target. A visually active-looking control can be disabled in the application. A typed query can identify the record but tell you nothing about which window has keyboard focus. Start from the operation and choose the source needed to support each check.
For a read-only task, visible text can sometimes answer the user’s question directly. For example, a dashboard card can show that a task is completed. That card may belong to a filtered list or a cached page. A trusted record query with the right identity is a stronger postcondition when available. The view is still useful for interpreting the task and for explaining why a proposed control was selected.
On an archive task, the question before acting is whether the intended control and target are current and authorized. Afterward, the question is whether the task now has archived status. A screenshot before the click can support the first condition and say nothing about the second. A successful execution report is evidence that the interaction was accepted. The application’s result is the evidence that the desired state changed.
| Observation source | What can be useful | What still needs to be checked |
|---|---|---|
| Screenshot or crop | Position, occlusion, visible text and layout | Capture time, coordinates, accessibility semantics and identity |
| Structured view | Roles, names, flags, parent regions and local references | Current view membership, visible hit target and applicable grants |
| Trusted application state | Record identity and verified fields | Access scope, source freshness and completeness for the desired outcome |
An interface rendered in a child frame or another app window adds a coordinate and authority boundary. Record which view produced a candidate. An element number without page, frame or session context is only a number. If a proposal was formed in one view and another brought a modal forward before execution, the runtime needs a way to reject the old target or refresh the view. In a multi-tab workflow, attach view identity even when the two tabs show similar titles.
Ground a relative coordinate explicitly
A crop discards part of the parent frame. Its coordinates can still be converted if the crop rectangle and resized image dimensions are known. Let be the point in the resized image, the image dimensions, the width and height the crop covered in its parent frame, and its top-left offset in the same parent units. The parent point is
where:
- is the candidate point in parent coordinates.
- is the proposal in resized-image coordinates.
- is the crop origin in the parent frame.
- are positive widths and heights.
The calculation assumes an axis-aligned crop with no padding and a known common origin convention. It does not support rotations or letterboxing. For a browser implementation, the parent coordinate could be a viewport coordinate or a device pixel. Record which one it is rather than relying on both numbers looking similar.
PythonIn [5]Expand
from math import isfinite
def map_crop_point(point, image_size, crop):
x_i, y_i = point
w_i, h_i = image_size
x_0, y_0, w_c, h_c = crop
if not all(isfinite(v) for v in (x_i, y_i, x_0, y_0, w_i, h_i, w_c, h_c)):
raise ValueError("Point, crop origin and dimensions must be finite")
if min(w_i, h_i, w_c, h_c) <= 0:
raise ValueError("All input and crop dimensions must be positive")
if not (0 <= x_i < w_i and 0 <= y_i < h_i):
raise ValueError("Point is outside the image")
parent = (x_0 + (x_i / w_i) * w_c, y_0 + (y_i / h_i) * h_c)
if not all(isfinite(v) for v in parent):
raise ValueError("Mapped point must be finite")
return parent
def rejected_point():
try:
map_crop_point((320, 10), (320, 180), (100, 80, 640, 360))
except ValueError as error:
return str(error)
raise AssertionError("An out-of-bounds point was accepted")ConsoleOut [6]Expand
(420.0, 260.0) Point is outside the image
The crop center maps to in the parent frame. The second point lies exactly at the excluded right edge of a half-open image domain. The code rejects it. It also rejects nonfinite inputs or a nonfinite result. In an integration, this geometric test is a prerequisite to checking the current hit target. It is not an authorization check and it makes no claim that the mapped point is actionable.
Evaluate observation choices separately from the policy
An implementation decision such as “provide only tree data” changes what information the model can use. To understand that effect, compare the same fixed policy and tasks under different representations. Retain the labels, page versions and available actions. If one variant prunes a needed label and the other includes it, the failure can be attributed more narrowly than when the model, browser and action surface all change together.
Define an expected target for a small set of states. Include pairs of controls with neighboring labels, a disabled button, a non-actionable container, a control behind a modal and a context that needs a safe clarification. If a policy abstains, score it separately or as correct only where abstention is the intended response. Reporting overall match rate without the abstention rule can hide a policy that refuses every challenging example.
Two comparable representations may need different budgets. The pruned tree is likely cheaper for a short task list when the record names and roles are available. A visually positioned canvas task may require pixels. This is why the relevant outcome is cost at an acceptable task and safety rate, rather than the number of context units taken by each representation in isolation. Record capture, preprocessing, model response, validation and UI outcome as separate timing components.
Past views can remain useful after their action references expire. In a viewer-facing log, keep a compact description of the proposal, the validation reason and any verified change. An observation snapshot with personally identifying information should have access and retention rules, even when it was captured for debugging. A separate summary of timing and outcome counts can often support aggregate evaluation without retaining complete screenshots.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!