Skip to content

feat: add cleanroom agent codex shortcut#58

Open
lox wants to merge 3 commits into
mainfrom
codex/agent-codex-shortcut
Open

feat: add cleanroom agent codex shortcut#58
lox wants to merge 3 commits into
mainfrom
codex/agent-codex-shortcut

Conversation

@lox
Copy link
Copy Markdown
Contributor

@lox lox commented Mar 1, 2026

Summary

This adds a first-class cleanroom agent command for running coding agents inside a Cleanroom sandbox.

Agent sessions use the repository's normal Cleanroom environment: the cleanroom.yaml sandbox image, backend, repository bootstrap, network policy, and interactive console transport. The command keeps newly created sandboxes by default so agents can retain workspace state after the session.

This also adds runtime-configured agent commands and credential copying.

How to use it

Run a built-in agent in a new sandbox from the current repository policy:

cleanroom agent codex -- exec --yolo "fix the failing tests"
cleanroom agent claude
cleanroom agent gemini
cleanroom agent opencode
cleanroom agent --dangerously-allow-all codex -- exec "summarize the repo"

Pass agent arguments after the agent name. A leading -- is stripped when present, so both of these are valid:

cleanroom agent codex -- exec "summarize the repo"
cleanroom agent codex exec "summarize the repo"

Run an agent in an existing sandbox:

cleanroom agent --sandbox-id cr_123 codex -- exec "inspect the current tree"

Configured custom agents are added to the cleanroom agent <agent> enum alongside the built-ins.

What it does

cleanroom agent:

  • resolves or creates a sandbox using the same policy path as cleanroom console
  • runs the selected agent through the interactive console path
  • can disable egress filtering for newly created sandboxes with --dangerously-allow-all
  • keeps newly created sandboxes after the agent exits
  • copies configured credential paths into the sandbox before attaching the agent
  • passes through agent arguments safely by shell-quoting them before appending to the configured command

The built-in agent commands first use an agent binary already present in the sandbox image. If the binary is missing, they fall back to mise-managed Node.js plus the npm package, for example:

mise --no-config exec -y nodejs@lts -- npm exec --yes --package @openai/codex@latest -- codex

That means plain Debian-based Cleanroom images can run agents once they contain the required runtime libraries and the policy allows the package manager/network hosts needed by mise, Node.js, npm, and the agent itself. Images that already include agent binaries skip the fallback path.

Runtime config

cleanroom config init emits agent configuration with default commands and credential mappings. The generated commands are shell snippets; the Codex default is representative:

agents:
  codex:
    command: sh -lc 'if command -v codex >/dev/null 2>&1; then exec codex "$@"; fi; exec env MISE_YES=1 MISE_TRUSTED_CONFIG_PATHS=/workspace mise --no-config exec -y nodejs@lts -- npm exec --yes --package @openai/codex@latest -- codex "$@"' sh
    test: command -v codex >/dev/null 2>&1 || command -v mise >/dev/null 2>&1
    credentials:
      - source: ~/.codex/auth.json
        target: ~/.codex/auth.json
      - source: ~/.codex/config.toml
        target: ~/.codex/config.toml

command, test, and optional install are shell snippets. If install is configured, Cleanroom runs it only when test fails. Built-in defaults do not need install because they either use an existing binary or run the mise fallback.

Credential behavior

Credential entries are explicit runtime config mappings. Each source is read from the host, packaged into a tar archive, copied into the sandbox with the sandbox archive extraction API, and extracted at target before the agent starts.

When copying Codex config, Cleanroom preserves the host config.toml content and adds /workspace as a trusted project in the sandbox copy.

Missing credential paths are skipped. Copied credentials remain in a kept sandbox until that sandbox is terminated.

Testing

  • mise exec -- go test ./internal/cli
  • mise exec -- go test ./...
  • mise exec -- go run ./cmd/cleanroom agent --help

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 685a17d4bb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/endpoint/endpoint.go
Comment thread internal/cli/cli.go Outdated
@lox lox force-pushed the codex/agent-codex-shortcut branch from 685a17d to abcb6dd Compare March 1, 2026 04:54
@lox
Copy link
Copy Markdown
Contributor Author

lox commented Mar 1, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lox lox force-pushed the codex/agent-codex-shortcut branch from 51d529f to f4f062b Compare March 1, 2026 22:05
@lox lox force-pushed the codex/agent-codex-shortcut branch 3 times, most recently from c6efef4 to 4ae68fe Compare March 14, 2026 06:34
@lox lox force-pushed the codex/agent-codex-shortcut branch 7 times, most recently from e677214 to fedf12d Compare April 26, 2026 21:08
@lox
Copy link
Copy Markdown
Contributor Author

lox commented Apr 26, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fedf12d66e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/cli/agent.go
Comment on lines +189 to +193
if info.Mode()&os.ModeSymlink != 0 {
var err error
link, err = os.Readlink(source)
if err != nil {
return fmt.Errorf("read agent credential symlink %q: %w", source, err)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Dereference symlinked credentials before archiving

This path preserves symlinks instead of copying their contents, so a credential source that is a symlink (common with dotfile managers) is extracted into the sandbox as the same link target rather than usable file bytes. If that link points outside the copied tree (for example an absolute host path), the sandbox gets a dangling credential path and agent auth fails even though the source existed on the host.

Useful? React with 👍 / 👎.

Comment thread internal/cli/agent.go
Comment on lines +74 to +76
test := strings.TrimSpace(spec.Test)
if test == "" {
test = "command -v " + shellQuote(name) + " >/dev/null 2>&1"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Base default command check on configured command

When an agent defines command but omits test, the fallback check still hardcodes command -v <agent name>. That makes valid custom commands fail the preflight check (for example absolute paths or wrapper invocations where <agent name> is not on PATH), causing an unnecessary exit 127 before exec would have worked.

Useful? React with 👍 / 👎.

@lox lox force-pushed the codex/agent-codex-shortcut branch 11 times, most recently from a9ab404 to d748193 Compare April 27, 2026 08:02
lox added 2 commits April 27, 2026 18:41
Provide a first-class  entrypoint so common agent workflows do not require manually composing sandbox and console commands.

This keeps the implementation backend-neutral by reusing existing console execution semantics while adding parser and integration coverage for command passthrough and persistent sandbox behavior.
Generalize the agent command passthrough, default newly created agent sandboxes to the agents image, prefer a locally built alpine-agents image on local control planes, and document the current device-auth flow. Also bring up guest loopback so localhost auth listeners can bind inside the sandbox.
@lox lox force-pushed the codex/agent-codex-shortcut branch 4 times, most recently from 71530a9 to e6cf2e1 Compare April 27, 2026 09:10
@lox lox force-pushed the codex/agent-codex-shortcut branch from e6cf2e1 to 4a8288d Compare April 27, 2026 09:16
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