kosa8 docs Dashboard
esc
↑ ↓ move↵ openRuns in your browser; nothing you type is sent anywhere.

Guides / Agent frameworks / Codex CLI

Codex CLI

kosa8 agent run codex starts OpenAI's Codex CLI in a microVM of its own, from the built-in codex kit. It sees one folder at /work, reaches registry.npmjs.org and, through a broker on your computer, api.openai.com, and holds a placeholder instead of your OpenAI key.

How this page was checked

Against the built-in kit in kosa8's source (pkg/kit/kit.go, pkg/kit/hook.go) and the kosa8 agent run and kosa8 prompt commands, November 2026.

Run it#

$ curl -fsSL https://kosa8.com/install | sh
$ kosa8 daemon start
$ export OPENAI_API_KEY=sk-…
$ kosa8 agent run --dry-run -w ~/code/api codex
$ kosa8 agent run -w ~/code/api codex --sandbox danger-full-access --ask-for-approval on-request

Everything after the kit name is passed to Codex. The microVM is the boundary, so Codex's danger-full-access reaches one VM, not your computer.

One task, headless#

$ kosa8 prompt -a codex -w ~/code/api "why does TestLogin flake?"

This runs codex exec --skip-git-repo-check --dangerously-bypass-approvals-and-sandbox TASK in a fresh sandbox that is removed when it finishes. Codex's own sandbox needs kernel features the kosa8 guest does not give it, so the kosa8 sandbox is the boundary instead.

What the kit sets#

FieldValue
Imagenode:22-alpine
Package@openai/codex 0.162.1, checked against a pinned digest
Workspacethe current directory, or -w DIR, at /work
Networkregistry.npmjs.org; api.openai.com through the broker
CredentialsOPENAI_API_KEY, brokered; the sandbox gets OPENAI_BASE_URL (the broker's /v1) and a placeholder
Hookkosa8's hook as a managed Codex PreToolUse hook on every tool (allow_managed_hooks_only)
Skills folder$HOME/.agents/skills
Size4 vCPUs, 4096 MB

The flags are the same as for any kit: -w, --no-network, --keep, --name, --dry-run and --skill. kosa8 agent init codex writes the kit to ~/.kosa8/kits/codex.yaml for you to edit; see Writing a kit.

Check where it went#

$ kosa8 audit ls
$ kosa8 sandbox egress NAME     # a running sandbox's rule and its refusals

Keep Codex local, with cloud sandboxes#

To keep Codex on your machine and send only its sandbox commands to kosa8 Cloud, add the cloud MCP server to ~/.codex/config.toml:

[mcp_servers.kosa8-cloud]
url = "https://api.kosa8.com/mcp"
bearer_token_env_var = "KOSA8_API_KEY"

For kosa8's checks on a Codex that runs on your own machine, see Agent hooks.

What it does not cover#

  • The shared folder: Codex can change anything in it, including .git. Commit first.
  • What it sends to the hosts it can reach, including your code to the model.
  • The placeholder is a capability: anything in the sandbox can spend the key through the broker.
  • kosa8 does not detect or stop prompt injection; it limits what an injected instruction can reach.

The overview with FAQs is on kosa8.com: Run Codex CLI in a microVM sandbox.

Something wrong or missing? Write to contact@kosa8.com.

The kosa8 newsletter

A short daily email with that day's article and one tip. Switch to weekly or unsubscribe in one click.

© 2026 kosa8 · kosa8.com · Zero Trust cybersecurity infrastructure for AI agents · Local models served by llamay · Agent gateway: MAQPNA