Skip to content

feat: run computer use on OpenAI-compatible AI providers - #3

Merged
ibetitsmike merged 10 commits into
mainfrom
mike/computer-use-openai-compat
Nov 8, 2026
Merged

ibetitsmike merged 10 commits into
mainfrom
mike/computer-use-openai-compat

Conversation

@ibetitsmike

Copy link
Copy Markdown
Owner

Brings coder#31895 into the fork: computer use runs on OpenAI-compatible AI providers through an ordinary computer function tool, so a computer_use subagent can start on a self-hosted model such as the local oMLX Qwen.

The 10 commits are cherry-picked unchanged from the upstream PR head 84e305522f; the tree diff against fork main is identical to the upstream PR diff. No migrations and no chatd schema changes.

Known limit from the local UAT: the plumbing works, but Qwen3.8-Flash-Next cannot localize UI targets well enough to drive a desktop, so expect slow, inaccurate clicks from that model.

Note

Opened and merged by Xum, Mike's coding agent, at Mike's request.

Computer use only ran on Anthropic and OpenAI AI providers. Chatd derives the
tool flavor from the AI provider type, and `openai-compat` had no flavor, so any
self-hosted model, including the deployment default here, was marked
unavailable for `type=computer_use`.

Hosted computer tools are not an option on those servers: an OpenAI-compatible
endpoint accepts a `computer_20250124` tool over `/v1/messages` and a
`computer-use-preview` tool over `/v1/responses` and then drops both, so the
model never sees a way to act. Declare an ordinary function tool instead. The
model sends one action per call, and the runner answers every call with a fresh
screenshot, which is the shape these models handle through the shared action
runner. Media tool results already reach the model because fantasy promotes
them to user-role messages.

- `codersdk.ChatComputerUseProviderOpenAICompat` names the new flavor, and
  `chatprovider.ComputerUseProvider` returns it for `AIProviderTypeOpenaiCompat`.
  Provider types that reuse the chat completions client without being
  OpenAI-compatible (Azure, Google, OpenRouter, Vercel, Copilot) stay
  unsupported until each is verified.
- The new tool reuses the Anthropic input conventions (whole-second durations,
  capped key repeat) so one action runner serves both flavors, and it omits
  `zoom`, which the agent desktop cannot perform.
- `runActionPerCallComputerUse` now backs both the pre-2026 Anthropic toolsets
  and the new flavor. The Anthropic toolset keeps its text action results.
- A requested screenshot is still stored as a chat attachment; the screenshot
  that follows an action stays model-only.

Coder cannot verify an arbitrary OpenAI-compatible model, so those models keep
the unverified warning icon in the admin UI, and the docs say so.

No new dependency: `go.mod` and `go.sum` are unchanged.

Tests: the flavor selection, tool definition, action runner, and turn wiring are
covered, and the model-override API test now accepts an OpenAI-compatible model
while a Google model still proves the rejection path.

Docs: the supported-provider list in the virtual desktop page and the
architecture page now includes OpenAI-compatible providers.

Generated `coderd/apidoc/docs.go`, `coderd/apidoc/swagger.json`,
`docs/reference/api/schemas.md`, and `site/src/api/typesGenerated.ts` are
hand-edited to match the new enum value because this checkout has no pnpm.
Three surfaces still listed only Anthropic, OpenAI, and Bedrock as computer
use providers. Update the Coder Agents index and the organization model
settings copy. Leave a TODO in the chatd architecture document, because its
author writes that document's prose updates.
A computer action at the top-left pixel [0,0] decoded as an omitted
coordinate, so the agent rejected the action with a missing-coordinate
error. Coordinates now decode by key presence, which also keeps an absent
coordinate absent instead of clicking the corner.

An OpenAI-compatible model batches one action per call, so every call of a
step is planned against the same screen. The flavor was left out of the
halting gate, and a later click or type still ran after an earlier action of
the step failed. It now halts like the Anthropic flavor, which also sends one
action per call. The hosted OpenAI flavor sends an array of actions per call
and is unchanged.
markdown-table-formatter pads every row of a table to its widest cell, so the
longer computer use row in docs/coder-agents/architecture.md required re-padding
the whole table. Cell content is unchanged; fmt and lint-docs both check the
padding.

revive rejects a control-flag parameter, so runActionPerCallComputerUse no
longer takes textResult. computerUseAnswersWithText derives the answer shape
from the provider and tool version, which is the same rule, and the two
flavors that send one action per call now share one Run case.
… subagents

The computer_use model allowlist in the chatd architecture doc predates
OpenAI-compatible support. Add the provider and drop the TODO that
flagged the stale sentence.
A failed computer call halts the rest of its step, so an OpenAI-compatible
model that pressed the mouse with left_mouse_down and planned the release
for a later call could leave the button pressed. The function tool no
longer offers left_mouse_down or left_mouse_up (left_click_drag covers
drags in one call) and rejects any action it does not declare.

A scroll_amount of zero or less was forwarded as omitted, so the desktop
scrolled its default of three clicks. The runner now rejects it, and the
function tool declares a minimum of 1.
Coordinates are forwarded by key presence, which is safe only because
fantasy's ParseComputerUseInput rejects an array that is not exactly two
values; otherwise it would decode zero-filled into a top-left click. Pin
that with a test and say so in the comment.
A repeat of 0 read as an omitted repeat, so a key call asking for zero
presses pressed the key once. Detect repeat by key presence, like
scroll_amount, so 0 is rejected with the other out-of-range counts.
Drop the transport and tool-mechanism terms from the OpenAI-compatible
paragraph and move its confirmation step next to the general one, so
the check before saving covers both kinds of provider.
…AI-compatible models

The desktop clamps a point outside the screen to its edge, so a model that
aims off the screenshot sees an action land somewhere it did not ask for and
gets no signal that it missed. Reject such coordinates for the
OpenAI-compatible function tool with an error that states the valid range.
@ibetitsmike
ibetitsmike enabled auto-merge (squash) November 8, 2026 21:38
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

Docs preview

Check off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here.

@ibetitsmike
ibetitsmike merged commit 03753eb into main Nov 8, 2026
5 of 6 checks passed
@ibetitsmike
ibetitsmike deleted the mike/computer-use-openai-compat branch November 8, 2026 21:49
ibetitsmike added a commit that referenced this pull request Nov 10, 2026
…#143)

Bring coderd/x/chatd/chattool/computeruse.go, computeruse_test.go,
chatprovider/chatprovider.go and chatloop/chatloop.go to upstream
082668f, which adds a7cf3c4 (validate per-call computer actions
the same way for every flavor) on top of the commits fork PR #3 already
ported. Take the matching ChatComputerUseProvider doc comment in
codersdk/chats.go and keep the fork-only fields there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant