📚AI 编程官方教程中文版
📘 OpenAI Codex📚 官方教程中文版规则、安全与配置

查询完整配置项

本篇是 Codex 配置文件的可搜索参考。

本篇是 Codex 配置文件的可搜索参考。

如果你需要概念和示例,先看:

config.toml

User-level configuration 位于:

~/.codex/config.toml

你也可以在项目中添加 project-scoped overrides:

.codex/config.toml

Codex 只会在你 trust project(信任项目)后加载 project-scoped config files。

Sandbox 和 approval 相关键,例如 approval_policysandbox_modesandbox_workspace_write.*,建议同时参考:

核心模型和 provider 配置

KeyTypeDescription
modelstring使用的模型,例如 gpt-5.5
review_modelstring/review 使用的可选模型覆盖值;默认使用当前 session model。
model_providerstringmodel_providers 中的 provider id,默认 openai
openai_base_urlstring内置 openai model provider 的 base URL override。
model_context_windownumber当前模型可用的 context window tokens。
model_auto_compact_token_limitnumber触发 automatic history compaction 的 token threshold;未设置时使用模型默认值。
model_catalog_jsonstring (path)启动时加载的可选 JSON model catalog 路径;profile-level profiles.<name>.model_catalog_json 可按 profile 覆盖。
oss_providerlmstudio / ollama使用 --oss 时的默认本地 provider;未设置时会提示选择。

审批和沙箱配置

KeyTypeDescription
approval_policyuntrusted / on-request / never / granular table控制 Codex 执行命令前什么时候暂停等待 approval。也可用 approval_policy = { granular = { ... } } 细分 prompt categories。on-failure 已 deprecated;interactive runs 用 on-request,non-interactive runs 用 never
approval_policy.granular.sandbox_approvalbooleantrue 时,允许 sandbox escalation approval prompts 出现。
approval_policy.granular.rulesbooleantrue 时,允许 execpolicy prompt rules 触发的 approvals 出现。
approval_policy.granular.mcp_elicitationsbooleantrue 时,MCP elicitation prompts 可出现;否则 auto-rejected。
approval_policy.granular.request_permissionsbooleantrue 时,request_permissions tool 的 prompts 可出现。
approval_policy.granular.skill_approvalbooleantrue 时,skill-script approval prompts 可出现。
approvals_revieweruser / auto_review谁 review eligible approval prompts。默认 userauto_review 使用 reviewer subagent。它不改变 sandboxing 或 sandbox 内已允许的 actions。
auto_review.policystringAutomatic review 的本地 Markdown policy instructions。Managed guardian_policy_config 优先;空值忽略。
allow_login_shellboolean是否允许 shell-based tools 使用 login-shell semantics。默认 true;为 false 时拒绝 login = true,未写 login 时默认 non-login shell。
sandbox_moderead-only / workspace-write / danger-full-access命令执行时的 filesystem 和 network access sandbox policy。
sandbox_workspace_write.writable_rootsarray<string>sandbox_mode = "workspace-write" 时额外 writable roots。
sandbox_workspace_write.network_accessbooleanworkspace-write sandbox 内是否允许 outbound network access。
sandbox_workspace_write.exclude_tmpdir_env_varbooleanworkspace-write mode 中是否排除 $TMPDIR writable root。
sandbox_workspace_write.exclude_slash_tmpbooleanworkspace-write mode 中是否排除 /tmp writable root。
windows.sandboxunelevated / elevatedWindows 原生运行 Codex 时的 native sandbox mode。
windows.sandbox_private_desktopbooleanNative Windows 上默认把最终 sandboxed child process 放到 private desktop。只有为了兼容旧 Winsta0\\Default 行为时才设为 false

通知、analytics 和指令配置

