Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion internal/httpapi/assistant_engine_codex.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,13 @@ func (s *codexAppServer) response(message codexRPCMessage) []string {
// App-server builds each thread's hook trust from its own config.
// Both the platform guard and workspace approval hook are generated
// and reviewed by the platform.
params := map[string]any{"developerInstructions": s.opts.SystemPrompt, "sandbox": "read-only", "approvalPolicy": "never", "cwd": filepath.Join(s.opts.Root, "ws"), "config": map[string]any{"bypass_hook_trust": true}}
// The runtime starts the CLI in its per-sandbox working directory:
// <root>/ws in platform mode, Docker and bwrap, but the run workspace
// itself on macOS seatbelt, which cannot map <root>/ws. A relative cwd
// resolves against that directory. It must be sent on resume too:
// without it Codex keeps the cwd recorded when the thread started, so a
// platform-mode thread handed to a workspace would stay in <root>/ws.
params := map[string]any{"developerInstructions": s.opts.SystemPrompt, "sandbox": "read-only", "approvalPolicy": "never", "cwd": ".", "config": map[string]any{"bypass_hook_trust": true}}
if s.opts.Model != "" {
params["model"] = s.opts.Model
}
Expand Down
10 changes: 10 additions & 0 deletions internal/httpapi/assistant_engine_codex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ func TestCodexAppServerTurn(t *testing.T) {
if config, _ := start.Params["config"].(map[string]any); config["bypass_hook_trust"] != true {
t.Fatalf("platform denial hook not trusted by thread: %+v", start)
}
// The runtime picks the working directory per sandbox (the run workspace
// on macOS seatbelt); the thread must follow it, not <root>/ws.
if start.Params["cwd"] != "." {
t.Fatalf("thread/start cwd must follow the process working directory: %+v", start.Params["cwd"])
}
if out := inv.translate(`{"id":2,"result":{"thread":{"id":"019a-thread"}}}`); len(out) != 1 || !strings.Contains(out[0], `"session_id":"019a-thread"`) {
t.Fatalf("thread started: %v", out)
}
Expand Down Expand Up @@ -240,6 +245,11 @@ func TestCodexAppServerResume(t *testing.T) {
if config, _ := m.Params["config"].(map[string]any); config["bypass_hook_trust"] != true {
t.Fatalf("resumed thread lost denial hook trust: %+v", m)
}
// Without an explicit cwd Codex resumes in the directory recorded when the
// thread started, so a thread handed to a seatbelt workspace stays in <root>/ws.
if m.Params["cwd"] != "." {
t.Fatalf("thread/resume cwd must override the recorded directory: %+v", m.Params["cwd"])
}
// A thread the server cannot load reads as a missing session.
out := inv.translate(`{"id":2,"error":{"code":-32600,"message":"no rollout found for thread id 019a-old"}}`)
if len(out) != 1 || !strings.Contains(out[0], "No conversation found with session ID: 019a-old") {
Expand Down