How to add a Codex agent in an sbx sandbox
This guide shows how to add Codex (OpenAI's coding agent, through its ACP adapter codex-acp) as a Sidekicks agent that runs inside a Docker sandbox (sbx). Codex then works in its own folder, isolated from the rest of your computer, and Sidekicks shows its files and a terminal like for any other agent. It assumes sbx is installed and that you have a ChatGPT account or an OpenAI API key. It follows the same steps as How to add a Claude agent in an sbx sandbox.
A ready-made example is in the repository: agents/snippets/codex-acp.
A kit provided by a third party
The sandbox is built from the docker.io/sbx/codex-acp kit. This kit is provided by a third party, not by Sidekicks: what it contains (Codex, codex-acp), its updates (the sandbox pulls latest each time it is created) and whether it stays available depend on that third party. Sidekicks only creates the sandbox from the sbxenv.yaml that names it and starts codex-acp inside it. If the kit changes or disappears, the sandbox may no longer be created, or Codex may no longer start: the Log tab then shows what sbx said.
What you need
| Role | |
|---|---|
A folder for the agent, e.g. /Users/me/agents/codex-acp |
holds the sandbox's sbxenv.yaml and the workspace/ folder Codex works in. |
The docker.io/sbx/codex-acp kit |
the sandbox's image, with Codex and codex-acp installed. |
| Your OpenAI credentials, stored in sbx | sbx adds them to Codex's requests to OpenAI: they are written neither in the sandbox nor in Sidekicks' configuration. |
With the assistant
-
Prepare the folder: copy
agents/snippets/codex-acp(itssbxenv.yamlandworkspace/) to where the agent will live, e.g./Users/me/agents/codex-acp. Changename:in thesbxenv.yamlif you want another sandbox name. -
Give your OpenAI credentials to sbx, before the sandbox is created: the
codexkit reads them when the sandbox is created.sbx secret set -g openai --oauth # sign in with your ChatGPT account echo "$OPENAI_API_KEY" | sbx secret set -g openai # or: an API keyIf you store them after the sandbox exists, 🗑 Remove the sandbox in the agent's header, then start the agent again.
-
In the Agents panel, click + Add an agent. Fill in Name shown (
Codex) and, if you like, an icon (📗). -
Where does it run? Choose In an sbx sandbox, then drop the
sbxenv.yamlon Recreate the sandbox when it is gone (optional) (or click Choose an sbxenv.yaml…). The sandbox, the agent's folder (…/workspace) and thesbx envcommands are filled in from it. -
Program:
codex-acpis chosen for you, fromagent: codexin thesbxenv.yaml(otherwise choose it in the list; it is offered in an sbx sandbox only). Leave Arguments empty. -
Click Add the agent, then start Codex from the Agents panel (▶), or write to it. The first time, the Log tab shows
sandbox codex-acp not found: creating it, then the kit being pulled — this can take a minute or two.
By hand
The sbxenv.yaml of the example:
schemaVersion: "1"
name: codex-acp
agent: codex
workspace: ./workspace
kits:
- docker.io/sbx/codex-acp:latest
bindings:
openai:
apiKey:
domains:
- api.openai.com
- openai.com
oauth:
domains:
- auth.openai.com
- chatgpt.com
And the agent's entry, under agents: in Settings:
- name: codex
title: Codex
icon: "📗"
command: sbx
args: [exec, -i, codex-acp, codex-acp]
workspace: /Users/me/agents/codex-acp/workspace
runtime:
type: sbx
sandbox: codex-acp
lifecycle:
folder: /Users/me/agents/codex-acp
create: [sbx, env, create, --force]
stop: [sbx, stop, codex-acp]
remove: [sbx, env, rm, --force]
workspace is the folder Codex works in, on this computer; sbx shares it with the sandbox at the same path. lifecycle.folder is the folder of the sbxenv.yaml, where the sbx env commands run. The sandbox name must be the same in name:, args, runtime.sandbox and lifecycle.stop.
Check that it works
- Ask Codex to write a file, e.g. "Write
notes/hello.mdwith a greeting". The file appears in the agent's Files tab (📂) and in/Users/me/agents/codex-acp/workspaceon this computer. - When Codex asks for permission to change a file or run a command, Sidekicks shows the request and waits for your answer.
cannot mix v3 kits with v1/v2 kits in one sandboxwhen the sandbox is created: thesbxenv.yamlnames the olderdocker.io/sbx/codex-acp-kit. sbx now gives thecodexagent as a kit of the new format (v3), which only composes with v3 kits: namedocker.io/sbx/codex-acp:latestinstead, then start the agent again.executable file … codex-acp not found(exit status 127): the agent runs in another sandbox — the log then shows another sandbox being started, such asclaude-acp. The assistant now refuses ansbxenv.yamlwhoseagent:is not the program's; in Settings, check that the sandbox name iscodex-acpinargs,runtime.sandboxandlifecycle, and thatworkspaceandlifecycle.folderare Codex's folders.executable file `/home/agent/.local/bin/codex-acp` not foundwith the right sandbox: the agent's entry was made for the olderdocker.io/sbx/codex-acp-kit. The v3 kit putscodex-acpin thePATH: writecodex-acpalone as the last argument.- An authentication error in the Log tab: the credentials are not stored in sbx, or were stored after the sandbox was created. Store them again, then 🗑 Remove the sandbox and start the agent.
See also
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|