KeyTypeDescription
notifyarray<string>通知命令;Codex 会传入 JSON payload。
check_for_update_on_startupboolean启动时检查 Codex 更新。只有集中管理更新时才设为 false
feedback.enabledboolean是否在 Codex surfaces 中启用 /feedback;默认 true
analytics.enabledboolean本机或 profile 是否启用 analytics。未设置时使用 client default。
instructionsstring预留给未来使用;当前优先使用 model_instructions_fileAGENTS.md
developer_instructionsstring注入 session 的额外 developer instructions,可选。
log_dirstring (path)Codex 写 log files 的目录,例如 codex-tui.log;默认 $CODEX_HOME/log
sqlite_homestring (path)Codex 存储 SQLite-backed state DB 的目录,用于 agent jobs 和其他 resumable runtime state。
compact_promptstringHistory compaction prompt 的 inline override。
commit_attributionstring覆盖 commit co-author trailer text。设为空字符串可关闭 automatic attribution。
model_instructions_filestring (path)用文件替换 built-in instructions,而不是使用 AGENTS.md
personalitynone / friendly / pragmatic支持 supportsPersonality 的模型默认 communication style;可按 thread / turn 或 /personality 覆盖。
service_tierflex / fast新 turns 的 preferred service tier。
experimental_compact_prompt_filestring (path)从文件加载 compaction prompt override。Experimental。

Skills 和 apps 配置

KeyTypeDescription
skills.configarray<object>保存在 config.toml 中的 per-skill enablement overrides。
skills.config.<index>.pathstring (path)包含 SKILL.md 的 skill folder 路径。
skills.config.<index>.enabledboolean启用或禁用该 skill。
apps.<id>.enabledboolean按 id 启用或禁用具体 app / connector,默认 true
apps._default.enabledboolean所有 apps 的默认 enabled state,除非 app 单独覆盖。
apps._default.destructive_enabledbooleandestructive_hint = true 的 app tools 默认允许或拒绝。
apps._default.open_world_enabledbooleanopen_world_hint = true 的 app tools 默认允许或拒绝。
apps.<id>.destructive_enabledboolean对该 app 中声明 destructive_hint = true 的 tools 允许或阻止。
apps.<id>.open_world_enabledboolean对该 app 中声明 open_world_hint = true 的 tools 允许或阻止。
apps.<id>.default_tools_enabledboolean该 app tools 的默认 enabled state,除非有 per-tool override。
apps.<id>.default_tools_approval_modeauto / prompt / approve该 app tools 默认 approval behavior,除非有 per-tool override。
apps.<id>.tools.<tool>.enabledboolean某个 app tool 的 per-tool enabled override,例如 repos/list
apps.<id>.tools.<tool>.approval_modeauto / prompt / approve单个 app tool 的 approval behavior override。
tool_suggest.discoverablesarray<table>允许对额外 discoverable connectors 或 plugins 提示工具建议。每项使用 type = "connector""plugin" 和一个 id
tool_suggest.disabled_toolsarray<table>禁用特定 discoverable connectors 或 plugins 的建议。每项使用 type = "connector""plugin" 和一个 id

功能开关

KeyTypeDescription
features.appsboolean启用 ChatGPT Apps / connectors support。Experimental。
features.codex_hooksboolean启用从 hooks.json 或 inline [hooks] config 加载 lifecycle hooks。
hookstableconfig.toml 中 inline 配置 lifecycle hooks。事件 schema 与 hooks.json 相同;示例和事件见 Hooks guide。
features.memoriesboolean启用 Memories,默认关闭:https://developers.openai.com/codex/memories
features.unified_execboolean使用 PTY-backed unified exec tool。Stable;除 Windows 外默认启用。
features.shell_snapshotbooleanSnapshot shell environment,加速重复命令。Stable;默认启用。
features.undoboolean启用 undo support。Stable;默认关闭。
features.multi_agentboolean启用 multi-agent collaboration tools:spawn_agentsend_inputresume_agentwait_agentclose_agent。Stable;默认启用。
features.personalityboolean启用 personality selection controls。Stable;默认启用。
features.web_searchbooleanDeprecated legacy toggle;优先使用顶层 web_search
features.web_search_cachedbooleanDeprecated legacy toggle。web_search 未设置时,true 映射到 web_search = "cached"
features.web_search_requestbooleanDeprecated legacy toggle。web_search 未设置时,true 映射到 web_search = "live"
features.shell_toolboolean启用默认 shell tool 运行命令。Stable;默认启用。
features.enable_request_compressionboolean支持时用 zstd 压缩 streaming request bodies。Stable;默认启用。
features.skill_mcp_dependency_installboolean允许为 skills 提示并安装缺失 MCP dependencies。Stable;默认启用。
features.fast_modeboolean启用 Fast mode selection 和 service_tier = "fast" 路径。Stable;默认启用。
features.prevent_idle_sleepbooleanturn 正在运行时阻止机器 sleep。Experimental;默认关闭。
suppress_unstable_features_warningboolean启用 under-development feature flags 时,不显示 warning。

