Skip to content

fix(computer): exclude Computer instances from provider duck-typing#3249

Merged
seratch merged 1 commit intoopenai:mainfrom
adityasingh2400:fix/computer-provider-isinstance-check
May 8, 2026
Merged

fix(computer): exclude Computer instances from provider duck-typing#3249
seratch merged 1 commit intoopenai:mainfrom
adityasingh2400:fix/computer-provider-isinstance-check

Conversation

@adityasingh2400
Copy link
Copy Markdown
Contributor

Summary

_is_computer_provider in src/agents/tool.py checks for ComputerProvider via isinstance or any object that exposes a callable create attribute. A user-defined Computer/AsyncComputer subclass that happens to define a create method (e.g. an internal helper named create_window, create_session, etc., or any helper named create) is misclassified as a provider.

When this happens, resolve_computer enters the provider branch and crashes:

AttributeError: 'MyComputer' object has no attribute 'dispose'

at disposer: ComputerDispose[Any] | None = lifecycle.dispose if lifecycle else None.

Fix

Short-circuit _is_computer_provider for already-resolved Computer | AsyncComputer instances — they are never providers, regardless of whether a subclass exposes a create attribute.

Test plan

  • New regression test test_resolve_computer_with_create_attribute_returns_instance fails on main with AttributeError and passes with the fix.
  • Existing 37 computer-tool tests still pass (tests/test_computer_tool_lifecycle.py, tests/test_computer_action.py).

`_is_computer_provider` returned True for any object with a callable
`create` attribute. A `Computer`/`AsyncComputer` subclass that happens
to define a `create` method (e.g. a user helper) was misclassified as
a `ComputerProvider`, causing `resolve_computer` to fail with
`AttributeError: ... has no attribute 'dispose'`.

Short-circuit by treating resolved computer instances as non-providers.
@github-actions github-actions Bot added bug Something isn't working feature:core labels May 8, 2026
@seratch
Copy link
Copy Markdown
Member

seratch commented May 8, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

ℹ️ 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".

@seratch seratch added this to the 0.17.x milestone May 8, 2026
@seratch seratch merged commit e86dff2 into openai:main May 8, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feature:core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants