Vision-as-a-Tool: Giving Coding Agents a Visual Diff

1 Wrap Vision as Five Tools, No Training Needed
Ask an agent to rebuild a web page from a screenshot and it has to loop: write code, render it, compare with the target, fix. Comparison is the hard part. The target wraps its text in an arc around an image; an agent relying on its own eyes misses that kind of layout difference, and often decides the result is close enough and quits early. A text-only model, which cannot see images at all, cannot run the loop in the first place.
The paper’s fix is pure engineering. It leaves the coding agent alone and trains nothing; it hands the agent a set of visual tools, all backed by one vision model, Gemini-3.8-Flash, acting as external eyes. The paper calls the idea Vision-as-a-Tool (VaaT) and the toolbox VHarness: five tools, transcribe, grep, inspect, diff and align, each with its own prompt and a strict JSON output format. The agent decides when to call which.
Four vision-capable models improve on web pages, vector graphics and 3D models, with 3D gaining the most, and a text-only model can finish the tasks too. The price: the agent runs more rounds and writes 2 to 6 times as much output.
Paper: Vision-as-a-Tool: Visual Harness for Multimodal Agentic Coding, from Peking University, Microsoft Research, University of Edinburgh and Nanjing University, 2026-11. By Haolin Yang et al. of Furu Wei’s group, arXiv version 2611.17797v1, dated 2026-11-13. There is also a project page.
2 Where the Screenshot-to-Code Loop Breaks: Comparison
2.1 The One Uncertain Step in a Four-Step Loop
Screenshot to HTML, raster image to SVG (a vector image format that describes shapes with coordinates), four photos of an object to a modeling script for Blender (open-source 3D software): three tasks on the surface, one four-step loop underneath:
- Write code: produce HTML, SVG or a Blender script from the target image.
- Render: turn the code into an image, such as a browser screenshot, a rasterized SVG or a Blender render.
- Compare: find where the render differs from the target.
- Fix: change the code to address the differences, then go back to Step 1.
Code has a programming language and rendering has deterministic tools, so both steps are predictable. Comparison is the one uncertain step: someone has to actually see where the render differs from the target, or the next round does not know what to change. Get comparison wrong and the loop just spins in place.
2.2 Multimodal Agents: Capped by Their Own Eyesight
The common approach lets the agent’s underlying multimodal large language model (MLLM, a model that reads images and text together) do the comparison itself; the paper calls this Thinking-with-Images. Fancier versions crop and zoom first, but that only gives the same eyes a bigger picture; the ceiling is still the model’s own eyesight. The other route builds a repair pipeline for one task, such as DesignRepair for web pages or Chat2SVG for SVG, which has to be rebuilt for every new task.
What goes wrong when an agent checks its own work? Row one of the paper’s Figure 2 shows it.

