Visual Artifact Verification
Use when you produced an HTML concept/mockup/poster (or any visual artifact) and need to actually SEE it before showing the user, but (a) no browser toolset is loaded in the session, and/or (b) the configured vision model rejects image input (e.g. a text-only model errors with unknown variant 'image_url', expected 'text'). Two proven paths replace browser_navigate + vision_analyze:
- Headless Chrome screenshot — render HTML → PNG locally (no browser toolset needed).
- OpenRouter vision fallback — QA the PNG with a vision-capable model via direct API (bypasses the session's text-only vision model).
Path 1: Headless Chrome screenshot (HTML → PNG)
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
--headless=new --disable-gpu --hide-scrollbars \
--screenshot="/tmp/out.png" \
--window-size=1080,1620 \
"file:///abs/path/index.html"
- For deterministic full-poster captures, give the body a fixed canvas:
html, body { width: 1080px; height: 1620px; overflow: hidden; }and match--window-sizeto it. 1080×1620 = 2:3 portrait (X-post sized). - Chrome, Chromium, or Brave paths all work (check
/Applications/on macOS). - Fonts load over the network (Google Fonts
<link>works fromfile://).
Path 2: OpenRouter vision fallback (PNG → text QA)
When vision_analyze fails, call OpenRouter directly with a vision-capable model. Reusable script: scripts/vision_qa.py.
python3 scripts/vision_qa.py /tmp/sketch.png "Any overflow, clipping, broken images, cut-off sections? Are the 6 cards + header + footer visible?"
Key details:
- Model:
openai/gpt-4o-mini(cheap, vision-capable, reliable). - Reads
OPENROUTER_API_KEYfrom~/.hermes/.env; send the image as a base64 data URL inimage_urlcontent. - Works on any backend because it bypasses the configured (possibly text-only) vision model.
- Other vision-capable keys that can substitute if OpenRouter is missing: Kimi (
KIMI_API_KEY, moonshot-vl), DashScope (DASHSCOPE_API_KEY, qwen-vl). Probe with a small test image first.
Workflow
- Write the artifact (HTML file, generated image).
- Screenshot with headless Chrome (HTML only).
- Vision-QA the PNG with
scripts/vision_qa.py— ask specifically about overflow, clipping, cut-off edges, unstyled elements, broken images, and whether every expected section is visible. - Fix issues in source, re-render, re-QA.
- Present to user (optionally open in their browser via
human-review).
Pitfalls
unknown variant 'image_url', expected 'text'from an OpenAI-compatible chat API = the model is text-only. Don't keep retryingvision_analyze; switch to Path 2 immediately.- Oversized images can fail even with a vision-capable model — downscale first (macOS):
sips -Z 768 -s format jpeg in.jpg --out out_small.jpg. - QA prompt should be concrete, not "how does this look": enumerate the failure modes you care about (overflow, overlap, clipping, cut-off at bottom, broken img, contrast) so the model reports them.
- Piping
curl | python3trips shell security heuristics; write a.pyfile and run it instead (cleaner, reusable, no approval friction). - If a vision call returns a huge error body, print only the first ~1500 chars (
json.dumps(d)[:1500]) to avoid flooding context.
Why this exists
Session where vision_analyze failed on a text-only model; headless Chrome + OpenRouter QA passed all three HTML mockups cleanly. Also documents the browser-toolset diagnostic path — see references/browser-toolset-troubleshooting.md for why browser/web tools may be absent in a profile and how to enable them.
References
references/browser-toolset-troubleshooting.md— profile env isolation,hermes status/doctor/toolschecks, post-setup hooks, cloud_provider mismatch, Firecrawl setup.scripts/vision_qa.py— parameterized OpenRouter vision-QA script.