Repository navigation
fix(chat): run Codex threads in the native sandbox workspace - #1089
Open
finallylly wants to merge 2 commits into
Open
finallylly wants to merge 2 commits into
finallylly wants to merge 2 commits into
Conversation
The Codex app-server adapter always sent cwd=<root>/ws on thread/start and thread/resume. On macOS seatbelt there is no mount namespace, so the runtime starts the CLI in the run workspace instead, and <root>/ws is not writable there. Codex then ran shell commands in the cache directory and relative writes such as git clone or mkdir failed with "Operation not permitted". Send cwd="." so the thread follows the process working directory chosen by the runtime for each sandbox. Platform mode, Docker, bwrap and runner execution still start the CLI in <root>/ws, so they are unchanged. The cwd is also sent on resume, because Codex otherwise keeps the directory recorded when the thread started.
Author
|
补充一下中文说明,方便 review: 问题:macOS 上使用 native(seatbelt)沙箱的 Codex 对话工作区无法写入当前目录, 原因:#947 已经让 seatbelt 下的 CLI 进程直接运行在 run workspace 中,但 Codex app-server 适配器在 修改:改为传 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
On macOS, a Codex conversation workspace using the native (seatbelt) sandbox could not write to its working directory. Relative commands such as
git cloneormkdirfailed withOperation not permitted, and the agent fell back to the system temp directory.The runtime already starts the CLI in the run workspace on seatbelt, because seatbelt cannot map
<root>/wsonto it (#947). The Codex app-server adapter, however, always sentcwd=<root>/wsonthread/startandthread/resume. Codex therefore ran shell commands in the conversation cache directory, which the seatbelt profile does not allow writing to.The adapter now sends
cwd: ".", so the thread follows the process working directory selected by the runtime for each sandbox. The cwd is also sent on resume: without it, Codex keeps the directory recorded when the thread started, so a platform-mode thread handed to a workspace would stay in<root>/ws.Scope
Compatibility
Only the Codex engine is affected. Its effective cwd changes only for macOS seatbelt workspaces. Platform mode, review-only calls, Docker, Linux bwrap and runner execution all start the CLI in
<root>/ws, so"."resolves to the same directory as before. A runner that predates the seatbelt working-directory change keeps its previous behavior. No schema or runner protocol changes.The fix relies on Codex resolving a relative
cwdagainst the app-server process directory. This was checked with Codex CLI 0.150.0, 0.169.0 and 0.170.0:thread/startandthread/resumewithcwd: "."both use the process directory, whilethread/resumewithoutcwdkeeps the originally recorded directory. Unit tests do not run a real Codex binary, so this should be rechecked when upgrading Codex.Validation
Run on macOS (Apple silicon).
Manual check on macOS with a native sandbox and Codex: in a new Codex conversation workspace,
pwdreports the run workspace, andmkdirandgit clonesucceed there without falling back to a temp directory.Safety