Look at row one only. The target wraps its text in an arc around the image; the baseline (the control: the same agent without the toolbox) misses the arrangement and stacks the text in a straight column. Seeing wrong is only half of it. Deciding whether the job is done uses the same eyes, and the paper’s Appendix C.1 notes that the baseline often misses small shifts or omissions, declares itself finished and stops early.
2.3 Text-Only Agents: Borrowed Eyes That See One Image
A text-only model cannot see, so it has to ask an outside model to look for it. Existing approaches fall into two camps, and both fail to sustain the loop for the same reason: the outside helper looks at one image at a time and never compares the target with the render.
One illustrative scenario makes this clear: the target wraps its text in an arc around an image, and the agent’s first draft stacks it in a straight column. What can each kind of external vision do?
| Fixed external modules (MM-REACT, ViperGPT, etc.) | Visual question-answering pipelines (SeeingEye, DRP, etc.) | Vision as a tool (this paper’s VaaT) | |
|---|---|---|---|
| The outside model | Specialist models: captioning, OCR, layout detection | One general multimodal model | One general multimodal model, wrapped as five fixed tools |
| What the agent gets back for the target image | “A page with an image and text” plus a few text-box coordinates; it cannot say “arc” | Ask “how is the text laid out?” and it answers “in an arc around the image” | Skeleton, positions, font and color, depending on the tool called |
| Can it compare two images? | No | No; it is designed for one static image | Yes: diff reports “the middle section is a column; the target is an arc” with positions on both sides |
| Can it sustain the loop? | No | No | Yes |
Fixed modules have the deepest problem: a specialist model only outputs what it was trained to output, and a captioning model cannot express a layout relation like “arc”. Question-answering pipelines are much smarter and can name the arc if asked the right question, but they are built to look at one static image and answer. Coding from images needs someone to say how two images differ; without comparison, Step 3 of the loop stays empty.
So multimodal or text-only, the missing piece is the same: a reliable comparer the agent can call at any time. My inference from the table above is that VaaT is not a new category so much as the existing “text-only reasoner plus external vision model” setup, extended with the two actions a coding loop needs: compare and confirm.
3 The Core Idea: Unix Commands for Vision
VHarness leaves the loop as it is and does not modify or train the coding model. It adds two layers beside it: a visual toolbox, and the external eyes that actually look at images behind each tool.
Picture one round on the arc page (an illustration; the paper includes no real trace). The agent writes a first HTML draft and a browser screenshot gives the render. It hands the target and the render to diff and gets back one line: “the middle text is a column; the target is an arc.” It fixes the code, renders again, and finally calls align to confirm the headline text is spelled right. Throughout the round, the external eyes behind the tools do the actual looking.
The paper’s own analogy is easy to hold: the coding agent is an engineer at a terminal, the toolbox is Unix commands for vision, grep to find things and diff to compare two files, and the external eyes are the programs that actually run behind those commands. The engineer does not need to know how grep is implemented, only what goes in and what comes out.
The system has five roles. This post uses plain names for them; the paper’s terms are:
| Name here | Paper’s term | What it is |
|---|---|---|
| Coder | coding agent | The model writing code inside Claude Code; multimodal or text-only |
| Renderer | rendering environment | Turns code into an image: browser screenshot, SVG rasterization, Blender render |
| Visual toolbox | VHarness, five atomic actions | transcribe, grep, inspect, align, diff |
| External eyes | external visual utilities | The model that looks at images behind the tools: Gemini-3.8-Flash |
| Own eyes | intrinsic vision | The coder’s built-in ability to see; only multimodal models have it |
Data flows like this: the coder writes code and the renderer turns it into an image. When the coder needs to look, it calls a tool; the tool sends the image and a question to the external eyes and passes a structured answer back. The tools reach the coder over MCP (Model Context Protocol, a standard way for agents to call external tools). A multimodal coder can use both kinds of eyes, keeping its own; a text-only coder sees the world only through the toolbox.
%%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#dbeafe', 'primaryBorderColor':'#3b82f6', 'primaryTextColor':'#1e3a5f', 'lineColor':'#3b82f6', 'secondaryColor':'#eff6ff', 'tertiaryColor':'#eff6ff', 'clusterBkg':'#eff6ff', 'clusterBorder':'#93c5fd', 'edgeLabelBackground':'#ffffff' }}}%%
graph TD
a["Coder: writes code"]
b["Renderer: makes the image"]
c["Visual toolbox: five tools"]
d["External eyes: Gemini-3.8-Flash"]
a -->|code| b
b -->|image| c
c -->|image + fixed prompt| d
d -->|structured JSON| a
4 Five Tools: Three to Understand, Two to Compare
The five tools map to the five questions a coder actually asks. Before writing, it needs to understand the target, from coarse to fine: what is the overall skeleton, where is a given thing, what does it look like. After rendering, it compares: where does the whole image differ, and is this one spot right. A bounding box in the table is the rectangle of coordinates around an element.
| Stage | Tool | Question it answers | Input | Output |
|---|---|---|---|---|
| Understand | transcribe | What is the overall skeleton? | Target image (four views for 3D) | JSON structure tree: blocks, reading order, side-by-side relations; no coordinates, colors or fonts. The 3D version outputs a part breakdown and materials |
| Understand | grep | Where is this thing? | One image + a text query | Every matching element: category, bounding box, text, confidence |
| Understand | inspect | What does it look like? | An image or a region + a mode (text or graphic) | Text mode: the exact text plus a one-line font spec from fixed options; graphic mode: a free description |
| Compare | diff | Where do the images differ? | Target image + render | A list of differences in one of two formats; [] when there are none |
| Compare | align | Is this one spot right? | An image or a region + the expected text | {"match": true or false}, judging meaning and wording only, ignoring font |
The output formats below come from the prompts printed in the paper’s Figure 9 and 10; the example contents are my own illustrations.
4.1 Understand the Target: transcribe, grep, inspect
transcribe gives the skeleton first. It answers only “which blocks does this page have, and how are they arranged”, and deliberately leaves out coordinates, colors and fonts. For a page with a header, a middle section (an image with wrapped text) and a footer, it returns a tree like this: layout: flow means top to bottom, and the middle layout: row means the image and the text block sit side by side.
{"layout":"flow","children":[{"block":"block_1"},
{"layout":"row","children":[{"graphic":"asset_03"},{"block":"block_2"}]},
{"block":"block_3"}]}grep finds things. Given an image and a text query, it returns every matching element with its category, bounding box, text and confidence:
[{"category":"text","bbox":[40,80,95,920],"text":"Summer Sale","confidence":0.93}]All tools share one bounding-box format: [top, left, bottom, right], scaled to 0 to 1000 instead of pixels, so coordinates mean the same thing at any image size. Converting is simple: on a page 3000 px tall, top = 40 means px from the top. The entry [40,80,95,920] above is a flat, wide headline close to the top of the page.
inspect describes appearance. It has two modes, depending on what kind of region it looks at. Two regions of the same page:
| Text mode | Graphic mode | |
|---|---|---|
| Used for | Headlines, paragraphs, button labels | Illustrations, icons, SVG shapes, 3D parts |
| Output | Summer Sale plus [type] family: sans-geometric · weight: bold · width: normal · slant: normal · text-colour: #1A1A1A | “An orange round sun with three white wavy lines across it and 12 short rays around the rim; no text.” |
| What the coder does with it | Maps it straight to CSS: bold becomes font-weight: 700, the color becomes color | Draws the shape in SVG or CSS |
Why fixed options for text but free description for graphics? The paper gives no reason. My reading: every font option maps directly to one CSS property, so the coder never has to guess whether “a bit bold” means 600 or 700, while graphics come in endless kinds and only natural language can describe them.
4.2 After Rendering: diff Finds Problems, align Locks Answers
diff answers “where do the images differ”. It takes the target and the render and returns a list of differences, or [] when there are none. It has two output formats that answer different questions; the paper does not say when to use which. The last row of the table is my guess at how a coder would use each:
| Ranked by prominence | Paired bounding boxes | |
|---|---|---|
| Answers | What is wrong, and what to fix first? | Where is this element in each image? |
| Engineering analogy | Code review comments sorted by severity | git diff’s “this chunk was at 10–20 in the old file and moved to 40–60 in the new one” |
| How the coder might use it | Decide the order of fixes | Crop both boxes and look closer with inspect before fixing |
In the ranked format, each difference has where (which region), what (what is wrong) and prominence (high, medium, low), big problems first. For the arc page:
[{"where":"中段","what":"文字排成插圖下方的直欄,目標是繞著插圖排成圓弧","prominence":"high"}]In the paired format, each entry has tag (which element), target_bbox (its position in the target) and render_bbox (its position in the render); if the render is missing the element entirely, render_bbox is null. Two boxes are needed because a misdrawn element sits in different places in the two images, and one box cannot cover both:
[{"tag":"環繞文字","target_bbox":[250,133,750,867],"render_bbox":[545,367,955,633]}][250,133,750,867]: 25% to 75% of the page height and 13.3% to 86.7% of the width, a wide ring around the image. In the render, the same text’s box is [545,367,955,633], squeezed into 54.5% to 95.5% of the height and 36.7% to 63.3% of the width, a narrow column under the image. With only one box, the coder could not crop both “what the target looks like” and “what I drew” to compare them.align answers “is this one spot right”. It returns only true or false, judging meaning and wording while ignoring font. After fixing the headline, say, the coder calls align(headline region of the render, "Summer Sale") to check. Getting false back means the text in that region is still wrong and needs another fix:
{"match": false}diff and align split the work the way you would run diff to find and prioritize problems, then use an assert to lock one point down once it is fixed.
4.3 One Run, Step by Step: No Fixed Order
There is no fixed workflow across the five tools; the coder decides what to call and when. The paper includes no step-by-step trace, so the table below is my illustration of the order described in the paper’s §2.3, again on the arc page:
| Step | Coder’s question | Call | What comes back |
|---|---|---|---|
| 1 | Roughly how many blocks does this page have? | transcribe(target) | Layout skeleton: header, middle (image + wrapped text), footer |
| 2 | Where is the headline and what does it look like? | grep → inspect | The headline’s bounding box; its text, bold sans-serif, #1A1A1A |
| 3 | Write a first draft | (write code.html → render) | render.png |
| 4 | How does it differ from the target? | diff(target, render) | Most prominent first: “middle text is a column; the target is an arc” |
| 5 | How is that region laid out in the target? | grep → inspect (on the target region) | A detailed description; then fix the code and render again |
| 6 | Is this line of text right now? | align(render region, "Summer Sale") | true or false |
| 7 | Any differences left? | diff | Stop on an empty list or when judged done; otherwise back to Step 4 |
In the table, Step 1 and 2 understand the target; Step 4 through 7 compare and confirm. The order is left open because the same tools must work for HTML, SVG and 3D, and a fixed workflow is exactly the weakness of the task-specific pipelines described earlier.
5 The Tool Is the Prompt: One Gemini, Five Specs
All five tools run on the same general model, Gemini-3.8-Flash, with no training and no specialist vision model. So what separates a “tool” from just asking the model? Each tool has its own dedicated prompt, and some have variants:
transcribehas an HTML/SVG version and a 3D version.inspecthas a text version and a graphic version.diffhas one version per output format.grepandalignhave one each.
The tools come from a resident MCP server written with FastMCP, registered under the name mcp__atomic__*. For grep:
- The coder calls
grep(./target.png, "main headline"). - The MCP server fills a fixed template: “This is a {width}x{height} px image. Find every element matching “{query}”… reply with strict JSON only.”
- The template and the image go to Gemini-3.8-Flash.
- The JSON that comes back is passed to the coder unchanged.
What turns “just asking” into a tool is five kinds of constraint in the prompt:
- Fixed output structure: strict JSON only, with fixed fields.
- Fixed vocabulary:
inspectpicks font weight from a set list running from thin to black. - Fixed order:
difflists big problems before small details. - Explicit exclusions:
transcribemay not give coordinates, colors or fonts. - Shared coordinates: every bounding box is scaled to 0 to 1000.
In engineering terms, this wraps an LLM as a typed function. The caller sees only the signature, what goes in and what structure comes back; the prompt is the implementation inside. The paper does not frame it this way; my inference is that fixed formats let the coder chain outputs directly, for example cropping with a bounding box from diff and passing the crop to inspect. How much the wrapping matters overall, the experiments isolate later with a dedicated comparison.
When does the loop stop? With or without the toolbox, there is no minimum number of rounds and no token budget; the coder stops when the result looks finished. What differs is who judges. The baseline judges with its own eyes, so it often stops early; with the toolbox, the external eyes keep checking, diff and inspect keep reporting remaining differences, and the loop goes on. The paper does not spell out the actual stop condition, for example whether it waits for diff to return an empty list. That design choice affects quality and cost at once, and it shows up again in the token analysis.
6 Results: Every Model Improves, and the Wrapping Matters
With the toolbox, all four multimodal coders improve on all three tasks, 3D the most. Part of the gain comes from an extra pair of eyes and part from wrapping vision as fixed tools; the cost is 2.0 to 6.4 times the coder’s output tokens.
6.1 Setup: 100 Tasks per Type, Two Main Metrics
Each task has 100 problems: HTML and SVG cases are high-complexity examples from public sources, and 3D cases are sampled from 3DCodeBench. Every coder runs inside Claude Code with reasoning effort set to high and a 200K context. Two metrics matter most here:
| Metric | How it is computed | What it measures |
|---|---|---|
| DINOv2 ↑ | The DINOv2 vision model turns each image into a vector, and the similarity between them is computed (0 to 1, higher is closer) | Overall visual resemblance |
| Chamfer ↓ | The average nearest-point distance between the surfaces of two 3D models (lower is closer) | How far the 3D shape is off; 3D only |
The paper also reports SigLIP2, LPIPS, SSIM, Pixel MSE, edge F1, Uni3D and others; they all point the same way as the results below.
6.2 Main Results: Every Cell Improves, the Weakest Model Most
The paper’s main results table (Table 1) lists every coder’s scores on three tasks and many metrics, with and without the toolbox. Below are only DINOv2 and Chamfer, written as “without → with”:
| Coder | HTML (DINOv2) | SVG (DINOv2) | 3D (DINOv2) | 3D (Chamfer) |
|---|---|---|---|---|
| GPT-5.5 | 0.888 → 0.905 | 0.852 → 0.879 | 0.662 → 0.750 | 0.0094 → 0.0058 |
| GPT-5.6-sol | 0.906 → 0.913 | 0.888 → 0.902 | 0.705 → 0.812 | 0.0157 → 0.0035 |
| Claude Opus 4.8 | 0.717 → 0.872 | 0.722 → 0.787 | 0.534 → 0.702 | 0.0339 → 0.0086 |
| GLM-5.3-Flash | 0.902 → 0.922 | 0.897 → 0.921 | 0.759 → 0.819 | 0.0056 → 0.0035 |
| GLM-5.2 (text-only, 50 tasks only, “with” only) | 0.895 | 0.866 | 0.662 | 0.0092 |
Table 1 — Output quality with and without VHarness on three tasks (100 tasks each), DINOv2 and Chamfer only. (Excerpt from the original paper, Table 1.)
- Every cell improves, and the 3D columns improve most. For GPT-5.6-sol, 3D DINOv2 rises from 0.705 to 0.812 and Chamfer falls from 0.0157 to 0.0035.
- The biggest gain goes to the weakest baseline. Claude Opus 4.8 is clearly behind without the toolbox (HTML at just 0.717) and climbs to 0.872 with it; the other three models gain only 0.007 to 0.020 on HTML.
- A text-only model can take part. GLM-5.2 cannot see images, so without the toolbox it cannot compete at all, which is why it has only a “with” column.
Read the GLM-5.2 row carefully: for budget reasons it ran on only 50 randomly sampled tasks, so it cannot be compared directly with the 100-task numbers above. The paper’s Table 8 compares it on the same 50 tasks with GPT-5.5 without the toolbox, on DINOv2:
| Task | GLM-5.2 + toolbox | GPT-5.5 without toolbox |
|---|---|---|
| HTML | 0.895 | 0.894 |
| SVG | 0.866 | 0.861 |
| 3D | 0.662 | 0.670 |
The three tasks come out roughly even. A model that cannot see, given the toolbox, performs close to a vision model working alone.
6.3 Freestyle Ablation: Same Eyes, Free-Form Questions
The main results hide a confound: the toolbox brings two things at once, a better pair of eyes (Gemini) and the wrapping of vision into five fixed tools. Which one drives the gain?
The paper separates them with an ablation (removing or replacing one part of the system to see how much the score drops), called Freestyle: same Gemini, but the coder gets a single free-form question tool, writes its own questions, and skips the five tools’ dedicated prompts. This experiment uses only GPT-5.6-sol on the 3D task, with three columns: no toolbox, Freestyle, five tools. Watch where the middle column lands:
| Setting | DINOv2 ↑ | Chamfer ↓ |
|---|---|---|
| No toolbox | 0.705 | 0.0157 |
| Freestyle (same Gemini, free-form questions) | 0.748 | 0.0070 |
| Five tools | 0.812 | 0.0035 |
Table 3 — Ablation replacing the five tools with a single free-form question interface (GPT-5.6-sol, 3D task), DINOv2 and Chamfer only. (Excerpt from the original paper, Table 3.)
- DINOv2: the total gain is , of which Freestyle gets , about 40%; the remaining three fifths or so come from wrapping vision into five fixed tools.
- Chamfer: the total improvement is , of which Freestyle gets , about 71%.
The two metrics tell slightly different stories. An extra pair of eyes alone captures most of the shape improvement (about seventy percent on Chamfer) but only about forty percent of the appearance gain on DINOv2; the remaining sixty percent or so needs the fixed tools. Extra eyes help on their own, and organizing vision into typed, fixed tools pushes further on both metrics.
6.4 The Bill: 2.0 to 6.4 Times the Output Tokens
Intuitively, outsourcing vision to Gemini should make the coder’s job lighter. The paper’s token counts say the opposite.

