Skip to content

feat: add named frame sources and vision annotation pipeline - #990

Merged
edenreich merged 11 commits into
mainfrom
feat/vision-annotation-pipeline
Aug 3, 2026
Merged

edenreich merged 11 commits into
mainfrom
feat/vision-annotation-pipeline

Conversation

@edenreich

@edenreich edenreich commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #895

What

Lets any chat-completions model — including text-only ones like DeepSeek — understand screen and camera frames, via explicit tools instead of base64 image forwarding.

  • Named frame sources: the screenshot ring buffer becomes the screen source; new directory sources serve the newest image from a folder (camera frames), with optional retention pruning. Registered on the tool registry, so chat and headless infer agent get them.
  • Image annotator (internal/vlm): image → scene summary + numbered element list with bounding boxes, via a side-call to a vision model through the gateway (title-generator pattern). The gateway also serves fully local models (Ollama), so offline annotation is just a local provider — no separate engine in the CLI. Default model: ollama_cloud/qwen3.5-vl.
  • GetLatestFrame(source, format) replaces GetLatestScreenshot: annotated returns text instead of the image (default when the annotator is enabled), regular returns the raw frame. Screen-source annotations include MouseClick-ready element centers.
  • ImageDecode(image, prompt?): describe any local image file as text, optionally answering a question about it.
  • Attached images carry their saved path: clipboard pastes and --files attachments add a [image saved at <path>] text part, so a model without vision can ImageDecode the file itself; pasted files are retained (pruned newest-20/24h) instead of deleted on send.

No model fingerprinting: models opt into text by calling the tools, which any orchestrator that speaks chat completions can do.

Fixes along the way

  • Headless infer agent silently dropped tool-result images; they now flow and are hoisted into a follow-up user message (tool-role messages stay text-only for Anthropic).
  • ComputerUse floating window appended a "running..." line per keep-alive tick; it now updates one line in place with elapsed time and stamps the total on completion.
  • The embedded ComputerUse.app is re-extracted on every launch; the previous exists-check kept running a stale copy after CLI upgrades.

Behavior notes

  • SetScreenshotProvider (and its MouseClick re-registration vestige) is deleted; MouseClick keeps the shared computer-use rate limiter.
  • The annotator parser never fails on malformed model output — it degrades to summary-only; annotation errors degrade to the regular frame with a note, never Success: false.

Tested

  • Unit + integration suites green; integration proves the annotated path sends zero image parts to the session model while the annotator side-call carries the image.
  • Live end-to-end: headless agent with a directory source + Ollama Cloud annotator (accurate shapes/bboxes on a synthetic frame), and interactive chat where deepseek-v4-flash:cloud (text-only) described the actual screen — iTerm/tmux panes and code visible in the editor — through the screen source + qwen3.5:cloud annotator.

Docs

README ("Frame Sources & Vision Annotation"), docs/tools-reference.md (GetLatestFrame, ImageDecode), docs/configuration-reference.md (Vision Settings, gateway.vision_enabled disambiguation). A [DOCS] ticket for inference-gateway/docs to follow.

TODOs

  • Models that supports vision shouldn't need to be instructed to call ImageDecode()
  • Models that supports vision should get the data as base64 included in the content instead of the instructions to use ImageDecode() function
  • Check if the gateway can provide a metadata about the model (if it supports vision or not)
  • Check about MacOS accessibility API or create a follow-up - should reuse existing computer use tools and it should be a parameter passed to allow it to use accessibility API instead of actually moving the mouse or typing with the keyboard, maybe we can define background tasks -> accessibility API it should be pretty good for letting deepseek (non vision model) perform some tasks

Generalize screenshot plumbing into named frame sources (screen +
directory-backed camera sources), add a pluggable image annotator
(local llama-mtmd-cli engine with auto-downloaded Qwen3-VL GGUF, or a
gateway side-call), expose it via GetLatestFrame(source, format) and a
new ImageDecode tool, and gate base64 image injection for models
declared text-only via vision.text_only_models - annotation text
replaces images at all three choke points (chat tool results, headless
agent, user attachments).

