Skip to content

fix: #2938 make agents.sandbox.sandboxes importable on Windows#2937

Closed
DhanushKenkiri wants to merge 3 commits intoopenai:mainfrom
DhanushKenkiri:fix/windows-sandboxes-import
Closed

fix: #2938 make agents.sandbox.sandboxes importable on Windows#2937
DhanushKenkiri wants to merge 3 commits intoopenai:mainfrom
DhanushKenkiri:fix/windows-sandboxes-import

Conversation

@DhanushKenkiri
Copy link
Copy Markdown

@DhanushKenkiri DhanushKenkiri commented Apr 18, 2026

PR Description

  • Problem: On Windows, import agents.sandbox.sandboxes fails with ModuleNotFoundError: fcntl because the package eagerly imports the Unix-only unix_local backend (which depends on Unix-only stdlib like fcntl/termios).
  • Change:
    • Guard unix_local imports in src/agents/sandbox/sandboxes/init.py so the sandboxes package can be imported on Windows even when the Unix backend is unavailable.
    • Add an explicit, user-facing ImportError in src/agents/sandbox/sandboxes/unix_local.py when imported on Windows (clearer than the current ModuleNotFoundError).
    • Add regression tests in tests/sandbox/test_sandboxes_imports.py.
  • Why this approach: unix_local is inherently Unix-only; the SDK should stay importable cross-platform and only fail when a platform-incompatible backend is explicitly imported/used.
  • Tests: python -m pytest -q tests/sandbox/test_sandboxes_imports.py

Fixes #2938

@github-actions github-actions bot added bug Something isn't working feature:sandboxes labels Apr 18, 2026
@DhanushKenkiri DhanushKenkiri changed the title fix: avoid unix_local import on Windows make agents.sandbox.sandboxes importable on Windows Apr 18, 2026
@DhanushKenkiri DhanushKenkiri changed the title make agents.sandbox.sandboxes importable on Windows fix: make agents.sandbox.sandboxes importable on Windows Apr 18, 2026
Copy link
Copy Markdown
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you resolve the lint errors?

@seratch seratch added this to the 0.14.x milestone Apr 18, 2026
@seratch seratch changed the title fix: make agents.sandbox.sandboxes importable on Windows fix: #2938 make agents.sandbox.sandboxes importable on Windows Apr 18, 2026
@DhanushKenkiri
Copy link
Copy Markdown
Author

Working on the lint error, the error is due to ruff format --check says it “would reformat” src/agents/sandbox/sandboxes/init.py. Next I’ll install the pinned Ruff version locally, run ruff format on the touched files, commit the formatting-only change, and push so the GitHub Action passes.

@DhanushKenkiri DhanushKenkiri requested a review from seratch April 18, 2026 13:58
@seratch
Copy link
Copy Markdown
Member

seratch commented Apr 18, 2026

Thanks for sending this patch. Let us close it in favor of #2948

@seratch seratch closed this Apr 18, 2026
@seratch seratch removed this from the 0.14.x milestone Apr 18, 2026
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:sandboxes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: import agents.sandbox.sandboxes fails with ModuleNotFoundError: fcntl

2 participants