Skip to content

fix(computer-use): dock annotations, single-resample frames, saner frame retention - #1083

Merged
edenreich merged 6 commits into
mainfrom
fix/computer-use-dock-annotations
Aug 20, 2026
Merged

edenreich merged 6 commits into
mainfrom
fix/computer-use-dock-annotations

Conversation

@edenreich

@edenreich edenreich commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Computer-use agents on macOS could not reliably click small UI like Dock icons. This PR fixes the whole grounding pipeline: frame retention, resampling, aspect-preserving coordinate mapping, OS-chrome annotation, a region zoom for native-resolution inspection, and annotation-parser robustness. Verified end to end: the agent zoomed into the Dock, identified Find My at exact coordinates, clicked it, and the app launched.

Changes

  • config/prompts.go: screen annotator prompt covers OS chrome (Dock icons, menu bar, desktop icons); GetLatestFrame description documents region zoom.
  • internal/services/screenshot_server.go: single uniform resample from the native capture (was physical -> logical -> stretched 1024x768, losing Retina detail and skewing VLM grounding).
  • config/computer_use.go: FitDims fits frames inside the target box with one scale factor (aspect preserved); default screenshot.buffer_size 5 -> 60 (frame files lived ~15s, shorter than the LLM round-trip that reads them).
  • internal/agent/tools: MouseClick/MouseMove derive their API space from FitDims so capture and click mapping cannot disagree; GetLatestFrame accepts region {x,y,width,height} in frame space - the rectangle is re-captured at native resolution, annotated, and element coordinates are translated back into frame space.
  • internal/display/resize.go: ResizeImage shared by the capture path and the zoom tool.
  • internal/vlm: annotation parser salvages the summary and well-formed elements from malformed/truncated replies; default annotator max_tokens 1024 -> 4096 (dense annotations were truncated mid-JSON).

Follow-up: accessibility-tree grounding - #998.

…ive capture

The screen annotator prompt never mentioned the macOS Dock, menu bar, or desktop icons, so annotated frames omitted them and agents could not find Dock apps to click. Frames were also downsampled twice (physical -> logical -> target), losing Retina detail exactly where Dock icons need it; resize once from the native capture instead.
At the 3s capture interval a frame file lived ~15 seconds before the ring buffer removed it - almost always shorter than the LLM round-trip between GetLatestFrame and a follow-up ImageDecode, which then failed with file-not-found. 60 frames keeps ~3 minutes on disk for a few MB.
@edenreich
edenreich marked this pull request as ready for review August 19, 2026 23:39
@edenreich
edenreich requested a review from a team as a code owner August 19, 2026 23:39
Frames were stretched into the fixed 1024x768 target box, so a 16:10 screen reached the model with a ~15% horizontal distortion. VLM coordinate grounding degrades on distorted images in ways the inverse mapping cannot undo, which showed up as systematic misclicks (Dock icons hit one slot to the left). Per the computer-use guidance, scale with a single uniform factor: FitDims fits the frame inside the target box and both the capture path and the mouse tools derive the API space from it, so the mapping stays symmetric.
Small UI such as Dock icons is unresolvable in the downscaled full frame - annotators confabulate names and coordinates. An optional region argument (frame coordinate space) re-captures just that rectangle at native resolution, annotates it, and translates element coordinates back into the standard frame space, so MouseClick keeps a single coordinate space. Crops above the annotator's image limits are downscaled uniformly; ResizeImage moves to internal/display so both the capture path and the tool share it.
…kens to 4096

Dense annotations (a 30-icon Dock) overflow 1024 tokens, truncating the JSON mid-list; the parser then dropped everything and the model received a raw fenced fragment with zero elements. The parser now recovers the summary and every element object that unmarshals on its own, and the default token budget fits real screens.
Comment thread internal/services/screenshot_server.go Resolved
@edenreich
edenreich merged commit 0074510 into main Aug 20, 2026
1 check passed
@edenreich
edenreich deleted the fix/computer-use-dock-annotations branch August 20, 2026 10:44
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.178.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant