bots-garden/sidekickspublic Fork
⑂ v1.6.0
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/sidekicks.git
git clone ssh://git@rickub.com/bots-garden/sidekicks.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP
add-a-codex-agent-in-a-sandbox.md · 96 lines · 6.0 KBmarkdown
Blame HistoryOpen raw

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

  1. Prepare the folder: copy agents/snippets/codex-acp (its sbxenv.yaml and workspace/) to where the agent will live, e.g. /Users/me/agents/codex-acp. Change name: in the sbxenv.yaml if you want another sandbox name.

  2. Give your OpenAI credentials to sbx, before the sandbox is created: the codex kit 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 key
    

    If you store them after the sandbox exists, 🗑 Remove the sandbox in the agent's header, then start the agent again.

  3. In the Agents panel, click + Add an agent. Fill in Name shown (Codex) and, if you like, an icon (📗).

  4. Where does it run? Choose In an sbx sandbox, then drop the sbxenv.yaml on Recreate the sandbox when it is gone (optional) (or click Choose an sbxenv.yaml…). The sandbox, the agent's folder (…/workspace) and the sbx env commands are filled in from it.

  5. Program: codex-acp is chosen for you, from agent: codex in the sbxenv.yaml (otherwise choose it in the list; it is offered in an sbx sandbox only). Leave Arguments empty.

  6. 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.md with a greeting". The file appears in the agent's Files tab (📂) and in /Users/me/agents/codex-acp/workspace on 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 sandbox when the sandbox is created: the sbxenv.yaml names the older docker.io/sbx/codex-acp-kit. sbx now gives the codex agent as a kit of the new format (v3), which only composes with v3 kits: name docker.io/sbx/codex-acp:latest instead, 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 as claude-acp. The assistant now refuses an sbxenv.yaml whose agent: is not the program's; in Settings, check that the sandbox name is codex-acp in args, runtime.sandbox and lifecycle, and that workspace and lifecycle.folder are Codex's folders.
  • executable file `/home/agent/.local/bin/codex-acp` not found with the right sandbox: the agent's entry was made for the older docker.io/sbx/codex-acp-kit. The v3 kit puts codex-acp in the PATH: write codex-acp alone 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
# 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](add-a-claude-agent-in-a-sandbox.md).

A ready-made example is in the repository: [`agents/snippets/codex-acp`](../../../agents/snippets/codex-acp/README.md).

## 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

1. **Prepare the folder**: copy [`agents/snippets/codex-acp`](../../../agents/snippets/codex-acp/) (its `sbxenv.yaml` and `workspace/`) to where the agent will live, e.g. `/Users/me/agents/codex-acp`. Change `name:` in the `sbxenv.yaml` if you want another sandbox name.
2. **Give your OpenAI credentials to sbx**, before the sandbox is created: the `codex` kit reads them when the sandbox is created.

   ```bash
   sbx secret set -g openai --oauth                  # sign in with your ChatGPT account
   echo "$OPENAI_API_KEY" | sbx secret set -g openai # or: an API key
   ```

   If you store them after the sandbox exists, **🗑 Remove the sandbox** in the agent's header, then start the agent again.
3. In the **Agents** panel, click **+ Add an agent**. Fill in **Name shown** (`Codex`) and, if you like, an icon (📗).
4. **Where does it run?** Choose **In an sbx sandbox**, then drop the `sbxenv.yaml` on **Recreate the sandbox when it is gone (optional)** (or click **Choose an sbxenv.yaml…**). The sandbox, the agent's folder (`…/workspace`) and the `sbx env` commands are filled in from it.
5. **Program**: `codex-acp` is chosen for you, from `agent: codex` in the `sbxenv.yaml` (otherwise choose it in the list; it is offered in an sbx sandbox only). Leave **Arguments** empty.
6. 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:

```yaml
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**:

```yaml
  - 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.md` with a greeting". The file appears in the agent's **Files** tab (📂) and in `/Users/me/agents/codex-acp/workspace` on 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 sandbox`** when the sandbox is created: the `sbxenv.yaml` names the older `docker.io/sbx/codex-acp-kit`. sbx now gives the `codex` agent as a kit of the new format (v3), which only composes with v3 kits: name `docker.io/sbx/codex-acp:latest` instead, 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 as `claude-acp`. The assistant now refuses an `sbxenv.yaml` whose `agent:` is not the program's; in **Settings**, check that the sandbox name is `codex-acp` in `args`, `runtime.sandbox` and `lifecycle`, and that `workspace` and `lifecycle.folder` are Codex's folders.
- **``executable file `/home/agent/.local/bin/codex-acp` not found``** with the right sandbox: the agent's entry was made for the older `docker.io/sbx/codex-acp-kit`. The v3 kit puts `codex-acp` in the `PATH`: write `codex-acp` alone 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

- [How to add a Claude agent in an sbx sandbox](add-a-claude-agent-in-a-sandbox.md)
- [How to run an agent in an sbx sandbox](run-an-agent-in-a-sandbox.md)
- [How to add an agent](add-an-agent.md)