Skip to content

Let the caller choose Codex's sandbox (CODEX_COMPANION_THREAD_CONFIG) - #1

Merged
johannestreutlein merged 8 commits into
mainfrom
sandbox-from-config
Oct 28, 2026
Merged

johannestreutlein merged 8 commits into
mainfrom
sandbox-from-config

Conversation

@johannestreutlein

Copy link
Copy Markdown

Lets the caller choose the Codex sandbox of a run, so that the research plugin's research-codex can give GPT reviews and tasks a sandbox in which they can run tests, uv run and scripts, while the reviewed repository stays read-only. FORK.md describes every difference from upstream.

  • CODEX_COMPANION_THREAD_CONFIG (JSON keyed by the sandbox mode a command would use): thread/start and thread/resume send that Codex config instead of sandbox, approvalPolicy and cwd. Each such run starts its own codex app-server (no shared broker) in its own process group, and stops before its first turn unless Codex reports the requested permission profile. Bad JSON or a missing entry stops the run.
  • cancel: a run interrupts its own turn on SIGTERM and kills the processes below its app-server; the kill helper also signals a run that leads no process group, after checking that the pid still runs one of the plugin's scripts.
  • plugin.json has no version, so each commit of the fork installs as an update (Claude Code compares version strings).
  • README points to the fork's install commands.

Without the variable, behavior is upstream's, apart from the kill-helper fallback.

Tests: npm test (upstream's suite plus tests/fork-thread-config.test.mjs), npm run build. Merge together with the upstream-sync PR, which FORK.md describes.

🤖 Generated with Claude Code

johannestreutlein and others added 8 commits October 28, 2026 21:21
With CODEX_COMPANION_THREAD_CONFIG set, thread/start and thread/resume send the
caller's Codex config for the run's mode instead of sandbox, approvalPolicy and
cwd; each run starts its own app-server (no shared broker); and a run whose
active permission profile is not the requested one stops before its first
turn. plugin.json has no version, so each fork commit installs as an update.
FORK.md says what differs from upstream.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without a broker, `cancel` sent its turn interrupt to a fresh app-server that
does not hold the run's thread, and its kill did nothing for a run that leads
no process group (ESRCH), so runs went on. Now a run with
CODEX_COMPANION_THREAD_CONFIG set interrupts its own turn and closes its
app-server on SIGTERM/SIGINT, and the kill helper also signals the process
itself when its process group is not found.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…or detached delivery)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e plugin's own pids

Codex's turn interrupt leaves commands running in the background, and on
Linux its sandbox keeps them alive when the app-server dies, so the run now
lists the processes below its app-server before it interrupts the turn and
kills them afterwards. The kill helper's fallback for a pid that leads no
process group now checks that the pid still runs one of this plugin's
scripts, since a stale pid may belong to another program.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the run leads its process group (started with setsid), cancel's group
signal reached the app-server at the same moment, and Codex tore down its outer
sandbox processes before the run could list the command below them, which then
survived. With the app-server in its own group, the signal reaches only the run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@johannestreutlein
johannestreutlein merged commit 1c6211c into main Oct 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.

1 participant