Vision
The underlying model has no native image understanding. When an image arrives, do not use the Read tool — run scripts/vision.js to get a text description back.
Requires Node.js 18+ (native fetch) and network access to an OpenAI-compatible vision API.
When to use
- User shares an image path (local file or remote URL)
- Message contains "Saved attachments:" listing image files
- User asks to analyze, describe, or identify image content
Quick start
node scripts/vision.js "<image path>" "[question]"
node scripts/vision.js --url "<image url>" "[question]"
node scripts/vision.js "<image path>" "find the search button" --coords
node scripts/vision.js --base64 "<base64 or data:image/...;base64,... URL>" "[question]"
node scripts/vision.js --base64 - < shot.b64 "[question]" --coords center
node scripts/vision.js "<image path>" "[question]" --session ui # multi-turn conversation
node scripts/vision.js "<image 2>" "compare with the previous image" --session ui
node scripts/vision.js --clear ui # remove the session cache when done
Run node scripts/vision.js --help for the full flag list.
Session continuity
Pass the same --session <name> to several calls to keep the conversation
history — previous images and replies are replayed alongside the current
question on every call. State is stored in .vision/<name>.json (cwd), or
VISION_SESSION_DIR/<name>.json when that env var is set. When the
conversation is finished, remove the cache with
node scripts/vision.js --clear <name>. See core-usage.
Output contract
The reply is injected into the caller's context, so keep it compact:
- Concise by default — 1 subject line + compact bullets covering every key element. No fixed cap: dense images stay complete. Group similar elements (menus, lists, grids) into one bullet; include visible text verbatim; no greetings, filler, or disclaimers.
- Debug mode (
--coords [bbox|center], caller decides) appends a ## Coordinates section — one JSON line per element: bbox {"name","text","bbox":{"x","y","w","h"}} by default, or center point {"name","text","center":{"x","y"}} with --coords center. Coordinates are pixels in the ORIGINAL image; views are resampled and remapped automatically.
- Default is non-debug — coordinates appear only when the caller passes
--coords.
Gotchas
- Never try to "see" an image directly — always use
scripts/vision.js.
--base64 accepts raw base64 or a full data URL; use --base64 - (stdin) for
large payloads that exceed the Windows command-line limit, e.g. screenshots.
- Keep replies dense: they enter the caller's context, so compactness is a hard contract, not a suggestion.
- Do not pass width/height or rescale coordinates — the script handles both automatically.
- The first
--coords call downloads one dependency (sharp, one-time); non-debug calls are zero-dependency.
--detail [n] and --rounds N are optional; defaults are compact and coarse-to-fine (2 rounds).
References — load on demand
| When |
Reference |
Unsure of flags or output contract, or using --coords / --detail for the first time |
core-usage |
| First run with no API key configured |
core-setup |
| Debugging the pipeline or editing the scripts |
core-script |
1---2name: vision3description: Image recognition for agents without native vision support. Use when the user shares an image path or URL, the message contains saved image attachments, or the user asks to analyze, describe, or identify image content. Sends local images or remote URLs to an OpenAI-compatible vision model; --coords returns pixel element coordinates for UI/debug inspection.4---5
6# Vision
7
8The underlying model has no native image understanding. When an image arrives, **do not use the Read tool** — run `scripts/vision.js` to get a text description back.
9
10Requires Node.js 18+ (native fetch) and network access to an OpenAI-compatible vision API.
11
12## When to use
13
14- User shares an image path (local file or remote URL)
15- Message contains "Saved attachments:" listing image files
16- User asks to analyze, describe, or identify image content
17
18## Quick start
19
20```bash
21node scripts/vision.js "<image path>" "[question]"
22node scripts/vision.js --url "<image url>" "[question]"
23node scripts/vision.js "<image path>" "find the search button" --coords
24node scripts/vision.js --base64 "<base64 or data:image/...;base64,... URL>" "[question]"
25node scripts/vision.js --base64 - < shot.b64 "[question]" --coords center
26node scripts/vision.js "<image path>" "[question]" --session ui # multi-turn conversation
27node scripts/vision.js "<image 2>" "compare with the previous image" --session ui
28node scripts/vision.js --clear ui # remove the session cache when done
29```
30
31Run `node scripts/vision.js --help` for the full flag list.
32
33## Session continuity
34
35Pass the same `--session <name>` to several calls to keep the conversation
36history — previous images and replies are replayed alongside the current
37question on every call. State is stored in `.vision/<name>.json` (cwd), or
38`VISION_SESSION_DIR/<name>.json` when that env var is set. When the
39conversation is finished, remove the cache with
40`node scripts/vision.js --clear <name>`. See [core-usage](references/core-usage.md).
41
42## Output contract
43
44The reply is injected into the caller's context, so keep it compact:
45
46- **Concise by default** — 1 subject line + compact bullets covering every key element. No fixed cap: dense images stay complete. Group similar elements (menus, lists, grids) into one bullet; include visible text verbatim; no greetings, filler, or disclaimers.
47- **Debug mode** (`--coords [bbox|center]`, caller decides) appends a `## Coordinates` section — one JSON line per element: bbox `{"name","text","bbox":{"x","y","w","h"}}` by default, or center point `{"name","text","center":{"x","y"}}` with `--coords center`. Coordinates are **pixels in the ORIGINAL image**; views are resampled and remapped automatically.
48- **Default is non-debug** — coordinates appear only when the caller passes `--coords`.
49
50## Gotchas
51
52- Never try to "see" an image directly — always use `scripts/vision.js`.
53- `--base64` accepts raw base64 or a full data URL; use `--base64 -` (stdin) for
54 large payloads that exceed the Windows command-line limit, e.g. screenshots.
55- Keep replies dense: they enter the caller's context, so compactness is a hard contract, not a suggestion.
56- Do not pass width/height or rescale coordinates — the script handles both automatically.
57- The first `--coords` call downloads one dependency (`sharp`, one-time); non-debug calls are zero-dependency.
58- `--detail [n]` and `--rounds N` are optional; defaults are compact and coarse-to-fine (2 rounds).
59
60## References — load on demand
61
62| When | Reference |
63|------|-----------|
64| Unsure of flags or output contract, or using `--coords` / `--detail` for the first time | [core-usage](references/core-usage.md) |
65| First run with no API key configured | [core-setup](references/core-setup.md) |
66| Debugging the pipeline or editing the scripts | [core-script](references/core-script.md) |