OpenAI: send the `computer` tool as OpenAI's native computer tool on GPT-5.4 and later

Merged
AD
11d ago
+16526-59

Part of #9347

On GPT-5.4 and later, this PR sends the computer tool from ComputerUse() (#11037) as OpenAI's own computer tool, in place of a function tool. Users change nothing. The model gets the tool it was trained on. Pydantic AI translates its computer_call items to and from the shared actions in #11006. Other models, and ComputerUse(native=False), keep the function tool.

How to review:

  1. Read models/openai/_computer.py. The whole translation is in this one module.
  2. Then read the model checks in profiles/openai.py (_is_computer_use_model) and in _responses_model.py (_instance_profile_defaults).

Changes in this round

  • One computer_call is one computer call. The harness (#11037) now stops a response's later computer calls after one fails, so the adapter needs no batch handling.
  • Blocking a response that didn't complete is one function, block_computer_calls. It is called directly from the plain and the streamed path when the status isn't completed. It finds the computer tool with available_tool_names_for_kind. The stop_computer_calls_unless_completed wrapper, its refusal branch and its handling of a deferred tool revealed in the same response are cut (see Evidence).
  • Fewer action guards. extra='forbid', _TOOL_TYPES, _refused_action, the check for an actions value that isn't a list, and the None return in map_computer_call that only the stream parity test used are cut. The parity test now gives the computer tool to the requests that sent it. An action that doesn't validate goes to the tool as {"unsupported_openai_action": <the action>}, which the tool refuses. Sent as it is, a click with no coordinates would be a valid click wherever the pointer is.
  • Key names GPT-5.5 sends. NUMPAD0 to NUMPAD9, NUMPADENTER, NUMPADSUBTRACT, NUMPADMULTIPLY, NUMPADDIVIDE, NUMPADDECIMAL, LEFTCTRL/CTRLLEFT, LEFTSHIFT/SHIFTLEFT, LEFTALT/ALTLEFT and METALEFT now map. The shipped map refused all 14. The ARROW* names are cut: GPT sent UP, DOWN, LEFT and RIGHT, never ARROW*.
  • No scroll note. A pixel scroll still becomes wheel clicks of 114 px, but the result no longer says how it ran.
  • No special handling of results stored as JSON text, and tool-return images on the function path keep main's default detail. detail: "original" stays on computer_call_output and on the extra images after it.
  • Core changes followed: ComputerResult.actions_changed, no back/forward mouse buttons, Scroll.amount always set. MouseMove takes no modifiers, so a GPT move that holds keys goes to the tool with them and is refused, rather than moving without them.
  • Renames: map_computer_call_output → map_computer_result, _held_computer_calls → _server_stored_computer_calls, _held_computer_call → _replayable_computer_call, UNFINISHED_COMPUTER_ARGS → BLOCKED_CALL_ARGS (now in models/openai/_computer.py), and context fields computer_calls_by_id and sends_native_computer.
  • Recordings: test_gpt_actions_reach_the_screen (no back-button step), test_gpt_computer_calls_go_back_to_a_request_without_the_computer_tool, test_gpt_continues_a_native_history_after_the_tool_opts_out and test_gpt_resumes_an_approved_stored_native_call_after_the_tool_opts_out were re-recorded, with trailing whitespace stripped. test_gpt_is_told_how_a_pixel_scroll_ran and its recording are removed.

What the PR adds

  • Which models.
    • ComputerTool is in the profile's list of supported native tools for GPT-5.4 (including mini and pro), GPT-5.5 (including pro), GPT-5.6 and GPT-6.
    • These models get it through OpenAIResponsesModel, on OpenAI and on Bedrock Mantle's Responses API.
    • It is removed for Azure OpenAI clients and for any provider other than OpenAIProvider and BedrockMantleProvider, such as OpenRouter.
    • Turning it on or off works through main's supported_native_tools, the same way as for tool search. There is no separate flag.
  • Calls.
    • The actions of one computer_call become one computer call.
    • Each action is checked strictly against its documented fields. If an action has no matching action, or a field is missing or of the wrong type, nothing runs, and the model is asked to fix the call.
    • A scroll in pixels becomes wheel clicks of 114 px each.
    • A streamed call starts once, with all its arguments.
    • A computer call in a response that was incomplete or failed runs nothing.
  • Results.
    • The screenshot goes back as a computer_call_output at detail: "original".
    • A short user message with the summary follows if the call failed, was refused, was changed by a hook, or has no screenshot. Without that message, GPT would assume its actions ran.
    • Extra images in a result go in a user message, with core's tags that say which tool result they came from.
  • History.
    • Calls go back as computer_calls while two things hold: the request sends the computer tool, and the call is still the one GPT made. Otherwise they go back as function calls. For example, this happens when the history goes to another provider, or after a hook changed the call.
    • Calls that OpenAI holds on its side work with previous_response_id, with conversations, and with the stateless compact endpoint. That endpoint needs the computer tool turned on, so the tool is passed there too.
  • Docs. docs/models/openai.md points to ComputerUse. The screen-size section says at which sizes GPT clicks accurately.

Design decisions

Native support follows the profile's list of native tools. An earlier flag, openai_responses_supports_computer_tool, was dropped (a59e2e925c). Main's supported_native_tools does the job instead, as it does for tool search and the advisor tool. A user can turn the tool on or off with profile=, like any native tool.

Azure and OpenRouter keep the function tool; the gateway gets the native tool. Azure hasn't been checked live with the native tool, so it keeps the tool that works everywhere. The gateway's OpenAI route is an OpenAIProvider that reaches OpenAI's own API, so it gets the native tool like OpenAI (e79af7e687). OpenRouter isn't an OpenAIProvider, so it gets the function tool. Live, OpenRouter answered the native tool with only a reasoning item, with no call and no text. A user can turn the native tool on for any of them with the model's profile= argument.

Screenshots go back at detail: "original". On GPT-5.5, a screenshot costs the same number of tokens at this detail as at the default (2,079). The model clicks on exactly what it sees.

No limit on screenshot size for GPT. OpenAI accepts a screenshot of any size. The earlier limits were advice about accuracy, and later measurements didn't support them (2f829ab922). The docs give the advice instead: GPT-5.5 clicks accurately up to 1920x1200, and GPT-5.4 up to 2048x1280. The two measurements below disagree for GPT-5.5 at 2560x1440, so the docs give the smaller size.

A call that can't be translated runs nothing. An action that doesn't validate is kept under a reserved unsupported_openai_action key. Those arguments fail validation in any tool that runs them. So the call can't run with a default filled in, such as a click at the pointer for a click with no coordinates.

No handling of safety checks. The current computer tool sent no pending_safety_checks in the live responses recorded for this PR. The approval step for them was removed (71f550faa3). A call in the old format, with a single action, is refused, because OpenAI's SDK treats that format as missing its checks.

Whether a response's computer calls run is decided once, from the final response. OpenAI's guide says "Stop if the API returns an incomplete or failed response" and "Do not execute a partially generated action". So every computer call, native or function (native=False), in a response whose status isn't completed gets arguments that can't be parsed, and none of them run. A missing status counts as completed, for compatible APIs that send none. The run itself isn't ended here: the model is asked again, as after any tool call it sent incomplete, and a call cut off by the token limit a second time ends the run with IncompleteToolCall.

One function, block_computer_calls in _computer.py, does this for both the plain and the streamed path. Streamed events are left alone, so a call never starts twice (test_a_finished_call_in_a_response_that_did_not_complete_runs_nothing). Ordinary function calls keep main's behaviour. Refusals don't block: in 12 answered GPT-5.5 responses to harmful requests, none held a refusal part or a computer call (see Evidence).

One check decides whether a held call is still the one GPT made. A held call is a computer_call that OpenAI stores on its side. _replayable_computer_call returns it only if the call came from this provider, still has the native computer tool's name, and still has the stored actions. A hook may have renamed the call or changed its actions. Everything that replays or continues a conversation uses this check (8e581b8408, test_a_call_changed_since_gpt_made_it_is_never_replayed_as_made):

  • Full replay: a changed call goes back as an ordinary function call. So OpenAI is never told that actions ran which never did.
  • Continuing from a stored response: an output for a held call needs the native tool in the same request. Live, OpenAI answered 400 (You provided computer_output, but the "computer" tool is not enabled.) when a run resumed an approved call with ComputerUse(native=False). Now previous_response_id and compaction send the whole history in that case, as main does when a stored response no longer fits (test_gpt_resumes_an_approved_stored_native_call_after_the_tool_opts_out, recorded live). A live probe showed that a held call with no answer in the request needs no tool.
  • Conversations: a conversation already holds the items, so the whole history can't be sent again. Answering a held call there with native=False raises UserError. The error says to keep the native tool until the call is answered.
  • A changed call in a conversation: it is answered by its ID with a note, "The call ran as <name> with the arguments <json>.", because the stored item still shows what GPT made. The note goes only with a call that ran, not with one that was denied or interrupted (a467938258).

This replaces separate fallbacks for previous_response_id (815c5417b4) and compaction (94f3139e53). It also covers conversations and renamed calls, which no fallback did.

The native tool is never sent deferred. OpenAI rejects defer_loading on its computer tool, as recorded in test_openai_rejects_defer_loading_on_its_computer_tool. So when tool search would defer it, the computer goes as the function tool (test_a_computer_tool_found_by_tool_search_goes_as_the_function_tool). A ComputerUse loaded on demand with defer_loading=True is left out until it loads. Then it is sent as the native tool (test_gpt_drives_the_screen_after_loading_a_deferred_computer).

Evidence

Models (live, 20b2757779, 24217e8ebc):

Accept the native toolReject it with a 400
GPT-5.4, 5.4 mini, 5.5, 5.5 pro, 5.6, GPT-6GPT-5.4 nano, GPT-5.3 Codex, GPT-5.2

On Bedrock Mantle, GPT-5.4, 5.4 mini, 5.5, 5.6 and GPT-6 accepted it. GPT-5.4 nano and 5.2 refused it.

Click accuracy by screen size. Two measurements. They disagree at 2560x1440:

Model1920x12002048x12802560x14403840x2160
GPT-5.5, through ComputerUse, 3 targets (2026-11-11, 9620e0e8e3)18/186/94/9not measured
GPT-5.5, direct API, 1 target (2026-11-16)within 1 pxwithin 1 px3/3 within 1 pxmissed by 242 to 736 px
GPT-5.4, direct APIwithin 1 pxwithin 1 pxone miss of 40 pxmissed by 42 to 755 px
GPT-5.4 mini, direct APInot measurednot measuredmissed by 9 and 64 pxmissed by 104 to 221 px
GPT-5.6 (luna, sol, terra), GPT-6 sol, GPT-6.1 sol, direct APIwithin 1 pxwithin 1 pxwithin 1 pxwithin 1 px
  • In the earlier measurement, each GPT-5.5 miss was the right position multiplied by about 0.8 or 1.15. GPT-5.4 and GPT-5.6 hit 6/6 at 2560x1440.
  • The later probe is why the limits were dropped.
  • The advice in the docs is the cautious reading of both measurements.
  • A screenshot's input tokens grow with its size:
ScreenInput tokens
1920x12003,582
2048x12803,918
2560x14405,166
3840x216010,638

Scroll distance. One wheel click scrolled 114 px in Firefox ESR 153 on the Docker desktop at 1280x800 (b1372bfd56).

Probes for this round (GPT-5.5 unless named, 2026-11-23):

WhatResultDecision
Key names, a 34-name list and a 27-task listGPT sent NUMPAD0, NUMPAD7, NUMPADENTER, NUMPADSUBTRACT, NUMPADMULTIPLY, NUMPADDIVIDE, NUMPADDECIMAL, LEFTCTRL/CTRLLEFT, LEFTSHIFT/SHIFTLEFT, LEFTALT/ALTLEFT and METALEFT. The shipped map refused all 14. Arrows came as UP, DOWN, LEFT, RIGHT in 4 of 4 asks, never ARROW*.Add the 14, cut ARROW*
Scroll note: "wheel-scroll until Row 173 is the top row" on a Docker desktop, 6 runs with the note and 6 withoutExact landing 3/6 with the note, 4/6 without. One run each overshot to the end of the page.Cut the note
computer_call_output with no image, then with image_url: ''400 Missing mutually exclusive parameters: 'input[0].output'. Ensure you are providing exactly one of: 'file_id' or 'image_url'. and 400 Invalid 'input[0].output.image_url'. Expected a valid URLKeep the blank PNG
Refusals: 20 harmful requests with the computer tool, 8 of them with a JSON schema8 were rejected before the model saw them (400). The 12 answered held text only: no refusal part and no computer call.Cut the refusal branch
A computer_call's cu_ ID on a function_call400 Invalid 'input[1].id': 'cu_…'. Expected an ID that begins with 'fc'. The same item with an fc_ ID or none gives 200.Keep the ID rewrite
One request with the computer tool per modelgpt-5-nano, gpt-5.4-nano, gpt-5.3-codex and gpt-5.2: 400 Tool 'computer' is not supported with <model>. gpt-5.4, gpt-5.4-mini and gpt-5.5: 200.Keep the model check
Mouse back and forward buttons; a hover with a key heldGPT clicked the toolbar arrow or pressed ALT+LEFT when asked to go back (0 of 4 used the button). It sent button: back or forward only when the prompt named the button, and move with keys only when the prompt asked for a held key.Core dropped both. A GPT move with keys is refused.
Results stored as JSON text: a real run's history through ModelMessagesTypeAdapterAll 11 computer results came back as [str, BinaryImage], never a JSON string.Cut the handling

Recorded tests through the real ComputerUse (tests/harness/computer_use/test_computer_use_live.py):

BehaviourTest
GPT drives the screen with the native tooltest_gpt_drives_the_screen_through_the_native_computer_tool, test_gpt_actions_reach_the_screen
Bedrock Mantletest_gpt_on_bedrock_mantle_drives_the_screen_through_the_native_computer_tool
Tool loaded on demandtest_gpt_drives_the_screen_after_loading_a_deferred_computer
History sent to a request without the tooltest_gpt_computer_calls_go_back_to_a_request_without_the_computer_tool, test_gpt_continues_a_native_history_after_the_tool_opts_out
Stored responses, conversations, store=Falsetest_gpt_gets_only_the_outputs_after_a_stored_response, test_gpt_gets_only_the_outputs_in_a_conversation, test_gpt_gets_the_whole_history_back_with_store_off
Compactiontest_gpt_compacts_a_history_of_computer_calls_through_the_compact_endpoint and three similar tests
Denied call, extra image, call cut off by the token limittest_gpt_is_told_why_a_denied_call_has_a_blank_screenshot, test_gpt_sees_an_image_a_result_holds_beside_its_screenshot, test_gpt_computer_call_cut_off_by_the_token_limit_has_no_actions

The translation rules are tested in tests/models/test_openai_computer_use.py. Examples: test_a_call_changed_since_gpt_made_it_is_never_replayed_as_made, test_azure_and_openrouter_keep_the_function_tool_and_the_gateway_gets_the_native_tool, test_a_malformed_call_runs_nothing, and the property-based test_any_stored_computer_call_replays. One recorded call with ten actions replaced one recording per action. That cut about 4.6k lines (5cee9f7b91).

Known limits and follow-ups

  • OpenAI's native tool can't zoom, triple-click, hold a key, press or release a mouse button on its own, or read the pointer position. ComputerUse(native=False) gives GPT those actions.
  • Not checked live: Azure, the gateway, and the Codex backend.
  • OpenAI's computer tool is sent only on OpenAI and Bedrock Mantle, the two servers checked live (7913b11ef8). Every other OpenAI-compatible server, such as Ollama or vLLM, gets ComputerUse's function tool, even when the model's profile lists ComputerTool for its own provider's API, as Claude's does. Their other native tools stay as on main. A server that supports OpenAI's tool can add ComputerTool to supported_native_tools in the model's profile.
  • When a streamed computer call is stopped, its last PartEndEvent still shows the original arguments. The final response has the stopped arguments.
  • An action field OpenAI doesn't document is ignored, so the action runs without it. GPT-5.5 sent no such field in this PR's recordings or probes.

Testing

  • Recorded tests through ComputerUse on OpenAI and Bedrock Mantle, listed above. The recordings match on request bodies (cad5802317).
  • Translation tests through model.request and the stream. They include property-based tests over every valid action and every stored call.
  • Live accuracy probes as above.

Merging

This PR builds on #11006 and #11037. The Anthropic PR #11039 sits on top of it.