MCP servers 配置

KeyTypeDescription
mcp_servers.<id>.commandstringMCP stdio server 的 launcher command。
mcp_servers.<id>.argsarray<string>传给 MCP stdio server command 的 arguments。
mcp_servers.<id>.envmap<string,string>转发给 MCP stdio server 的 environment variables。
mcp_servers.<id>.env_varsarray<string | { name = string, source = "local" | "remote" }>额外 allowlist 的 environment variables。字符串默认 source = "local"source = "remote" 只用于 executor-backed remote stdio。
mcp_servers.<id>.cwdstringMCP stdio server process 的 working directory。
mcp_servers.<id>.urlstringMCP streamable HTTP server endpoint。
mcp_servers.<id>.bearer_token_env_varstring给 MCP HTTP server 提供 bearer token 的环境变量。
mcp_servers.<id>.http_headersmap<string,string>每个 MCP HTTP request 附带的 static HTTP headers。
mcp_servers.<id>.env_http_headersmap<string,string>从环境变量填充的 MCP HTTP server headers。
mcp_servers.<id>.enabledboolean不删除配置的情况下禁用 MCP server。
mcp_servers.<id>.requiredbooleantrue 时,如果 enabled MCP server 无法初始化,则 startup / resume 失败。
mcp_servers.<id>.startup_timeout_secnumber覆盖 MCP server 默认 10s startup timeout。
mcp_servers.<id>.startup_timeout_msnumberstartup_timeout_sec 的毫秒别名。
mcp_servers.<id>.tool_timeout_secnumber覆盖 MCP server 默认 60s per-tool timeout。
mcp_servers.<id>.enabled_toolsarray<string>MCP server 暴露工具的 allow list。
mcp_servers.<id>.disabled_toolsarray<string>MCP server 工具 deny list;在 enabled_tools 后应用。
mcp_servers.<id>.scopesarray<string>认证该 MCP server 时请求的 OAuth scopes。
mcp_servers.<id>.oauth_resourcestringMCP login 时可选 RFC 8707 OAuth resource parameter。
mcp_servers.<id>.experimental_environmentlocal / remoteMCP server 实验性 placement。remote 会通过 remote executor environment 启动 stdio servers;streamable HTTP remote placement 尚未实现。

agents 和记忆配置

KeyTypeDescription
agents.max_threadsnumber可同时打开的 agent threads 最大数量。未设置默认 6
agents.max_depthnumber允许 spawned agent threads 的最大 nesting depth;root session 深度为 0,默认 1。
agents.job_max_runtime_secondsnumberspawn_agents_on_csv jobs 的默认 per-worker timeout。未设置时每个 worker 默认 1800 秒。
agents.<name>.descriptionstringCodex 选择并 spawn 该 agent type 时看到的 role guidance。
agents.<name>.config_filestring (path)该 role 的 TOML config layer 路径;relative paths 相对声明 role 的 config file。
agents.<name>.nickname_candidatesarray<string>该 role spawned agents 的可选 display nicknames 池。
memories.generate_memoriesbooleanfalse 时,新 threads 不会存为 memory-generation inputs。默认 true
memories.use_memoriesbooleanfalse 时,Codex 不向 future sessions 注入 existing memories。默认 true
memories.disable_on_external_contextbooleantrue 时,使用 MCP tool calls、web search 或 tool search 等 external context 的 threads 不参与 memory generation。默认 false。Legacy alias: memories.no_memories_if_mcp_or_web_search
memories.max_raw_memories_for_consolidationnumberGlobal consolidation 保留的 recent raw memories 最大数量。默认 256,上限 4096
memories.max_unused_daysnumbermemory last used 超过多少天后不再参与 consolidation。默认 30,范围 0-365
memories.max_rollout_age_daysnumbermemory generation 考虑的 threads 最大 age。默认 30,范围 0-90
memories.max_rollouts_per_startupnumber每次 startup pass 处理的 rollout candidates 最大数量。默认 16,上限 128
memories.min_rollout_idle_hoursnumberthread 被纳入 memory generation 前的最小 idle time。默认 6,范围 1-48
memories.min_rate_limit_remaining_percentnumbermemory generation 启动前,Codex rate-limit windows 中需要保留的最小百分比。默认 25,范围 0-100
memories.extract_modelstringPer-thread memory extraction 的可选模型覆盖。
memories.consolidation_modelstringGlobal memory consolidation 的可选模型覆盖。