Also fixes headless infer agent silently dropping tool result images,
and hoists tool images into a follow-up user message so tool-role
messages stay text-only.

Closes #895
Models opt into text via GetLatestFrame's annotated format (the default
when an annotator is configured; the annotation text replaces the image)
or ImageDecode - any chat-completions orchestrator can use the tools
directly, no per-model vision fingerprinting needed.
…tion

The agent re-publishes 'running' tool-progress events as keep-alives;
the floating window appended a line per tick. Update the tool's line in
place with elapsed seconds instead, and stamp the total on completion.

Also re-extract the embedded ComputerUse.app on every launch - the
previous exists-check kept launching a stale copy after CLI upgrades.
@edenreich
edenreich requested a review from a team as a code owner August 2, 2026 13:32
Clipboard-pasted and file-attached images are saved to disk, but the
model only received the base64 part - a model without vision had no way
to find the file. Append a text part naming the saved path so it can
inspect the image via ImageDecode.
The message now references the saved path for ImageDecode, but the file
was deleted the moment the message was sent, so the model chased a
dead path. Prune clipboard images by retention (newest 20 / 24h)
instead of removing them on send.
Drop the local llama-mtmd-cli engine - the gateway already serves local
models (e.g. Ollama), so the annotator is always a gateway side-call.
vision.annotator.model is a provider/model reference, defaulting to
ollama_cloud/qwen3.5-vl.
qwen3.5-vl is not a real model id; the vision-capable Qwen on Ollama
Cloud is qwen3.5:397b.
qwen3.5:397b hallucinates too much on annotation; Haiku 4.5 is a
cheap vision model with reliable structured output.
Comment thread cmd/agent.go Resolved
@edenreich

Copy link
Copy Markdown
Contributor Author

@infer Can you create a follow-ups bug report / feature requests for the todos? I want to merge this PR. use /ponytail:ponytail

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Model: ollama_cloud/deepseek-v4-flash · View Job

Todos

  • Fetch issue templates from inference-gateway/.github
  • Check for existing issues before creating duplicates
  • Create follow-up issue for vision model detection (TODOs 1-3)
  • Create follow-up issue for macOS accessibility API (TODO 4)

Pull Request

#990

✅ Infer Result: Success

Done. Created two follow-up issues from the PR's TODOs:

Issue #997 - [FEATURE] Vision model detection: route image data natively to vision-capable models

  • Covers TODOs 1-3: gateway model metadata for vision capability, base64 image content for vision models instead of ImageDecode() instructions, and no unnecessary tool calls for models that natively support vision.

Issue #998 - [FEATURE] macOS Accessibility API integration for computer use tools

  • Covers TODO 4: a use_accessibility_api parameter on computer use tools that reads the macOS accessibility tree instead of moving the mouse/typing, enabling text-only models to navigate UI by coordinates without vision.

No existing open issues matched either topic, so no duplicates were created. Both are filed on inference-gateway/cli with the enhancement label, structured after the org's feature request template.

Model: ollama_cloud/deepseek-v4-flash · Exit Code: 0 · Duration: 2m 25s

Tokens: 1,267,684 in · 9,464 out · 1,277,148 total (20 requests)

Tool calls: 35 total · 89% success rate

Traces
Session: 1785751202-1aff98e8

