Repository navigation
feat(dev): opt-in Codex login for sandbox VMs - #4756
Merged
Merged
Conversation
The Codex kit seeds ~/.codex once, at VM creation, from the host's OpenAI secret. A VM created without one has no Codex login until it is recreated. `dev/sbx/sandbox start` now runs Docker's host-side OAuth flow before creating a VM when no global OpenAI secret exists. The README documents the ChatGPT path as the default and the API-key path as the alternative. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TBX7J21wEKRkvxUkk1tEdp
Contributor
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — The new --codex option provisions host-side OAuth before VM creation, with failure checks and added tests. Human review must confirm the intended global credential scope, which lets local Codex-kit sandboxes use the developer’s ChatGPT subscription. You can add or adjust custom eligibility rules. Learn more. |
The OpenAI OAuth secret is global, so creating it on every VM creation was too broad. `start --codex` now opts in; a plain `start` never reads or creates an OpenAI secret. The Codex CLI stays in every VM. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TBX7J21wEKRkvxUkk1tEdp
A failed or malformed `sbx secret ls` no longer counts as "no secret", so it cannot start the global OAuth flow. `--api-key` values are checked while parsing options, before any VM is created, so an option such as `--codex` cannot be taken as a key's host or placeholder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TBX7J21wEKRkvxUkk1tEdp
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.
Summary
Adds opt-in Codex login for the Docker Sandboxes VM. With
dev/sbx/sandbox start --codex, Codex in the VM uses the host's ChatGPT subscription, and the OAuth tokens never enter the VM. Every VM still has the Codex CLI installed. A plainstartnever reads or creates an OpenAI secret.Before: the Codex kit writes
~/.codex/config.tomlandauth.jsononce, at VM creation, from whatever OpenAI secret the host has at that moment. The wrapper had no way to set one up, so a VM created without it had no Codex login. Fixing that meant destroying and recreating the VM.After:
start --codexchecks for a global OpenAI secret before creating a VM. If there is none, it runssbx secret set openai --oauth, Docker's host-side ChatGPT sign-in. The kit then seeds Codex with theoai-oat01-proxy-managedsentinel, and the sandbox proxy swaps in the real token on requests tochatgpt.com. If sign-in fails, or the secret lookup fails or returns malformed output,startstops before creating anything.--api-keyvalues are format-checked while parsing options, so a bad key also stopsstartbefore the VM exists. On an existing VM,--codexonly prints a note, because the login is fixed at creation.sbxenv.yamlcan't do this alone. Env-filesecrets:supportvalue,ref, orcommandsources but not OAuth, andbindings:only approve injection domains (which the file already declares foropenai).The README documents
--codex, the recreate step for VMs created without it, and the API-key alternative with its existing isolation caveat. It also notes that the OAuth secret is global: once it exists, a VM created without--codexstill gets Codex login until the secret is removed withsbx secret rm openai.Verification
dev/nix-shell 'python3.11 -B dev/sbx/test_sandbox.py': 20 tests pass, using the fakesbx, never a live VM.startneither reads nor creates an OpenAI secret;--codex(mixed with--api-key) signs in beforeenv runand still registers keys;--codexskips sign-in when a global secret or the VM already exists;--api-keyvalues (including--codexin a value slot) create nothing.main, the--codextests fail. Against a version that always signs in, the plain-start test also fails.just lint-config,just lint-markdown,just lint-treefmt, andshellcheck dev/sbx/sandboxpass.Follow-ups
.secretsfromsbx secret ls --global --service openai --json(sbx 0.50). I could not see how an OAuth entry is listed without creating one. If OAuth secrets are listed elsewhere, the only effect is thatstart --codexasks for sign-in again when it creates a VM.🤖 Generated with Claude Code
https://claude.ai/code/session_01TBX7J21wEKRkvxUkk1tEdp
Note
Add opt-in Codex login to
sandboxstartvia--codexstartnow accepts a--codexflag plus repeated--api-key HOST PLACEHOLDERoptions, parsed and validated before VM creation in sandboxstart --codexruns host-side OAuth setup (sbx secret set openai --oauth) before creating the VM; on failure, nothing is created. If the VM already exists, the current login is keptvalidate_keyhelper used by both parsing and registrationMacroscope summarized 3c8f06a.