模型 providers 配置

KeyTypeDescription
model_providers.<id>tableCustom provider definition。内置 provider IDs openaiollamalmstudio 保留,不能覆盖。
model_providers.<id>.namestringCustom model provider 的 display name。
model_providers.<id>.base_urlstringModel provider 的 API base URL。
model_providers.<id>.env_keystring提供 provider API key 的环境变量。
model_providers.<id>.env_key_instructionsstringProvider API key 的可选设置说明。
model_providers.<id>.experimental_bearer_tokenstringProvider direct bearer token。不建议使用;优先 env_key
model_providers.<id>.requires_openai_authbooleanProvider 是否使用 OpenAI authentication,默认 false。
model_providers.<id>.wire_apiresponsesProvider 使用的 protocol。responses 是唯一支持值;省略时默认 responses
model_providers.<id>.query_paramsmap<string,string>附加到 provider requests 的 extra query parameters。
model_providers.<id>.http_headersmap<string,string>加到 provider requests 的 static HTTP headers。
model_providers.<id>.env_http_headersmap<string,string>从环境变量填充 HTTP headers。
model_providers.<id>.request_max_retriesnumberProvider HTTP requests 的 retry count,默认 4。
model_providers.<id>.stream_max_retriesnumberSSE streaming interruptions 的 retry count,默认 5。
model_providers.<id>.stream_idle_timeout_msnumberSSE streams idle timeout,单位 ms,默认 300000。
model_providers.<id>.supports_websocketsboolean该 provider 是否支持 Responses API WebSocket transport。
model_providers.<id>.authtableCustom provider 的 command-backed bearer token 配置。不要与 env_keyexperimental_bearer_tokenrequires_openai_auth 组合。
model_providers.<id>.auth.commandstringCodex 需要 bearer token 时运行的 command。必须把 token 打印到 stdout。
model_providers.<id>.auth.argsarray<string>传给 token command 的 arguments。
model_providers.<id>.auth.timeout_msnumberToken command 最大运行时间,默认 5000 ms。
model_providers.<id>.auth.refresh_interval_msnumberCodex 主动刷新 token 的间隔,默认 300000 ms。设为 0 时,只在 authentication retry 后刷新。
model_providers.<id>.auth.cwdstring (path)Token command 的 working directory。
model_providers.amazon-bedrock.aws.profilestring内置 amazon-bedrock provider 使用的 AWS profile name。
model_providers.amazon-bedrock.aws.regionstring内置 amazon-bedrock provider 使用的 AWS region。

推理和 shell 环境配置

KeyTypeDescription
model_reasoning_effortminimal / low / medium / high / xhigh调整支持模型的 reasoning effort。仅 Responses API;xhigh 依赖模型。
plan_mode_reasoning_effortnone / minimal / low / medium / high / xhighPlan mode 专用 reasoning override。未设置时 Plan mode 使用内置 preset 默认值。
model_reasoning_summaryauto / concise / detailed / none选择 reasoning summary 详细程度,或完全禁用 summaries。
model_verbositylow / medium / highGPT-5 Responses API verbosity override;未设置时使用模型 / preset 默认值。
model_supports_reasoning_summariesboolean强制 Codex 发送或不发送 reasoning metadata。
shell_environment_policy.inheritall / core / none启动 subprocesses 时 baseline environment inheritance。
shell_environment_policy.ignore_default_excludesboolean在其他 filters 运行前保留包含 KEY / SECRET / TOKEN 的变量。
shell_environment_policy.excludearray<string>默认过滤后移除 environment variables 的 glob patterns。
shell_environment_policy.include_onlyarray<string>Whitelist patterns;设置后只保留匹配变量。
shell_environment_policy.setmap<string,string>注入每个 subprocess 的 explicit environment overrides。
shell_environment_policy.experimental_use_profileboolean启动 subprocesses 时使用 user shell profile。