session (standard, success)                                    2m23s
├── chat ollama_cloud/deepseek-v4-flash                         4.7s
│   ╰── POST /v1/chat/completions [inference-gateway]           4.7s
│       ╰── POST /proxy/:provider/*path [inference-gateway]     4.7s
├── execute_tool Bash call_pzwzx5ng                             29ms
├── execute_tool Read call_zatk5xin                            781µs
├── execute_tool Bash call_v4lvxo7a                             25ms [error: tool_error]
├── chat ollama_cloud/deepseek-v4-flash                         7.1s
│   ╰── POST /v1/chat/completions [inference-gateway]           7.1s
│       ╰── POST /proxy/:provider/*path [inference-gateway]     7.1s
├── execute_tool TodoWrite call_tppml5wl                        83µs
├── chat ollama_cloud/deepseek-v4-flash                         4.0s
│   ╰── POST /v1/chat/completions [inference-gateway]           4.0s
│       ╰── POST /proxy/:provider/*path [inference-gateway]     4.0s
├── chat ollama_cloud/deepseek-v4-flash                         3.6s
│   ╰── POST /v1/chat/completions [inference-gateway]           3.6s
│       ╰── POST /proxy/:provider/*path [inference-gateway]     3.6s
├── chat ollama_cloud/deepseek-v4-flash                        11.9s
│   ╰── POST /v1/chat/completions [inference-gateway]          11.9s
│       ╰── POST /proxy/:provider/*path [inference-gateway]    11.9s
├── execute_tool WebFetch call_4bkq76fi                        207µs [error: tool_error]
├── execute_tool WebFetch call_ieth9xnx                        145µs [error: tool_error]
├── execute_tool WebFetch call_jctyv1kn                        154µs [error: tool_error]
├── chat ollama_cloud/deepseek-v4-flash                        10.7s
│   ╰── POST /v1/chat/completions [inference-gateway]          10.7s
│       ╰── POST /proxy/:provider/*path [inference-gateway]    10.7s
├── execute_tool Bash call_7ud462lg                            353ms
├── chat ollama_cloud/deepseek-v4-flash                        12.1s
│   ╰── POST /v1/chat/completions [inference-gateway]          12.1s
│       ╰── POST /proxy/:provider/*path [inference-gateway]    12.1s
├── execute_tool Bash call_g7u6659m                            374ms
├── execute_tool Bash call_xn1bibik                            362ms
├── execute_tool Bash call_lepm0kqe                            402ms
├── chat ollama_cloud/deepseek-v4-flash                         4.6s
│   ╰── POST /v1/chat/completions [inference-gateway]           4.6s
│       ╰── POST /proxy/:provider/*path [inference-gateway]     4.6s
├── execute_tool TodoWrite call_6y8qmohj                        79µs
├── chat ollama_cloud/deepseek-v4-flash                         9.9s
│   ╰── POST /v1/chat/completions [inference-gateway]           9.9s
│       ╰── POST /proxy/:provider/*path [inference-gateway]     9.9s
├── execute_tool Bash call_1i2pk6nq                             34ms
├── chat ollama_cloud/deepseek-v4-flash                        11.0s
│   ╰── POST /v1/chat/completions [inference-gateway]          11.0s
│       ╰── POST /proxy/:provider/*path [inference-gateway]    11.0s
├── execute_tool Bash call_rgvruook                             29ms
├── execute_tool Bash call_9a7a2w7y                             44ms
├── execute_tool Bash call_bh7yipkf                             43ms
├── chat ollama_cloud/deepseek-v4-flash                         4.9s
│   ╰── POST /v1/chat/completions [inference-gateway]           4.9s
│       ╰── POST /proxy/:provider/*path [inference-gateway]     4.9s
├── execute_tool TodoWrite call_qme9d4hb                        81µs
├── chat ollama_cloud/deepseek-v4-flash                         3.9s
│   ╰── POST /v1/chat/completions [inference-gateway]           3.9s
│       ╰── POST /proxy/:provider/*path [inference-gateway]     3.9s
├── execute_tool Bash call_w1f333lh                            700ms
├── execute_tool Bash call_wwyn10ao                            783ms
├── execute_tool Bash call_nypxvrng                            747ms
├── chat ollama_cloud/deepseek-v4-flash                         2.8s
│   ╰── POST /v1/chat/completions [inference-gateway]           2.8s
│       ╰── POST /proxy/:provider/*path [inference-gateway]     2.8s
├── execute_tool Bash call_flmz32av                            709ms
├── execute_tool Bash call_hov9etiu                            852ms
├── execute_tool Bash call_l2cn9i1b                            837ms
├── chat ollama_cloud/deepseek-v4-flash                         2.2s
│   ╰── POST /v1/chat/completions [inference-gateway]           2.2s
│       ╰── POST /proxy/:provider/*path [inference-gateway]     2.2s
├── execute_tool Bash call_4ig3lw70                            368ms
├── chat ollama_cloud/deepseek-v4-flash                         3.2s
│   ╰── POST /v1/chat/completions [inference-gateway]           3.2s
│       ╰── POST /proxy/:provider/*path [inference-gateway]     3.2s
├── execute_tool TodoWrite call_2v37wlu5                        72µs
├── chat ollama_cloud/deepseek-v4-flash                        21.4s
│   ╰── POST /v1/chat/completions [inference-gateway]          21.4s
│       ╰── POST /proxy/:provider/*path [inference-gateway]    21.4s
├── execute_tool Write call_c93cft0n                           821µs
├── execute_tool Write call_ef7f0h9o                           898µs
├── chat ollama_cloud/deepseek-v4-flash                         2.2s
│   ╰── POST /v1/chat/completions [inference-gateway]           2.2s
│       ╰── POST /proxy/:provider/*path [inference-gateway]     2.2s
├── execute_tool Bash call_fywwii2f                             1.2s
├── chat ollama_cloud/deepseek-v4-flash                         3.8s
│   ╰── POST /v1/chat/completions [inference-gateway]           3.8s
│       ╰── POST /proxy/:provider/*path [inference-gateway]     3.8s
├── execute_tool Bash call_hoewjr2s                             1.4s
├── chat ollama_cloud/deepseek-v4-flash                         5.0s
│   ╰── POST /v1/chat/completions [inference-gateway]           5.0s
│       ╰── POST /proxy/:provider/*path [inference-gateway]     5.0s
├── execute_tool TodoWrite call_51h90i40                        68µs
╰── chat ollama_cloud/deepseek-v4-flash                         6.9s
Stats
Tool Calls

╭───────────┬───────┬───────┬───────╮
│ Tool      │ Calls │ Fail% │ Avg   │
├───────────┼───────┼───────┼───────┤
│ Bash      │ 19    │ 5%    │ 488ms │
│ TodoWrite │ 5     │ 0%    │ 0ms   │
│ WebFetch  │ 3     │ 100%  │ 0ms   │
│ Write     │ 2     │ 0%    │ 0ms   │
│ Read      │ 1     │ 0%    │ 0ms   │
╰───────────┴───────┴───────┴───────╯

Token Usage

╭────────────────────────────────┬─────────┬────────┬────────────┬─────────┬──────╮
│ Model                          │ Prompt  │ Cached │ Completion │ Total   │ Cost │
├────────────────────────────────┼─────────┼────────┼────────────┼─────────┼──────┤
│ ollama_cloud/deepseek-v4-flash │ 1267684 │ 0      │ 9464       │ 1277148 │ -    │
╰────────────────────────────────┴─────────┴────────┴────────────┴─────────┴──────╯

Sessions

╭───────────┬──────────┬──────────╮
│ Execution │ Mode     │ Sessions │
├───────────┼──────────┼──────────┤
│ headless  │ standard │ 1        │
╰───────────┴──────────┴──────────╯
⚠️ 4 log(s)
  • Bash call_v4lvxo7a:
    exit status 128: fatal: origin/main...HEAD: no merge base
    
  • WebFetch call_ieth9xnx:
    URL validation failed: domain not allowed
    
  • WebFetch call_jctyv1kn:
    URL validation failed: domain not allowed
    
  • WebFetch call_4bkq76fi:
    URL validation failed: domain not allowed
    

Triggered by edenreich · Infer Action · OSS

@edenreich
edenreich merged commit c9d884d into main Aug 3, 2026
1 check passed
@edenreich
edenreich deleted the feat/vision-annotation-pipeline branch August 3, 2026 10:03
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.159.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

[FEATURE] Vision annotation pipeline: let cheaper/text-only models understand screen and camera frames

1 participant