Repository navigation
feat(openai-base, ai-openai): add the computer tool - #1833
AlemTuzlak wants to merge 6 commits into
Conversation
computerUseTool({ type: 'computer' }) sends the computer tool of the
newer OpenAI models. Its tool name is computer. A computer_call is a
call to the computer tool of the request, with the batched actions and
the pending safety checks as input, and the replay sends the actions
back as they came. The computer_use_preview tool works as before.
OpenAI's computer use guide sends each screenshot with detail: 'original', so the model sees the screen at full size. The SDK type has no detail field yet, so the adapter adds it to its own screenshot type.
🦋 Changeset detectedLatest commit: f6ce006 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
View your CI Pipeline Execution ↗ for commit ad8d630
☁️ Nx Cloud last updated this comment at |
Coverage✅ Coverage held across 11 compared package(s). Each package is measured twice in this job — on this PR and on its merge-base with
|
@tanstack/ai
@tanstack/ai-acp
@tanstack/ai-angular
@tanstack/ai-anthropic
@tanstack/ai-bedrock
@tanstack/ai-byteplus
@tanstack/ai-claude-code
@tanstack/ai-client
@tanstack/ai-cloudflare
@tanstack/ai-code-mode
@tanstack/ai-code-mode-snippets
@tanstack/ai-codex
@tanstack/ai-cohere
@tanstack/ai-compaction
@tanstack/ai-devtools-core
@tanstack/ai-durable-stream
@tanstack/ai-elevenlabs
@tanstack/ai-event-client
@tanstack/ai-fal
@tanstack/ai-gemini
@tanstack/ai-grok
@tanstack/ai-grok-build
@tanstack/ai-groq
@tanstack/ai-isolate-cloudflare
@tanstack/ai-isolate-daytona
@tanstack/ai-isolate-e2b
@tanstack/ai-isolate-node
@tanstack/ai-isolate-quickjs
@tanstack/ai-isolate-quickjs-bun
@tanstack/ai-llmgateway
@tanstack/ai-lovable
@tanstack/ai-mcp
@tanstack/ai-memory
@tanstack/ai-mistral
@tanstack/ai-octane
@tanstack/ai-ollama
@tanstack/ai-ollaya
@tanstack/ai-openai
@tanstack/ai-opencode
@tanstack/ai-openrouter
@tanstack/ai-perplexity
@tanstack/ai-persistence
@tanstack/ai-preact
@tanstack/ai-react
@tanstack/ai-react-ui
@tanstack/ai-reactor
@tanstack/ai-remix
@tanstack/ai-sandbox
@tanstack/ai-sandbox-blaxel
@tanstack/ai-sandbox-boxd
@tanstack/ai-sandbox-cloudflare
@tanstack/ai-sandbox-daytona
@tanstack/ai-sandbox-docker
@tanstack/ai-sandbox-e2b
@tanstack/ai-sandbox-local-process
@tanstack/ai-sandbox-railway
@tanstack/ai-sandbox-sprites
@tanstack/ai-sandbox-upstash-box
@tanstack/ai-sandbox-vercel
@tanstack/ai-skills
@tanstack/ai-solid
@tanstack/ai-solid-ui
@tanstack/ai-svelte
@tanstack/ai-typesafe
@tanstack/ai-utils
@tanstack/ai-vercel-gateway
@tanstack/ai-vertex
@tanstack/ai-vue
@tanstack/ai-vue-ui
@tanstack/ai-worldlabs
@tanstack/openai-base
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
@tanstack/svelte-ai-devtools
commit: |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…r-tool # Conflicts: # packages/openai-base/src/adapters/responses-user-tools.ts # packages/openai-base/tests/computer-use-loop.test.ts
… the wire The route takes ?tool=computer for the computer tool of gpt-6.1-sol. The spec checks the batched actions, the computer tool entry, and detail: 'original' on each screenshot.
Apps can now give the newer OpenAI models, for example
gpt-6.1-sol, the computer tool withcomputerUseTool({ type: 'computer' }). The model sends a batch of actions in each call, the app runs them, and the adapter sends the screenshot back. This PR builds on #1831 (fix/openai-computer-call-loop), which makes the computer use loop run.🎯 Changes
computerUseTool()takes{ type: 'computer' }next to{ type: 'computer_use_preview', display_width, display_height, environment }. The tool name is the tool type, so the preview tool keeps its name.computer_callwithactionsbecomes a tool call with{ actions, pending_safety_checks }. The replay sends theactionsback as they came. A call with oneaction(the preview model) works as before.computer_callis a call to the computer tool of the request:computerwhen the request has it, elsecomputer_use_preview.computer, as the OpenAI SDK does.detail: 'original', as in OpenAI's computer use guide, so the model sees the screen at full size. The OpenAI SDK (also the newest, 7.39.0) and the API spec have nodetailfield yet. The adapter adds it to its own screenshot type.computerUseToolsection of the OpenAI adapter page uses{ type: 'computer' }withgpt-6.1-sol. It shows the preview tool forcomputer-use-preview, and its "Supported models" line names both.✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.docs/for this change, or this change is not user-facing.pnpm changeset), or this PR does not change a published package.🚀 Release Impact
Testing
Commands run:
pnpm --dir packages/openai-base run test:types, a build of@tanstack/openai-base, andpnpm --dir packages/ai-openai run test:types. Both pass.vitest run --maxWorkers=2inpackages/openai-baseoncomputer-use-loop,provider-tool-dispatch,responses-text,replay-parity,tool-choice-wire, andresponses-empty-completed-output: 187 tests pass. Inpackages/ai-openai,tools-per-model-type-safetyandopenai-adapter: all pass.test:oxlintof both packages (no errors),oxfmt --checkon the changed files,kiira checkondocs/adapters/openai.md(45 snippets pass),pnpm test:docs(no broken links), andpnpm test:knip(exit 0).After the screenshot detail commit:
computer-use-loop(3 tests pass),test:typesofopenai-base, oxlint on the changed files (no errors), andoxfmt --checkon the changed files.After the merge of fix(openai-base): run the computer use loop #1831 (a computer result is now the only result that reads the screenshot):
computer-use-loop(4 tests),provider-tool-dispatch, andreplay-paritypass (72 tests), andtest:typesofopenai-basepasses.After the merge of the E2E commit of fix(openai-base): run the computer use loop #1831: the spec
openai-computer-use-wirenow also checks?tool=computer(the batched actions ongpt-6.1-sol) anddetail: 'original'on each screenshot. I type-checked the route, and ranoxfmt --checkand oxlint on the changed files.Not run locally:
pnpm test:pr, E2E, and coverage. CI runs them. I type-checked the new E2E route. The spec runs in CI.Manual test:
pnpm --dir packages/openai-base exec vitest run tests/computer-use-loop.test.ts.{ type: 'computer' }. The tool gets the two actions. The second request sends thecomputer_callwith the same actions and thecomputer_call_outputwith the screenshot.How this PR makes testing easy:
tests/computer-use-loop.test.tsruns both tool types throughchat()with a mock client.tests/provider-tool-dispatch.test.tschecks the wire shape of{ type: 'computer' }, andtools-per-model-type-safety.test.tschecks thatgpt-6.1-solaccepts it.testing/e2e/tests/openai-computer-use-wire.spec.tsruns both tool types through the real OpenAI SDK, against a customfetch.Risk / rollback
Low. The preview tool keeps its name, its wire shape, and its single
action. The API spec does not listdetailoncomputer_screenshot, but OpenAI's own samples send it. If the API rejects it, remove thedetailline inscreenshotOf. To undo all of it, revert this PR.Public API change
Before
After