Repository navigation
feat: run computer use on OpenAI-compatible AI providers - #31895
Conversation
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3820beef47
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review Note Posted by Xum on Mike's behalf. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 833eea53f2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Note Posted by Xum on Mike's behalf. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e7329d67ed
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Note Posted by Xum on Mike's behalf. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d6e0c9e30
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return DefaultComputerUseProvider(t.provider) == codersdk.ChatComputerUseProviderAnthropic && | ||
| t.anthropicToolVersion == fantasyanthropic.ComputerUseToolset20260801 |
There was a problem hiding this comment.
Shed automatic screenshots during compaction
For OpenAI-compatible computer use, every successful action persists a fresh PNG tool result, and a model can emit several such calls in one step. If this screenshot-heavy history exceeds the compatible model or gateway's context/request-body limit, compaction cannot recover: its overflow retries truncate only text and error tool results, leaving every media result intact, so the chat terminates with the conversation-too-large error even though obsolete intermediate screenshots could be replaced by placeholders for summarization. Make the compaction fallback elide old automatic screenshot results, or otherwise provide a media-thinning retry.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This is not specific to the OpenAI-compatible flavor. On main, every flavor except the newest Anthropic toolset already stores a screenshot per action (computerUseAnswersWithText, and runOpenAIComputerUse ends with captureSharedScreenshot), and compaction only replaces tool media the compaction model cannot accept (replaceUnsupportedToolMedia). A media-thinning retry would be a compaction change outside this diff, so I'm leaving this open for Mike to decide whether to track it as a follow-up.
Note
Posted by Xum on Mike's behalf.
Documentation CheckBlocking
Findings for agents- id: audience-1
persona: audience
class: rule
blocking: true
file: docs/coder-agents/platform-controls/virtual-desktop.md
line: 52
quote: "An OpenAI-compatible AI provider has no computer use tool of its own, so Coder offers computer use to the model as an ordinary tool and returns a screenshot after every action."
evidence:
- docs/.style/content-guidelines.md#evidence-justifies-a-claim-and-does-not-belong-in-the-claim
rule: docs/.style/content-guidelines.md#evidence-justifies-a-claim-and-does-not-belong-in-the-claim
problem: The sentence describes how Coder implements computer use internally (the "chat completions API", "hosted computer tool", and "function tool" identifiers) rather than anything the organization admin types or receives while configuring computer use.
fix: "Reframe around what the reader observes and must do, keeping the screenshot behavior."
verified: trueAutomated review via Coder Agents. Reply to a finding's thread with the reason if the finding is wrong. |
|
@codex review Note Posted by Xum on Mike's behalf. |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
The Anthropic and OpenAI-compatible flavors share one action runner, but only the OpenAI-compatible tool rejected undeclared actions and off-screen coordinates. Decode the input into one struct and validate it against the actions that the flavor declares, so both flavors get the same checks: - An action that the flavor does not declare is rejected before it reaches the desktop. For Anthropic, this newly rejects key_down and key_up. - A coordinate outside the screenshot is rejected with the valid range for Anthropic too, because the desktop clamps it to the screen edge. - A null coordinate, start_coordinate, scroll_amount, or repeat counts as absent. Chat completions models often send null for unused fields, and the old parser rejected a null coordinate. ComputerUseProvider now derives the openai-compat flavor from the client switch, like the other flavors.
6d8e191 to
a7cf3c4
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Computer use only ran on Anthropic and OpenAI AI providers. Chatd derives the tool flavor from the AI provider type, and
openai-compathad no flavor, so every self-hosted model was marked unavailable fortype=computer_use, including the model a single-provider deployment already uses for chat.Hosted computer tools are not an option on those servers: an OpenAI-compatible endpoint accepts a
computer_20250124tool over/v1/messagesand acomputer-use-previewtool over/v1/responsesand then drops both, so the model never sees a way to act. Computer use is now declared as an ordinary function tool for those providers. The model sends one action per call and every call answers with a fresh screenshot, which is the shape these models already handle through the shared action runner. The tool omitszoom, which the agent desktop cannot perform. The desktop clamps a point outside the screen to its edge, so the tool rejects a coordinate outside the declared screenshot with an error that states the valid range, and a model that aims off the screen learns that it missed. Media tool results reach the model because the pinned fantasy fork promotes them to user-role messages, so no dependency changed.Coder can't verify an arbitrary OpenAI-compatible model, so those models keep the unverified warning icon in the admin UI. The virtual desktop docs, the Coder Agents index, the chatd architecture doc, and the organization model settings copy now list OpenAI-compatible providers as supported, and the docs say what to check before using one.
Three shared behaviors needed fixing to make this usable. A coordinate of
[0,0]is the top-left pixel and decoded as an omitted field, so the desktop rejected those clicks with a missing-coordinate error; coordinates now decode by key presence, which also keeps an absent coordinate absent. Ascroll_amountof zero or less, or a keyrepeatof zero, was also forwarded as omitted, so the desktop scrolled its default of three clicks or pressed the key once; the runner now rejects both, and the function tool declares a minimum of 1 for each. And because a chat completions model sends one action per call, it plans every call of a step against one screen, so a failed action now halts the later calls of that step, as it already did for Anthropic. The hosted OpenAI flavor still differs here on purpose: it delivers an array of actions in one call. Halting would strand a mouse press whose release was planned for a later call, so the function tool offersleft_click_draginstead of separate press and release actions, and rejects any action it does not declare.Provider types that reuse the chat completions client without being OpenAI-compatible (Azure, Google, OpenRouter, Vercel, Copilot) stay unsupported until each is verified.
Note
coderd/apidoc/docs.go,coderd/apidoc/swagger.json,docs/reference/api/schemas.mdandsite/src/api/typesGenerated.tsare hand-edited to match the new enum value, because the environment that prepared this change had no pnpm to re-run the generators. The same environment had no node, sopnpm run typecheck, biome and prettier did not run locally; CI is the validator for thesite/change and the generated files.Note
Prepared by Xum, Mike's coding agent, from the measurement that showed an OpenAI-compatible server dropping both hosted computer tools.