项目、profiles 和历史配置

KeyTypeDescription
project_root_markersarray<string>查找 parent directories 时用于识别 project root 的 marker filenames。
project_doc_max_bytesnumber构建 project instructions 时,从 AGENTS.md 读取的最大 bytes。
project_doc_fallback_filenamesarray<string>AGENTS.md 缺失时额外尝试的 filenames。
profilestring启动时应用的 default profile,等同 --profile
profiles.<name>.*variousProfile-scoped overrides,可覆盖支持的配置键。
profiles.<name>.service_tierflex / fastProfile-scoped service tier preference。
profiles.<name>.plan_mode_reasoning_effortnone / minimal / low / medium / high / xhighProfile-scoped Plan-mode reasoning override。
profiles.<name>.web_searchdisabled / cached / liveProfile-scoped web search mode override,默认 "cached"
profiles.<name>.personalitynone / friendly / pragmatic支持模型的 profile-scoped communication style override。
profiles.<name>.model_catalog_jsonstring (path)Profile-scoped model catalog JSON path override,只在 startup 应用,并覆盖 top-level model_catalog_json
profiles.<name>.model_instructions_filestring (path)Profile-scoped built-in instruction file replacement。
profiles.<name>.experimental_use_unified_exec_toolboolean启用 unified exec 的 legacy name;优先 [features].unified_exec
profiles.<name>.oss_providerlmstudio / ollama--oss sessions 的 profile-scoped OSS provider。
profiles.<name>.tools_view_imageboolean在该 profile 中启用或禁用 view_image tool。
profiles.<name>.analytics.enabledbooleanProfile-scoped analytics enablement override。
profiles.<name>.windows.sandboxunelevated / elevatedProfile-scoped Windows sandbox mode override。
history.persistencesave-all / none是否把 session transcripts 保存到 history.jsonl
tool_output_token_limitnumber存储单个 tool / function outputs 到 history 时的 token budget。
background_terminal_max_timeoutnumberwrite_stdin polls 的最大 poll window,单位 ms,默认 300000。替代旧 background_terminal_timeout
history.max_bytesnumber设置后,以 bytes 限制 history file size,并丢弃 oldest entries。
file_openervscode / vscode-insiders / windsurf / cursor / noneCodex output 中 citations 打开的 URI scheme,默认 vscode

OpenTelemetry 配置

KeyTypeDescription
otel.environmentstringOpenTelemetry events 的 environment tag,默认 dev
otel.exporternone / otlp-http / otlp-grpc选择 OpenTelemetry exporter,并提供 endpoint metadata。
otel.trace_exporternone / otlp-http / otlp-grpc选择 OpenTelemetry trace exporter,并提供 endpoint metadata。
otel.metrics_exporternone / statsig / otlp-http / otlp-grpc选择 OpenTelemetry metrics exporter,默认 statsig
otel.log_user_promptboolean是否把 raw user prompts 导出到 OpenTelemetry logs。
otel.exporter.<id>.endpointstringOTEL logs exporter endpoint。
otel.exporter.<id>.protocolbinary / jsonOTLP / HTTP exporter 使用的 protocol。
otel.exporter.<id>.headersmap<string,string>OTEL exporter requests 附带的 static headers。
otel.trace_exporter.<id>.endpointstringOTEL logs trace exporter endpoint。
otel.trace_exporter.<id>.protocolbinary / jsonOTLP / HTTP trace exporter 使用的 protocol。
otel.trace_exporter.<id>.headersmap<string,string>OTEL trace exporter requests 附带的 static headers。
otel.exporter.<id>.tls.ca-certificatestringOTEL exporter TLS CA certificate path。
otel.exporter.<id>.tls.client-certificatestringOTEL exporter TLS client certificate path。
otel.exporter.<id>.tls.client-private-keystringOTEL exporter TLS client private key path。
otel.trace_exporter.<id>.tls.ca-certificatestringOTEL trace exporter TLS CA certificate path。
otel.trace_exporter.<id>.tls.client-certificatestringOTEL trace exporter TLS client certificate path。
otel.trace_exporter.<id>.tls.client-private-keystringOTEL trace exporter TLS client private key path。

