使用 these options 当 you need more control over providers, policies, 和 integrations。For a quick 启动, see Config basics .
For background on project guidance, reusable capabilities, custom slash commands, subagent workflows, 和 integrations, see Customization 。For configuration keys, see Configuration Reference .
Profiles
Profiles let you save named configuration layers 和 切换 between them 从 the CLI。当 you pass --profile profile-name, Codex loads ~/.codex/config.toml, then overlays ~/.codex/profile-name.config.toml。Profile names can contain letters, numbers, hyphens, 和 underscores.
Create a separate TOML file for each profile。使用 top-level config keys in the profile file;don’t nest them under [profiles.profile-name].
# ~/.codex/deep-review.config.toml
model = "gpt-5.5"
model_reasoning_effort = "xhigh"
approval_policy = "on-request"
model_catalog_json = "/Users/me/.codex/model-catalogs/deep-review.json" codex --profile deep-review
codex exec --profile deep-review "review this change" Because the profile file is a layer above your base user config 和 below project 和 CLI config, it only needs the values that differ 从 your base config。Profile files can also override model_catalog_json;Codex uses the profile value 当 both files 设置 it.
In Codex 0.134.0 和 later, --profile no longer reads [profiles.profile-name] 从 config.toml, 和 the top-level profile = "profile-name" selector is no longer 支持的。Move legacy profile settings into ~/.codex/profile-name.config.toml, then 移除 the matching [profiles.profile-name] table 和 profile = "profile-name" selector 从 config.toml.
从 CLI 做一次性覆盖
In addition 到 editing ~/.codex/config.toml, you can override configuration for a single 运行 从 the CLI:
Prefer dedicated flags 当 they exist (例如, --model).
使用 -c / --config 当 you need 到 override an arbitrary key.
Examples:
# Dedicated flag
codex --model gpt-5.4
# Generic key/value override (value is TOML, not JSON)
codex --config model='"gpt-5.4"'
codex --config sandbox_workspace_write.network_access=true
codex --config 'shell_environment_policy.include_only=["PATH","HOME"]' Notes:
Keys can 使用 dot notation 到 设置 nested values (例如, mcp_servers.context7.enabled=false).
--config values are parsed as TOML. When in doubt, quote the value so your shell doesn’t split it on spaces.
如果 the value can’t be parsed as TOML, Codex treats it as a string.
配置与状态位置
Codex stores its local state under CODEX_HOME (默认s 到 ~/.codex).
Common files you may see there:
config.toml (your local configuration)
auth.json (如果 you 使用 file-based credential storage) 或 your OS keychain/keyring
history.jsonl (如果 history 持久化ence is enabled)
Other per-user state such as logs 和 caches
For authentication details (including credential storage modes), see Authentication 。For the full 列出 of configuration keys, see Configuration Reference .
For shared 默认s, rules, 和 skills checked into repos 或 system paths, see Team Config .
如果 you just need 到 point the built-in 打开AI provider at an LLM proxy, router, 或 data-residency enabled project, 设置 openai_base_url in config.toml 而不是 defining a 新的 provider。This changes the base URL for the built-in openai provider 不使用 requiring a separate model_providers.<id> entry.
openai_base_url = "https://us.api.openai.com/v1" 项目配置文件(.codex/config.toml)
In addition 到 your user config, Codex reads project-scoped overrides 从 .codex/config.toml files inside your repo。Codex walks 从 the project root 到 your 当前 working directory 和 loads every .codex/config.toml it finds。如果 multiple files define the same key, the closest file 到 your working directory wins.
For security, Codex loads project-scoped config files only 当 the project is trusted。如果 the project is untrusted, Codex ignores project .codex/ layers, including .codex/config.toml, project-local hooks, 和 project-local rules。User 和 system layers remain separate 和 still load.
Relative paths inside a project config (例如, model_instructions_file) are resolved relative 到 the .codex/ folder that contains the config.toml.
Project config files can’t override settings that redirect credentials, alter host-owned app request metadata, change provider auth, 选择 config profiles, 或 运行 machine-local notification/telemetry commands。Codex ignores the following keys in project-local .codex/config.toml 和 prints a startup warning 当 it sees them:openai_base_url, chatgpt_base_url, apps_mcp_product_sku, model_provider, model_providers, notify, profile, profiles, experimental_realtime_ws_base_url, 和 otel。设置 provider, notification, 和 telemetry keys in your user-level ~/.codex/config.toml;选择 config profiles 使用 --profile profile-name 和 ~/.codex/profile-name.config.toml.
Hooks
Codex can also load lifecycle hooks 从 either hooks.json files 或 inline [hooks] tables in config.toml files that sit next 到 active config layers.
In practice, the four most useful locations are:
~/.codex/hooks.json
~/.codex/config.toml
<repo>/.codex/hooks.json
<repo>/.codex/config.toml
Project-local hooks load only 当 the project .codex/ layer is trusted。User-level hooks remain independent of project trust.
Inline TOML hooks 使用 the same event structure as hooks.json:
[[hooks.PreToolUse]]
matcher = "^Bash$"
[[hooks.PreToolUse.hooks]]
type = "command"
command = '/usr/bin/python3 "$(git rev-parse --show-toplevel)/.codex/hooks/pre_tool_use_policy.py"'
timeout = 30
statusMessage = "Checking Bash command" 如果 a single layer contains both hooks.json 和 inline [hooks], Codex loads both 和 warns。Prefer one representation per layer.
For the 当前 event 列出, input fields, output behavior, 和 limitations, see Hooks .
Agent 角色(config.toml 中的 [agents])
For subagent role configuration ([agents] in config.toml), see Subagents .
项目根目录检测
Codex discovers project configuration (例如, .codex/ layers 和 AGENTS.md) by walking up 从 working directory until it reaches a project root.
By 默认, Codex treats a directory containing .git as the project root. To customize this behavior, 设置 project_root_markers in config.toml:
# Treat a directory as the project root when it contains any of these markers.
project_root_markers = [".git", ".hg", ".sl"] 设置 project_root_markers = [] 到 skip searching parent directories 和 treat the 当前 working directory as the project root.
自定义模型 providers
A model provider defines how Codex connects 到 a model (base URL, wire API, authentication, 和 可选 HTTP headers)。Custom providers can’t reuse the reserved built-in provider IDs:openai, ollama, 和 lmstudio.
Define additional providers 和 point model_provider at them:
model = "gpt-5.4"
model_provider = "proxy"
[model_providers.proxy]
name = "OpenAI using LLM proxy"
base_url = "http://proxy.example.com"
env_key = "OPENAI_API_KEY"
[model_providers.local_ollama]
name = "Ollama"
base_url = "http://localhost:11434/v1"
[model_providers.mistral]
name = "Mistral"
base_url = "https://api.mistral.ai/v1"
env_key = "MISTRAL_API_KEY" 添加 request headers 当 needed:
[model_providers.example]
http_headers = { "X-Example-Header" = "example-value" }
env_http_headers = { "X-Example-Features" = "EXAMPLE_FEATURES" } 使用 command-backed authentication 当 a provider needs Codex 到 fetch bearer tokens 从 an external credential helper:
[model_providers.proxy]
name = "OpenAI using LLM proxy"
base_url = "https://proxy.example.com/v1"
wire_api = "responses"
[model_providers.proxy.auth]
command = "/usr/local/bin/fetch-codex-token"
args = ["--audience", "codex"]
timeout_ms = 5000
refresh_interval_ms = 300000 The auth command receives no stdin 和 must 打印 the token 到 stdout。Codex trims surrounding whitespace, treats an empty token as an error, 和 refreshes proactively at refresh_interval_ms;设置 refresh_interval_ms = 0 到 refresh only 之后 an authentication retry。Don’t combine [model_providers.<id>.auth] 使用 env_key, experimental_bearer_token, 或 requires_openai_auth.
Amazon Bedrock provider
Codex includes a built-in amazon-bedrock model provider。设置 it directly as model_provider;unlike custom providers, this built-in provider supports only the nested AWS profile 和 region overrides.
model_provider = "amazon-bedrock"
model = "<bedrock-model-id>"
[model_providers.amazon-bedrock.aws]
profile = "default"
region = "eu-central-1" 如果 you omit profile, Codex uses the standard AWS credential chain。设置 region 到 the 支持的 Bedrock region that should handle requests.
For the full setup flow, authentication options, 支持的 models, 和 feature availability, see 使用 Codex 使用 Amazon Bedrock .
OSS 模式(本地 providers)
Codex can 运行 against a local “打开 source” provider (例如, Ollama 或 LM Studio) 当 you pass --oss。如果 you pass --oss 不使用 specifying a provider, Codex uses oss_provider as the 默认.
# Default local provider used with `--oss`
oss_provider = "ollama" # or "lmstudio" Azure provider 与按 provider 调优
[model_providers.azure]
name = "Azure"
base_url = "https://YOUR_PROJECT_NAME.openai.azure.com/openai"
env_key = "AZURE_OPENAI_API_KEY"
query_params = { api-version = "2025-04-01-preview" }
wire_api = "responses"
request_max_retries = 4
stream_max_retries = 10
stream_idle_timeout_ms = 300000 To change the base URL for the built-in 打开AI provider, 使用 openai_base_url;don’t create [model_providers.openai], because you can’t override built-in provider IDs.
使用 data residency 的 ChatGPT 客户
Projects created 使用 data residency enabled can create a model provider 到 update the base_url 使用 the correct prefix .
model_provider = "openaidr"
[model_providers.openaidr]
name = "OpenAI Data Residency"
base_url = "https://us.api.openai.com/v1" # Replace 'us' with domain prefix 模型推理、输出详细度和限制
model_reasoning_summary = "none" # Disable summaries
model_verbosity = "low" # Shorten responses
model_supports_reasoning_summaries = true # Force reasoning
model_context_window = 128000 # Context window size model_verbosity applies only 到 providers using the Responses API。Chat Completions providers will ignore the setting.
Approval policies 与 sandbox modes
Pick approval strictness (affects 当 Codex pauses) 和 sandbox level (affects file/network access).
For operational details 到 keep in mind while editing config.toml, see Common sandbox 和 approval combinations , Protected paths in writable roots , 和 Network access .
For beta permission profiles that 配置 filesystem 和 network access together, see Permissions .
You can also 使用 a granular approval policy (approval_policy = { granular = { ..。} }) 到 allow 或 auto-reject individual prompt categories。This is useful 当 you want normal interactive approvals for some cases but want others, such as request_permissions 或 skill-script prompts, 到 fail closed 自动.
设置 approvals_reviewer = "auto_review" 到 route eligible interactive approval requests through automatic 检查。This changes the reviewer, not the sandbox boundary.
使用 [auto_review].policy for local reviewer policy instructions。Managed guardian_policy_config takes precedence.
approval_policy = "untrusted" # Other options: on-request, never, or { granular = { ... } }
approvals_reviewer = "user" # Or "auto_review" for automatic review
sandbox_mode = "workspace-write"
allow_login_shell = false # Optional hardening: disallow login shells for shell tools
# Example granular approval policy:
# approval_policy = { granular = {
# sandbox_approval = true,
# rules = true,
# mcp_elicitations = true,
# request_permissions = false,
# skill_approval = false
# } }
[sandbox_workspace_write]
exclude_tmpdir_env_var = false # Allow $TMPDIR
exclude_slash_tmp = false # Allow /tmp
writable_roots = ["/Users/YOU/.pyenv/shims"]
network_access = false # Opt in to outbound network
[auto_review]
policy = """
Use your organization's automatic review policy.
""" 命名 permission profiles
For built-in profiles, custom profile syntax, 和 the full filesystem 和 network configuration model, see Permissions .
For the complete key 列出 和 requirements constraints, see Configuration Reference 和 Managed configuration .
In workspace-write mode, some environments keep .git/ 和 .codex/ 读取-only even 当 the rest of workspace is writable。This is why commands like git commit may still require approval to run outside the sandbox. If you want Codex to skip specific commands (例如, block git commit outside the sandbox), 使用 rules .
Disable sandboxing entirely (使用 only 如果 your environment already isolates processes):
sandbox_mode = "danger-full-access" Shell environment policy
shell_environment_policy controls which environment variables Codex passes 到 any subprocess it launches (例如, 当 running a tool-command the model proposes)。启动 从 a clean 启动 (inherit = "none") 或 a trimmed 设置 (inherit = "core"), then layer on excludes, includes, 和 overrides 到 avoid leaking secrets while still providing the paths, keys, 或 flags your tasks need.
[shell_environment_policy]
inherit = "none"
set = { PATH = "/usr/bin", MY_FLAG = "1" }
ignore_default_excludes = false
exclude = ["AWS_*", "AZURE_*"]
include_only = ["PATH", "HOME"] Patterns are case-insensitive globs (*, ?, [A-Z]);ignore_默认_excludes = false keeps the automatic KEY/SECRET/TOKEN filter 之前 your includes/excludes 运行.
MCP servers
See the dedicated MCP documentation for configuration details.
可观测性与 telemetry
Enable OpenTelemetry (OTel) log export 到 track Codex runs (API requests, SSE/events, prompts, tool approvals/results)。Disabled by 默认;opt in via [otel]:
[otel]
environment = "staging" # defaults to "dev"
exporter = "none" # set to otlp-http or otlp-grpc to send events
log_user_prompt = false # redact user prompts unless explicitly enabled 选择 an exporter:
[otel]
exporter = { otlp-http = {
endpoint = "https://otel.example.com/v1/logs",
protocol = "binary",
headers = { "x-otlp-api-key" = "${OTLP_TOKEN}" }
}} [otel]
exporter = { otlp-grpc = {
endpoint = "https://otel.example.com:4317",
headers = { "x-otlp-meta" = "abc123" }
}} 如果 exporter = "none" Codex records events but sends nothing。Exporters batch asynchronously 和 flush on shutdown。Event metadata includes service name, CLI version, env tag, conversation id, model, sandbox/approval settings, 和 per-event fields (see Config Reference ).
会发出哪些数据
Codex emits structured log events for runs 和 tool usage。Representative event types include:
codex.conversation_starts (model, reasoning settings, sandbox/approval policy)
codex.api_request (attempt, status/success, duration, 和 error details)
codex.sse_event (stream event kind, success/failure, duration, plus token counts on response.completed)
codex.websocket_request 和 codex.websocket_event (request duration plus per-message kind/success/error)
codex.user_prompt (length;content redacted unless explicitly enabled)
codex.tool_decision (approved/denied 和 whether the decision came 从 config vs user)
codex.tool_result (duration, success, output snippet)
发出的 OTel metrics
当 the OTel metrics pipeline is enabled, Codex emits counters 和 duration histograms for API, stream, 和 tool activity.
Each metric below also includes 默认 metadata tags:auth_mode, originator, session_source, model, 和 app.version.
| Metric | 输入 | Fields | Description |
|---|---|---|---|
| codex.api_request | counter | status, success | API request count by HTTP status 和 success/failure. |
| codex.api_request.duration_ms | histogram | status, success | API request duration in milliseconds. |
| codex.sse_event | counter | kind, success | SSE event count by event kind 和 success/failure. |
| codex.sse_event.duration_ms | histogram | kind, success | SSE event processing duration in milliseconds. |
| codex.websocket.request | counter | success | WebSocket request count by success/failure. |
| codex.websocket.request.duration_ms | histogram | success | WebSocket request duration in milliseconds. |
| codex.websocket.event | counter | kind, success | WebSocket message/event count by 输入 和 success/failure. |
| codex.websocket.event.duration_ms | histogram | kind, success | WebSocket message/event processing duration in milliseconds. |
| codex.tool.call | counter | tool, success | Tool invocation count by tool name 和 success/failure. |
| codex.tool.call.duration_ms | histogram | tool, success | Tool execution duration in milliseconds by tool name 和 outcome. |
For more security 和 privacy guidance around telemetry, see Security .
Metrics
By 默认, Codex periodically sends a small amount of anonymous usage 和 health data back 到 打开AI。This helps detect 当 Codex isn’t working correctly 和 shows what features 和 configuration options are being used, so the Codex team can focus on what matters most。These metrics don’t contain any personally identifiable information (PII)。Metrics collection is independent of OTel log/trace export.
如果 you want 到 disable metrics collection entirely across Codex surfaces on a machine, 设置 the analytics flag in your config:
[analytics]
enabled = false Each metric includes its own fields plus the 默认 context fields below.
默认 context 字段(适用于每个 event/metric)
auth_mode:swic | api | unknown.
model:name of the model used.
app.version:Codex version.
Metrics 目录
Each metric includes the 必需 fields plus the 默认 context fields above。Metric names below omit the codex。prefix。Most metric names are centralized in codex-rs/otel/src/metrics/names.rs;feature-specific metrics emitted outside that file are included here too。如果 a metric includes the tool field, it reflects the internal tool used (例如, apply_patch 或 shell) 和 doesn’t contain the actual shell command 或 patch codex is trying to apply.
Runtime 与模型传输
| Metric | 输入 | Fields | Description |
|---|---|---|---|
| api_request | counter | status, success | API request count by HTTP status 和 success/failure. |
| api_request.duration_ms | histogram | status, success | API request duration in milliseconds. |
| sse_event | counter | kind, success | SSE event count by event kind 和 success/failure. |
| sse_event.duration_ms | histogram | kind, success | SSE event processing duration in milliseconds. |
| websocket.request | counter | success | WebSocket request count by success/failure. |
| websocket.request.duration_ms | histogram | success | WebSocket request duration in milliseconds. |
| websocket.event | counter | kind, success | WebSocket message/event count by 输入 和 success/failure. |
| websocket.event.duration_ms | histogram | kind, success | WebSocket message/event processing duration in milliseconds. |
| responses_api_overhead.duration_ms | histogram | Responses API overhead timing 从 WebSocket responses. | |
| responses_api_inference_time.duration_ms | histogram | Responses API inference timing 从 WebSocket responses. | |
| responses_api_engine_iapi_ttft.duration_ms | histogram | Responses API engine IAPI time-to-first-token timing. | |
| responses_api_engine_service_ttft.duration_ms | histogram | Responses API engine service time-to-first-token timing. | |
| responses_api_engine_iapi_tbt.duration_ms | histogram | Responses API engine IAPI time-between-token timing. | |
| responses_api_engine_service_tbt.duration_ms | histogram | Responses API engine service time-between-token timing. | |
| transport.fallback_to_http | counter | from_wire_api | WebSocket-to-HTTP fallback count. |
| remote_models.fetch_update.duration_ms | histogram | Time 到 fetch remote model definitions. | |
| remote_models.load_cache.duration_ms | histogram | Time 到 load the remote model cache. | |
| startup_prewarm.duration_ms | histogram | status | Startup prewarm duration by outcome. |
| startup_prewarm.age_at_first_turn_ms | histogram | status | Startup prewarm age 当 the first real turn resolves it. |
| cloud_requirements.fetch.duration_ms | histogram | Workspace-managed cloud requirements fetch duration. | |
| cloud_requirements.fetch_attempt | counter | See note | Workspace-managed cloud requirements fetch attempts. |
| cloud_requirements.fetch_final | counter | See note | Final workspace-managed cloud requirements fetch outcome. |
| cloud_requirements.load | counter | trigger, outcome | Workspace-managed cloud requirements load outcome. |
The cloud_requirements.fetch_attempt metric includes trigger, attempt, outcome, 和 status_code fields。The cloud_requirements.fetch_final metric includes trigger, outcome, reason, attempt_count, 和 status_code fields.
Turn 与工具活动
| Metric | 输入 | Fields | Description |
|---|---|---|---|
| turn.e2e_duration_ms | histogram | End-to-end time for a full turn. | |
| turn.ttft.duration_ms | histogram | Time 到 first token for a turn. | |
| turn.ttfm.duration_ms | histogram | Time 到 first model output item for a turn. | |
| turn.network_proxy | counter | active, tmp_mem_enabled | Whether the managed network proxy was active for the turn. |
| turn.memory | counter | read_allowed, feature_enabled, config_use_memories, has_citations | Per-turn memory 读取 availability 和 memory citation usage. |
| turn.tool.call | histogram | tmp_mem_enabled | Number of tool calls in the turn. |
| turn.token_usage | histogram | token_type, tmp_mem_enabled | Per-turn token usage by token 输入 (total, input, cached_input, output, 或 reasoning_output). |
| tool.call | counter | tool, success | Tool invocation count by tool name 和 success/failure. |
| tool.call.duration_ms | histogram | tool, success | Tool execution duration in milliseconds by tool name 和 outcome. |
| tool.unified_exec | counter | tty | Unified exec tool calls by TTY mode. |
| approval.requested | counter | tool, approved | Tool approval request result (approved, approved_with_amendment, approved_for_session, denied, abort). |
| mcp.call | counter | See note | MCP tool invocation result. |
| mcp.call.duration_ms | histogram | See note | MCP tool invocation duration. |
| mcp.tools.列出.duration_ms | histogram | cache | MCP tool-list duration, including cache hit/miss state. |
| mcp.tools.fetch_uncached.duration_ms | histogram | Duration of MCP tool fetches that miss the cache. | |
| mcp.tools.cache_write.duration_ms | histogram | Duration of Codex Apps MCP tool-cache writes. | |
| hooks.运行 | counter | hook_name, source, status | Hook 运行 count by hook name, source, 和 status. |
| hooks.运行.duration_ms | histogram | hook_name, source, status | Hook 运行 duration in milliseconds. |
The mcp.call 和 mcp.call.duration_ms metrics include status;normal tool-call emissions also include tool, plus connector_id 和 connector_name 当 可用。Blocked Codex Apps MCP calls may emit mcp.call 使用 only status.
Threads、tasks 与 features
| Metric | 输入 | Fields | Description |
|---|---|---|---|
| feature.state | counter | feature, value | Feature values that differ 从 默认s (emit one row per non-default). |
| status_line | counter | Session started 使用 a configured status line. | |
| model_warning | counter | Warning sent 到 the model. | |
| thread.started | counter | is_git | New thread created, tagged by whether working directory is in a Git repo. |
| conversation.turn.count | counter | User/assistant turns per thread, recorded at the end of the thread. | |
| thread.fork | counter | source | New thread created by forking an 已有 thread. |
| thread.rename | counter | Thread renamed. | |
| thread.side | counter | source | Side conversation created. |
| thread.skills.enabled_total | histogram | Number of skills enabled for a 新的 thread. | |
| thread.skills.kept_total | histogram | Number of enabled skills kept 之后 prompt rendering. | |
| thread.skills.truncated | histogram | Whether skill rendering truncated the enabled skills 列出 (1 或 0). | |
| task.compact | counter | 输入 | Number of compactions per 输入 (remote 或 local), including manual 和 auto. |
| task.检查 | counter | Number of reviews triggered. | |
| task.undo | counter | Number of undo actions triggered. | |
| task.user_shell | counter | Number of user shell actions (! in the TUI 例如). | |
| shell_snapshot | counter | See note | Whether taking a shell snapshot succeeded. |
| shell_snapshot.duration_ms | histogram | success | Time 到 take a shell snapshot. |
| skill.injected | counter | status, skill | Skill injection outcomes by skill. |
| plugins.startup_sync | counter | transport, status | Curated plugin startup sync attempts. |
| plugins.startup_sync.final | counter | transport, status | Final curated plugin startup sync outcome. |
| multi_agent.spawn | counter | role | Agent spawns by role. |
| multi_agent.恢复 | counter | Agent resumes. | |
| multi_agent.nickname_pool_reset | counter | Agent nickname pool resets. |
The shell_snapshot metric includes success 和, on failures, failure_reason.
Memory 与本地状态
| Metric | 输入 | Fields | Description |
|---|---|---|---|
| memory.phase1 | counter | status | Memory phase 1 job counts by status. |
| memory.phase1.e2e_ms | histogram | End-to-end duration for memory phase 1. | |
| memory.phase1.output | counter | Memory phase 1 outputs written. | |
| memory.phase1.token_usage | histogram | token_type | Memory phase 1 token usage by token 输入. |
| memory.phase2 | counter | status | Memory phase 2 job counts by status. |
| memory.phase2.e2e_ms | histogram | End-to-end duration for memory phase 2. | |
| memory.phase2.input | counter | Memory phase 2 input count. | |
| memory.phase2.token_usage | histogram | token_type | Memory phase 2 token usage by token 输入. |
| memories.usage | counter | kind, tool, success | Memory usage by kind, tool, 和 success/failure. |
| external_agent_config.detect | counter | See note | External agent config detections by migration item 输入. |
| external_agent_config.import | counter | See note | External agent config imports by migration item 输入. |
| db.backfill | counter | status | Initial state DB backfill results (upserted, failed). |
| db.backfill.duration_ms | histogram | status | Duration of the initial state DB backfill. |
| db.error | counter | stage | Errors during state DB operations. |
The external_agent_config.detect 和 external_agent_config.import metrics include migration_type;skills migrations also include skills_count.
Windows sandbox
| Metric | 输入 | Fields | Description |
|---|---|---|---|
| windows_sandbox.setup_success | counter | originator, mode | Windows sandbox setup successes. |
| windows_sandbox.setup_failure | counter | originator, mode | Windows sandbox setup failures. |
| windows_sandbox.setup_duration_ms | histogram | result, originator, mode | Windows sandbox setup duration. |
| windows_sandbox.elevated_setup_success | counter | Elevated Windows sandbox setup successes. | |
| windows_sandbox.elevated_setup_failure | counter | See note | Elevated Windows sandbox setup failures. |
| windows_sandbox.elevated_setup_canceled | counter | See note | Canceled elevated Windows sandbox setup attempts. |
| windows_sandbox.elevated_setup_duration_ms | histogram | result | Elevated Windows sandbox setup duration. |
| windows_sandbox.elevated_prompt_shown | counter | Elevated sandbox setup prompt shown. | |
| windows_sandbox.elevated_prompt_accept | counter | Elevated sandbox setup prompt accepted. | |
| windows_sandbox.elevated_prompt_use_legacy | counter | User chose legacy sandbox 从 the elevated prompt. | |
| windows_sandbox.elevated_prompt_quit | counter | User quit 从 the elevated prompt. | |
| windows_sandbox.fallback_prompt_shown | counter | Fallback sandbox prompt shown. | |
| windows_sandbox.fallback_retry_elevated | counter | User retried elevated setup 从 the fallback prompt. | |
| windows_sandbox.fallback_use_legacy | counter | User chose legacy sandbox 从 the fallback prompt. | |
| windows_sandbox.fallback_prompt_quit | counter | User quit 从 the fallback prompt. | |
| windows_sandbox.legacy_setup_preflight_failed | counter | See note | Legacy Windows sandbox setup preflight failure. |
| windows_sandbox.setup_elevated_sandbox_command | counter | Elevated sandbox setup command invoked. | |
| windows_sandbox.createprocessasuserw_failed | counter | error_code, path_kind, exe, level | Windows CreateProcessAsUserW failures. |
The elevated setup failure metrics include code 和 message 当 Windows setup failure details are 可用, 和 may include originator 当 emitted 从 the shared setup path。The windows_sandbox.legacy_setup_preflight_failed metric includes originator 当 emitted 从 the shared setup path, but fallback-prompt preflight failures may not include any fields.
反馈控制
By 默认, Codex lets users send feedback 从 /feedback。To disable feedback collection across Codex surfaces on a machine, update your config:
[feedback]
enabled = false 当 disabled, /feedback shows a disabled message 和 Codex rejects feedback submissions.
隐藏或显示 reasoning events
如果 you want 到 reduce noisy “reasoning” output (例如 in CI logs), you can suppress it:
hide_agent_reasoning = true 如果 you want 到 surface raw reasoning content 当 a model emits it:
show_raw_agent_reasoning = true Enable raw reasoning only 如果 it’s acceptable for your workflow。Some models/providers (like gpt-oss) don’t emit raw reasoning;in that case, this setting has no visible effect.
通知
使用 notify 到 trigger an external program whenever Codex emits 支持的 events (currently only agent-turn-complete)。This is handy for desktop toasts, chat webhooks, CI updates, 或 any side-channel alerting that the built-in TUI notifications don’t cover.
notify = ["python3", "/path/to/notify.py"] Example notify.py (truncated) that reacts 到 agent-turn-complete:
#!/usr/bin/env python3
import json, subprocess, sys
def main() -> int:
notification = json.loads(sys.argv[1])
if notification.get("type") != "agent-turn-complete":
return 0
title = f"Codex: {notification.get('last-assistant-message', 'Turn Complete!')}"
message = " ".join(notification.get("input-messages", []))
subprocess.check_output([
"terminal-notifier",
"-title", title,
"-message", message,
"-group", "codex-" + notification.get("thread-id", ""),
"-activate", "com.googlecode.iterm2",
])
return 0
if __name__ == "__main__":
sys.exit(main()) The script receives a single JSON argument。Common fields include:
输入 (currently agent-turn-complete)
thread-id (session identifier)
turn-id (turn identifier)
cwd (working directory)
input-messages (user messages that led 到 the turn)
last-assistant-message (last assistant message text)
Place the script somewhere on disk 和 point notify 到 it.
notify 与 tui.notifications
notify runs an external program (good for webhooks, desktop notifiers, CI hooks).
tui.notifications is built in 到 the TUI 和 can 可选ly filter by event 输入 (例如, agent-turn-complete 和 approval-requested).
tui.notification_method controls how the TUI emits terminal notifications (auto, osc9, 或 bel).
tui.notification_condition controls whether TUI notifications fire only 当 the terminal is unfocused 或 always.
In auto mode, Codex prefers OSC 9 notifications (a terminal escape sequence some terminals interpret as a desktop notification) 和 falls back 到 BEL (\x07) otherwise.
See Configuration Reference for the exact keys.
历史持久化
By 默认, Codex saves local session transcripts under CODEX_HOME (例如, ~/.codex/history.jsonl)。To disable local history 持久化ence:
[history]
persistence = "none" To cap the history file size, 设置 history.max_bytes。当 file exceeds the cap, Codex drops the oldest entries 和 compacts file while keeping the newest records.
[history]
max_bytes = 104857600 # 100 MiB 可点击引用
如果 you 使用 a terminal/editor integration that supports it, Codex can render file citations as clickable links。配置 file_opener 到 pick the URI scheme Codex uses:
file_opener = "vscode" # or cursor, windsurf, vscode-insiders, none Example:a citation like /home/user/project/main.py:42 can be rewritten into a clickable vscode://file/...:42 link.
项目说明发现
Codex reads AGENTS.md (和 related files) 和 includes a limited amount of project guidance in the first turn of a session。Two knobs control how this works:
project_doc_max_bytes:how much 到 读取 从 each AGENTS.md file
project_doc_fallback_filenames:additional filenames 到 try 当 AGENTS.md is missing at a directory level
For a detailed walkthrough, see Custom instructions 使用 AGENTS.md .
TUI 选项
Running codex with no subcommand launches the interactive terminal UI (TUI)。Codex exposes some TUI-specific configuration under [tui], including:
tui.notifications:enable/disable notifications (或 restrict 到 specific types)
tui.notification_method:选择 auto, osc9, 或 bel for terminal notifications
tui.notification_condition:选择 unfocused 或 always for 当 notifications fire
tui.animations:enable/disable ASCII animations 和 shimmer effects
tui.alternate_screen:control alternate screen usage (设置 到 never 到 keep terminal scrollback)
tui.show_tooltips:显示 或 hide onboarding tooltips on the welcome screen
tui.notification_method 默认s 到 auto。In auto mode, Codex prefers OSC 9 notifications (a terminal escape sequence some terminals interpret as a desktop notification) 当 the terminal appears 到 support them, 和 falls back 到 BEL (\x07) otherwise.
See Configuration Reference for the full key 列出.