With the toolbox, the coder writes 2.0 to 6.4 times as many output tokens. The JSON the tools return counts as input tokens for the coder and is not in this table, so every extra token is one the coder wrote itself. The extra could come from three places:
| Source | Explanation | Basis |
|---|---|---|
| More rounds | The baseline stops when it judges itself done; with the toolbox, diff keeps reporting differences and the loop continues | Paper’s Appendix C.1 |
| Writing around every tool call | Choosing a tool, writing the query, reading the result and planning the next step | My inference |
| More edits | Each round fixes code for the newly reported differences | My inference; the paper does not report the baseline’s edit count |
Tool calls and token multipliers loosely track each other, though with only 4 models it is no strict correlation. Per the paper’s Table 7, GLM-5.3-Flash makes the fewest calls, 11 to 36 per task, and has the smallest multiplier, 2.0 to 3.0 times; GPT-5.5 makes the most, 92 to 285 per task, at 3.3 to 6.3 times; the other two models also fall inside the overall 2.0 to 6.4 range, with exact multipliers in Table 5. Text-only GLM-5.2 is more extreme: on HTML it writes 686K output tokens and makes 733 tool calls per task, since every act of looking has to go through a tool.
And this table covers only the coder’s output; the tokens it reads and the Gemini side’s cost go unreported, so the real total can only be higher.
7 Limitations: One Ablation, Half the Cost Accounting
- The credit split rests on narrow evidence. “Fixed tools beat free-form questions” is the paper’s most useful engineering finding, yet it comes from a single Freestyle ablation: one model (GPT-5.6-sol), one task (3D). Whether it holds for HTML, SVG or other coders, the paper does not test.
- The text-only result has a small sample. GLM-5.2 ran on only 50 tasks, and “close to a vision model” rests on those 50 tasks.
- Only half the cost is counted. The paper reports only the coder’s output tokens; there are no figures for input tokens or Gemini calls, so you cannot tell whether the quality gain is worth the extra spend.
- Reproducibility has gaps. Several implementation details are missing, which makes a full reproduction hard; they are listed below.
- The instructions the coder receives with the toolbox are not included. The appendix gives only two sets of coder instructions, one for the baseline without the toolbox and one for Freestyle; I would guess the missing one also shapes the coder’s behavior.
- The stop condition is not defined (the gap noted in the prompt section), and it affects both quality and cost.
- Where IDs like
block_1intranscribe’s output come from. - Each tool’s parameter definitions, for example who sets
inspect’s mode. - The text says
aligncan check “text or specifications”, but the appendix includes only the text-checking prompt. - Whether the prompts go in the system or the user role.
8 Takeaways: Add a Comparer, Type the Eyes, Count the Cost
- In the screenshot-to-code loop, writing code and rendering have deterministic tools; comparison is what stalls. Self-checking is capped by the model’s own eyesight and quits early, and existing external vision sees one image at a time. VHarness leaves the coder untouched and untrained, and uses one Gemini-3.8-Flash plus five prompts to build
transcribe,grep,inspect(understand the target) anddiff,align(compare and confirm), which the coder calls freely over MCP. - The wrapping has value of its own. In the Freestyle ablation, the same external model behind free-form questions captures only about forty percent of the appearance gain (DINOv2), with the remaining three fifths or so coming from the five fixed tools; for shape (Chamfer), about seventy percent comes from the extra eyes alone. All four multimodal models improve on all three tasks, the weakest baseline, Claude Opus 4.8, gains most, 3D most of all; a text-only model with the toolbox comes close to a vision model working alone.
- The bill is not settled: the coder’s output tokens rise 2.0 to 6.4 times, and input tokens and the external model’s cost remain unknown.
If you build agents that read screenshots or design mockups, the cheapest first step is to turn your existing vision calls into a few fixed-format tools: one that returns a list of differences, one that returns true or false, with coordinates on a shared scale, and see what happens to quality. Then watch output tokens, which grow with the number of rounds. And remember that “typed tools beat free-form questions” currently rests on one model and one task; on your own task, verify it again.