TUI 和本地界面配置

KeyTypeDescription
tuitableTUI-specific options,例如 inline desktop notifications。
tui.notificationsboolean / array<string>启用 TUI notifications,也可限制为 specific event types。
tui.notification_methodauto / osc9 / belTerminal notifications 的方法,默认 auto
tui.notification_conditionunfocused / alwaysTUI notifications 只在 terminal unfocused 时触发,还是无论 focus 都触发。默认 unfocused
tui.animationsboolean启用 terminal animations,例如 welcome screen、shimmer、spinner。默认 true
tui.alternate_screenauto / always / never控制 TUI alternate screen usage。默认 auto;Zellij 中 auto 会跳过以保留 scrollback。
tui.show_tooltipsboolean在 TUI welcome screen 显示 onboarding tooltips,默认 true
tui.status_linearray<string> / nullTUI footer status-line item identifiers 的有序列表;null 禁用 status line。
tui.terminal_titlearray<string> / nullTerminal window / tab title item identifiers 的有序列表。默认 ["spinner", "project"]null 禁用 title updates。
tui.themestringSyntax-highlighting theme override,使用 kebab-case theme name。
tui.keymap.<context>.<action>string / array<string>TUI action 的 keyboard shortcut binding。Contexts 包括 globalchatcomposereditorpagerlistapproval;context-specific bindings 覆盖 tui.keymap.global
tui.keymap.<context>.<action> = []empty array在该 keymap context 中 unbind action。Key names 使用 ctrl-ashift-enterpage-down 等 normalized strings。
tui.model_availability_nux.<model>integer按 model slug 记录 internal startup-tooltip state。
hide_agent_reasoningboolean在 TUI 和 codex exec output 中 suppress reasoning events。
show_raw_agent_reasoningbooleanActive model 发出 raw reasoning content 时显示它。
disable_paste_burstboolean禁用 TUI 中的 burst-paste detection。
windows_wsl_setup_acknowledgedboolean记录 Windows onboarding acknowledgement。Windows only。

认证、网页搜索、权限和提示配置

