Skip to content

fix: rebuild bwrap sandbox after cwd change - #22

Merged
zhanghanduo merged 1 commit into
ApodexAI:mainfrom
Ray0907:fix/bwrap-cwd-cache
Aug 28, 2026
Merged

fix: rebuild bwrap sandbox after cwd change#22
zhanghanduo merged 1 commit into
ApodexAI:mainfrom
Ray0907:fix/bwrap-cwd-cache

Conversation

@Ray0907

@Ray0907 Ray0907 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • key the cached Bubblewrap sandbox by its resolved workspace
  • rebuild the jail after /cwd switches to a different workspace
  • clean up the retired sandbox and cover reuse, replacement, and cleanup with a regression test

Background

_get_bwrap_sandbox() previously cached one process-wide jail. After /cwd changed the session workspace, later shell commands reused a jail whose writable bind still pointed at the original directory.

Validation

  • uv run pytest -q — 1722 passed
  • uv run ruff check frontier_agent/ apodex/ benchmarks/ workflows/ plugins/ deploy/ tools/ scripts/
  • uv run pyright — 0 errors
  • git diff --check

@zhanghanduo zhanghanduo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The fix correctly rebuilds the cached Bubblewrap sandbox after /cwd switches to a different workspace, while preserving reuse for equivalent paths and cleaning up the retired sandbox. The regression test covers the expected behavior well. LGTM!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes an issue where the Bubblewrap (bwrap) sandbox instance was cached process-wide and incorrectly reused after the session working directory changed, causing writable binds to point at the wrong workspace.

Changes:

  • Key the cached bwrap sandbox by the resolved cwd and rebuild it when the resolved workspace changes.
  • Dispose of the previously cached sandbox when replacing it.
  • Add a regression test covering reuse for equivalent paths, replacement on workspace change, and cleanup behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
apodex/sandbox.py Cache bwrap sandbox by resolved workspace and rebuild/cleanup when cwd switches.
apodex/tests/test_native.py Add regression test ensuring sandbox reuse for the same workspace and rebuild on workspace change.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread apodex/sandbox.py
@zhanghanduo
zhanghanduo merged commit 2b82a43 into ApodexAI:main Aug 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants