Codex CLI config.toml: The Complete Guide to Models, Approvals, MCP and Layered Config
Codex CLI centers on ~/.codex/config.toml: model picks the model, approval_policy gates prompts, sandbox_mode sets boundaries, mcp_servers wires tools, profiles switch scenarios.
How to
Create the file
Create or edit ~/.codex/config.toml; project overrides live in <repo>/.codex/config.toml.
Pick model and behavior
Write model = "gpt-6-astra" and optionally model_reasoning_effort and model_verbosity.
Set the safety boundary
Write sandbox_mode = "workspace-write" and approval_policy = "on-request" (use "never" for unattended runs).
Wire MCP (optional)
Add a [mcp_servers.<name>] table with command/args or url — see our MCP config guide for the full field list.
Codex CLI's behavior centers on ~/.codex/config.toml — one TOML file deciding which model it runs, what files it may touch, which tools it can call, and when it stops to ask. This guide maps the keys as defined by the ConfigToml struct in the codex-rs source rather than folklore.
1. File locations and layering
- User level:
~/.codex/config.toml— global defaults - Project level:
.codex/config.tomlat the repo root — overrides same-named keys - Admin level:
requirements.toml— managed/mandatory constraints (e.g.allow_managed_hooks_only = truemakes user and project hook configs inert, keeping only managed hooks)
The layering means: personal preferences go user-level, project rules go project-level (and into git), enterprise policy goes into requirements.toml.
2. Model and reasoning keys
model = "gpt-6-astra"
model_provider = "openai"
model_reasoning_effort = "high"
model_verbosity = "medium"
model— the model namemodel_provider— a key into the[model_providers]table, which can register custom providers for alternate channelsmodel_reasoning_effort— reasoning depthmodel_reasoning_summary/model_verbosity— reasoning summary style and output verbositymodel_context_window/model_auto_compact_token_limit— context window and auto-compaction thresholds (rarely needed)
3. The two safety axes
sandbox_mode = "workspace-write"
approval_policy = "on-request"
sandbox_mode governs filesystem and network boundaries (read-only / workspace-write / external-sandbox / danger-full-access); approval_policy governs when the agent asks (on-request / on-failure / granular / never). See our sandbox guide for the full semantics — the point here is they are independent and combine; there is no single master switch.
4. MCP and profiles
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
[profiles.ci]
model = "gpt-6-astra"
approval_policy = "never"
sandbox_mode = "workspace-write"
[mcp_servers.<name>]— declares an MCP server (full field list in our MCP guide)[profiles.<name>]— named config bundles for scenarios; select withprofile = "ci"or--profile
Profiles are the most underused mechanism in config.toml — packaging "write code", "CI batch", "read-only review" into three profiles beats editing the file every time.
5. Common mistakes
- Writing requirements.toml keys into config.toml:
allow_managed_hooks_onlyonly works in the admin layer — misplaced, it silently does nothing - Defining profiles but never selecting them: a
[profiles.ci]block without--profile ciis dead config - Plaintext secrets on disk: prefer the
*_env_varforms for API keys — project-level files are committed to git - Treating model_provider as a URL: it is a provider key; custom channels must be registered in
[model_providers]first
6. Next steps
Key points
- Main file: ~/.codex/config.toml; project-level .codex/config.toml overrides same-named keys
- model / model_provider pick model and provider; model_reasoning_effort and model_verbosity tune depth and length
- approval_policy + sandbox_mode are the two independent safety axes
- [mcp_servers.<name>] declares MCP servers; [profiles.<name>] defines named config profiles
- requirements.toml is the admin layer: allow_managed_hooks_only = true accepts managed hooks only
Frequently asked questions
Official references
Related articles
Codex Preview Line Jumps from 0.167 to 0.168: Four Releases, No Stable Close (2026)
The Codex 0.167 preview line reached alpha.5 on GitHub without ever shipping a stable release — npm's alpha dist-tag moved to 0.168.0-alpha.1 on November 4, while PyPI's openai-codex remains stuck at 0.163.0.
Read articleCodex CLI 0.166.0, Explained: GPT-6.1 Terra in Vertex AI and Bedrock Catalogs, Transcript Search, doctor
0.166.0 went stable on 2026-10-29T19:47 UTC: GPT-6.1 Terra covers the Vertex AI and Bedrock catalogs too; the TUI gains keyboard transcript selection and search; queue --resume and doctor --network-only land. PyPI gap: three versions.
Read articleCodex CLI 0.164–0.165, Explained: GPT-6.1 Terra in the Catalog, a Vertex AI Provider, /presets, memory v2
Two stable releases since 0.163: 0.164.0 (Oct 23) adds /presets and inline /model and /permissions; 0.165.0 (Oct 27) ships a Vertex AI provider and GPT-6.1 Terra in the catalog. Checked against the official notes.
Read articleSubscribe to GPTMap Weekly
One email every Monday: curated OpenAI updates, deep dives, and best practices. No ads, unsubscribe anytime.
Submitting opens Buttondown in a new tab to confirm your subscription.