KeyTypeDescription
chatgpt_base_urlstringChatGPT login flow 使用的 base URL override。
cli_auth_credentials_storefile / keyring / autoCLI 存储 cached credentials 的位置:file-based auth.json 或 OS keychain。
mcp_oauth_credentials_storeauto / file / keyringMCP OAuth credentials 的首选 store。
mcp_oauth_callback_portintegerMCP OAuth login 的 local HTTP callback server 固定端口。未设置时由 OS 选择 ephemeral port。
mcp_oauth_callback_urlstringMCP OAuth login 的 redirect URI override,例如 devbox ingress URL。mcp_oauth_callback_port 仍控制 callback listener port。
experimental_use_unified_exec_toolboolean启用 unified exec 的 legacy name;优先 [features].unified_execcodex --enable unified_exec
tools.web_searchboolean / object可选 web search tool 配置。Legacy boolean 仍被接受;object 形式可设置 context size、allowed domains、approximate user location。
tools.view_imageboolean启用 local-image attachment tool view_image
web_searchdisabled / cached / liveWeb search mode。默认 "cached";cached 使用 OpenAI-maintained index,不抓 live pages。使用 --yolo 或其他 full access sandbox setting 时默认 "live"
default_permissionsstring默认应用到 sandboxed tool calls 的 permissions profile 名称。内置::read-only:workspace:danger-no-sandbox;custom names 需要 [permissions.<name>]
permissions.<name>.filesystemtableNamed filesystem permission profile。每个 key 可以是 absolute path 或 :minimal:project_roots 等 special token。
permissions.<name>.filesystem.glob_scan_max_depthnumber对需要在 sandbox startup 前 snapshot matches 的平台,扩展 deny-read glob patterns 的最大深度。设置时至少为 1
permissions.<name>.filesystem.<path-or-glob>"read" / "write" / "none" / table给 path、glob pattern 或 special token 授予 direct access,或在 root 下 scope nested entries。用 "none" deny reads。
permissions.<name>.filesystem.":project_roots".<subpath-or-glob>"read" / "write" / "none"相对于 detected project roots 的 scoped filesystem access。"." 表示 root;"**/*.env" 这类 glob subpaths 可用 "none" deny reads。
permissions.<name>.network.enabledboolean为 named permissions profile 启用 network access。
permissions.<name>.network.proxy_urlstringNamed permissions profile 启用 managed network proxy 时使用的 HTTP proxy endpoint。
permissions.<name>.network.enable_socks5boolean启用 managed network proxy 时暴露 SOCKS5 listener。
permissions.<name>.network.socks_urlstring该 permissions profile 使用的 SOCKS5 proxy endpoint。
permissions.<name>.network.enable_socks5_udpboolean启用时允许 UDP over SOCKS5 listener。
permissions.<name>.network.allow_upstream_proxyboolean允许 managed proxy 链接到另一个 upstream proxy。
permissions.<name>.network.dangerously_allow_non_loopback_proxyboolean允许 managed proxy listener 使用 non-loopback bind addresses。
permissions.<name>.network.dangerously_allow_all_unix_socketsboolean允许 proxy 使用 arbitrary Unix sockets,而不是默认 restricted set。
permissions.<name>.network.modelimited / fullSubprocess traffic 使用的 network proxy mode。
permissions.<name>.network.domainsmap<string, allow | deny>Managed proxy 的 domain rules。key 使用 domain names 或 wildcard patterns,value 为 allowdeny
permissions.<name>.network.unix_socketsmap<string, allow | none>Managed proxy 的 Unix socket rules。key 为 socket paths,value 为 allownone
permissions.<name>.network.allow_local_bindingboolean允许通过 managed proxy 进行 local bind / listen operations。
projects.<path>.trust_levelstring标记 project 或 worktree 为 "trusted""untrusted"。Untrusted projects 会跳过 project-scoped .codex/ layers,包括 project-local config、hooks、rules。
notice.hide_full_access_warningboolean记录 full access warning prompt 是否已确认。
notice.hide_world_writable_warningboolean记录 Windows world-writable directories warning 是否已确认。
notice.hide_rate_limit_model_nudgeboolean记录是否关闭 rate limit model switch reminder。
notice.hide_gpt5_1_migration_promptboolean记录 GPT-5.1 migration prompt 是否已确认。
notice.hide_gpt-5.1-codex-max_migration_promptboolean记录 gpt-5.1-codex-max migration prompt 是否已确认。
notice.model_migrationsmap<string,string>记录已确认的 model migrations,形式为 old -> new。
forced_login_methodchatgpt / api限制 Codex 只能使用指定 authentication method。
forced_chatgpt_workspace_idstring (uuid)将 ChatGPT logins 限制到指定 workspace identifier。

JSON schema 配置

最新 config.toml JSON schema:

https://developers.openai.com/codex/config-schema.json

如果想在 VS Code 或 Cursor 中编辑 config.toml 时获得 autocompletion 和 diagnostics,可以安装 Even Better TOML:

https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml

然后在 config.toml 顶部加入:

#:schema https://developers.openai.com/codex/config-schema.json

注意:把旧的 experimental_instructions_file 改名为 model_instructions_file。Codex 已弃用旧 key,现有配置应迁移到新名称。

requirements.toml

requirements.toml 是 admin-enforced configuration file(管理员强制配置文件),用于限制用户不能覆盖的 security-sensitive settings。

位置、示例和细节见 Admin-enforced requirements:

https://developers.openai.com/codex/enterprise/managed-configuration#admin-enforced-requirements-requirementstoml

ChatGPT Business 和 Enterprise 用户还可以应用 cloud-fetched requirements。优先级见 security page。

requirements.toml 中使用 [features],可以用与 config.toml 相同的 canonical keys 固定 feature flags。省略的 keys 不受限制。

requirements 字段

KeyTypeDescription
allowed_approval_policiesarray<string>允许的 approval_policy 值,例如 untrustedon-requestnevergranular
allowed_approvals_reviewersarray<string>允许的 approvals_reviewer 值,例如 userauto_review
guardian_policy_configstringAutomatic review 的 managed Markdown policy instructions。优先级高于本地 [auto_review].policy;空值忽略。
allowed_sandbox_modesarray<string>允许的 sandbox_mode 值。
remote_sandbox_configarray<table>Host-specific sandbox requirements。第一个匹配 resolved host name 的 hostname_patterns entry 会覆盖该 requirements source 的顶层 allowed_sandbox_modes。目前 host-specific entries 只覆盖 sandbox modes。
remote_sandbox_config[].hostname_patternsarray<string>Case-insensitive host name patterns。支持 * 匹配任意字符序列,? 匹配一个字符。
remote_sandbox_config[].allowed_sandbox_modesarray<string>Host-specific entry 命中时应用的 allowed sandbox modes。
allowed_web_search_modesarray<string>允许的 web_search 值:disabledcachedlivedisabled 永远允许;空 list 实际上只允许 disabled
featurestableconfig.toml [features] canonical names 固定 feature values。
features.<name>boolean要求具体 canonical feature key 保持 enabled 或 disabled。
features.in_app_browserbooleanrequirements.toml 中设为 false 可禁用 in-app browser pane。
features.browser_useboolean设为 false 可禁用 Browser Use 和 Browser Agent availability。
features.computer_useboolean设为 false 可禁用 Computer Use availability 及相关 install / enablement flows。
hookstableAdmin-enforced managed lifecycle hooks。需要 managed hook directory,事件 schema 与 config.toml inline [hooks] 相同。
hooks.managed_dirstring (absolute path)macOS 和 Linux 上包含 managed hook scripts 的目录。Codex 会验证它是 absolute 且存在。
hooks.windows_managed_dirstring (absolute path)Windows 上包含 managed hook scripts 的目录。Codex 会验证它是 absolute 且存在。
hooks.<Event>array<table>某个 hook event 的 matcher groups,例如 PreToolUsePostToolUsePermissionRequestSessionStartUserPromptSubmitStop
hooks.<Event>[].hooksarray<table>Matcher group 的 hook handlers。当前支持 command hooks;prompt 和 agent hook handlers 会被解析但跳过。
permissions.filesystem.deny_readarray<string>Admin-enforced filesystem read denials。Entries 可以是 paths 或 glob patterns,用户不能用 local config 削弱。
mcp_serverstable允许启用的 MCP servers allowlist。Server name (<id>) 和 identity 都必须匹配,MCP server 才会启用;未在 allowlist 中或 identity 不匹配的 server 会被禁用。
mcp_servers.<id>.identitytable单个 MCP server 的 identity rule。设置 command (stdio) 或 url (streamable HTTP)。
mcp_servers.<id>.identity.commandstringmcp_servers.<id>.command 与此 command 匹配时,允许 MCP stdio server。
mcp_servers.<id>.identity.urlstringmcp_servers.<id>.url 与此 URL 匹配时,允许 MCP streamable HTTP server。
rulestable.rules files 合并的 admin-enforced command rules。Requirements rules 必须是 restrictive。
rules.prefix_rulesarray<table>Enforced prefix rules 列表。每条 rule 必须包含 patterndecision
rules.prefix_rules[].patternarray<table>用 pattern tokens 表示的 command prefix。每个 token 设置 tokenany_of
rules.prefix_rules[].pattern[].tokenstring该位置的单个 literal token。
rules.prefix_rules[].pattern[].any_ofarray<string>该位置允许的 alternative tokens 列表。
rules.prefix_rules[].decisionprompt / forbidden必填。Requirements rules 只能 prompt 或 forbid,不能 allow。
rules.prefix_rules[].justificationstring可选 non-empty rationale,会显示在 approval prompts 或 rejection messages 中。

On this page