|
| 1 | +# Feature: Feature Flags |
| 2 | + |
| 3 | +Links: |
| 4 | +Architecture: [docs/Architecture/Overview.md](../Architecture/Overview.md) |
| 5 | +Modules: [CodexSharpSDK/Models/CodexFeatureFlags.cs](../../CodexSharpSDK/Models/CodexFeatureFlags.cs), [CodexSharpSDK/Client/ThreadOptions.cs](../../CodexSharpSDK/Client/ThreadOptions.cs) |
| 6 | +ADRs: [001-codex-cli-wrapper.md](../ADR/001-codex-cli-wrapper.md) |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## Purpose |
| 11 | + |
| 12 | +Expose Codex CLI feature flags through the SDK so consumers can enable or disable experimental and optional capabilities without relying on magic string literals. |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## Scope |
| 17 | + |
| 18 | +### In scope |
| 19 | + |
| 20 | +- `CodexFeatureFlags` constants class mirroring the `features` block from `codex-rs/core/config.schema.json` |
| 21 | +- `ThreadOptions.EnabledFeatures` / `ThreadOptions.DisabledFeatures` accepting these constants |
| 22 | +- `CodexExecArgs.EnabledFeatures` / `CodexExecArgs.DisabledFeatures` for low-level exec control |
| 23 | + |
| 24 | +### Out of scope |
| 25 | + |
| 26 | +- Deciding which flags to enable at runtime (consumer responsibility) |
| 27 | +- Feature flag semantics (controlled entirely by the Codex CLI) |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## Business Rules |
| 32 | + |
| 33 | +- Feature flag identifiers must match the Codex CLI's `config.schema.json` exactly; never invent new names. |
| 34 | +- SDK ships constants for every known flag at the pinned submodule commit so consumers have compile-time safety. |
| 35 | +- New flags added by upstream syncs must be added to `CodexFeatureFlags` in the same PR that updates the submodule. |
| 36 | +- Raw string literals for feature flags are not permitted in SDK production code or tests; always use `CodexFeatureFlags` constants. |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +## Usage |
| 41 | + |
| 42 | +```csharp |
| 43 | +using ManagedCode.CodexSharpSDK.Models; |
| 44 | + |
| 45 | +var thread = client.StartThread(new ThreadOptions |
| 46 | +{ |
| 47 | + // Enable guardian approval and request-permissions tool (added in upstream sync 06f82c1) |
| 48 | + EnabledFeatures = [ |
| 49 | + CodexFeatureFlags.GuardianApproval, |
| 50 | + CodexFeatureFlags.RequestPermissionsTool, |
| 51 | + ], |
| 52 | + // Disable MCP elicitation |
| 53 | + DisabledFeatures = [ |
| 54 | + CodexFeatureFlags.ToolCallMcpElicitation, |
| 55 | + ], |
| 56 | +}); |
| 57 | +``` |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +## Known Feature Flags |
| 62 | + |
| 63 | +Sourced from `submodules/openai-codex/codex-rs/core/config.schema.json` at pinned commit. |
| 64 | + |
| 65 | +### Approval / sandbox |
| 66 | + |
| 67 | +| Constant | CLI string | Notes | |
| 68 | +|---|---|---| |
| 69 | +| `GuardianApproval` | `guardian_approval` | Guardian-based approval gate | |
| 70 | +| `RequestPermissions` | `request_permissions` | Permission request flow | |
| 71 | +| `RequestPermissionsTool` | `request_permissions_tool` | Request-permissions as a tool call | |
| 72 | + |
| 73 | +### Execution |
| 74 | + |
| 75 | +| Constant | CLI string | |
| 76 | +|---|---| |
| 77 | +| `UnifiedExec` | `unified_exec` | |
| 78 | +| `ExperimentalUseUnifiedExecTool` | `experimental_use_unified_exec_tool` | |
| 79 | +| `ShellTool` | `shell_tool` | |
| 80 | +| `ShellSnapshot` | `shell_snapshot` | |
| 81 | +| `ShellZshFork` | `shell_zsh_fork` | |
| 82 | +| `UseLinuxSandboxBwrap` | `use_linux_sandbox_bwrap` | |
| 83 | + |
| 84 | +### Apply patch |
| 85 | + |
| 86 | +| Constant | CLI string | |
| 87 | +|---|---| |
| 88 | +| `ApplyPatchFreeform` | `apply_patch_freeform` | |
| 89 | +| `ExperimentalUseFreeformApplyPatch` | `experimental_use_freeform_apply_patch` | |
| 90 | +| `IncludeApplyPatchTool` | `include_apply_patch_tool` | |
| 91 | + |
| 92 | +### MCP / tool calling |
| 93 | + |
| 94 | +| Constant | CLI string | Notes | |
| 95 | +|---|---|---| |
| 96 | +| `ToolCallMcpElicitation` | `tool_call_mcp_elicitation` | MCP-style elicitation for tool approvals | |
| 97 | + |
| 98 | +### Multi-agent / collaboration |
| 99 | + |
| 100 | +| Constant | CLI string | |
| 101 | +|---|---| |
| 102 | +| `MultiAgent` | `multi_agent` | |
| 103 | +| `Collab` | `collab` | |
| 104 | +| `CollaborationModes` | `collaboration_modes` | |
| 105 | +| `ChildAgentsMd` | `child_agents_md` | |
| 106 | +| `Steer` | `steer` | |
| 107 | + |
| 108 | +### Search |
| 109 | + |
| 110 | +| Constant | CLI string | |
| 111 | +|---|---| |
| 112 | +| `SearchTool` | `search_tool` | |
| 113 | +| `WebSearch` | `web_search` | |
| 114 | +| `WebSearchCached` | `web_search_cached` | |
| 115 | +| `WebSearchRequest` | `web_search_request` | |
| 116 | + |
| 117 | +### Memory |
| 118 | + |
| 119 | +| Constant | CLI string | |
| 120 | +|---|---| |
| 121 | +| `Memories` | `memories` | |
| 122 | +| `MemoryTool` | `memory_tool` | |
| 123 | + |
| 124 | +### Image |
| 125 | + |
| 126 | +| Constant | CLI string | |
| 127 | +|---|---| |
| 128 | +| `ImageGeneration` | `image_generation` | |
| 129 | +| `ImageDetailOriginal` | `image_detail_original` | |
| 130 | + |
| 131 | +### Plugins / apps |
| 132 | + |
| 133 | +| Constant | CLI string | |
| 134 | +|---|---| |
| 135 | +| `Plugins` | `plugins` | |
| 136 | +| `Apps` | `apps` | |
| 137 | +| `AppsMcpGateway` | `apps_mcp_gateway` | |
| 138 | +| `Connectors` | `connectors` | |
| 139 | + |
| 140 | +### JS REPL |
| 141 | + |
| 142 | +| Constant | CLI string | |
| 143 | +|---|---| |
| 144 | +| `JsRepl` | `js_repl` | |
| 145 | +| `JsReplToolsOnly` | `js_repl_tools_only` | |
| 146 | + |
| 147 | +### Realtime |
| 148 | + |
| 149 | +| Constant | CLI string | |
| 150 | +|---|---| |
| 151 | +| `RealtimeConversation` | `realtime_conversation` | |
| 152 | +| `VoiceTranscription` | `voice_transcription` | |
| 153 | + |
| 154 | +### Windows sandbox |
| 155 | + |
| 156 | +| Constant | CLI string | |
| 157 | +|---|---| |
| 158 | +| `ExperimentalWindowsSandbox` | `experimental_windows_sandbox` | |
| 159 | +| `EnableExperimentalWindowsSandbox` | `enable_experimental_windows_sandbox` | |
| 160 | +| `ElevatedWindowsSandbox` | `elevated_windows_sandbox` | |
| 161 | +| `PowershellUtf8` | `powershell_utf8` | |
| 162 | + |
| 163 | +### Storage / DB |
| 164 | + |
| 165 | +| Constant | CLI string | |
| 166 | +|---|---| |
| 167 | +| `Sqlite` | `sqlite` | |
| 168 | +| `RemoteModels` | `remote_models` | |
| 169 | + |
| 170 | +### Networking / transport |
| 171 | + |
| 172 | +| Constant | CLI string | |
| 173 | +|---|---| |
| 174 | +| `ResponsesWebsockets` | `responses_websockets` | |
| 175 | +| `ResponsesWebsocketsV2` | `responses_websockets_v2` | |
| 176 | +| `EnableRequestCompression` | `enable_request_compression` | |
| 177 | + |
| 178 | +### Miscellaneous |
| 179 | + |
| 180 | +| Constant | CLI string | |
| 181 | +|---|---| |
| 182 | +| `FastMode` | `fast_mode` | |
| 183 | +| `Artifact` | `artifact` | |
| 184 | +| `RequestRule` | `request_rule` | |
| 185 | +| `RuntimeMetrics` | `runtime_metrics` | |
| 186 | +| `Undo` | `undo` | |
| 187 | +| `Personality` | `personality` | |
| 188 | +| `SkillEnvVarDependencyPrompt` | `skill_env_var_dependency_prompt` | |
| 189 | +| `SkillMcpDependencyInstall` | `skill_mcp_dependency_install` | |
| 190 | +| `CodexGitCommit` | `codex_git_commit` | |
| 191 | +| `DefaultModeRequestUserInput` | `default_mode_request_user_input` | |
| 192 | +| `PreventIdleSleep` | `prevent_idle_sleep` | |
| 193 | + |
| 194 | +--- |
| 195 | + |
| 196 | +## Diagrams |
| 197 | + |
| 198 | +```mermaid |
| 199 | +flowchart LR |
| 200 | + Consumer["Consumer code"] -->|"EnabledFeatures / DisabledFeatures"| ThreadOptions |
| 201 | + ThreadOptions --> CodexExec["CodexExec.BuildCommandArgs()"] |
| 202 | + CodexExec -->|"--enable guardian_approval\n--disable steer"| CLI["codex exec CLI"] |
| 203 | + CodexFeatureFlags["CodexFeatureFlags constants"] -.->|"type-safe identifiers"| Consumer |
| 204 | +``` |
| 205 | + |
| 206 | +--- |
| 207 | + |
| 208 | +## Upstream sync |
| 209 | + |
| 210 | +Feature flags are kept in sync with the pinned `submodules/openai-codex` submodule. |
| 211 | +When the submodule is updated, compare `codex-rs/core/config.schema.json` `.properties.features.properties` against `CodexFeatureFlags` and add any new entries. |
| 212 | + |
| 213 | +Flags added by upstream sync `6638558b88 → 06f82c123c` (2026-03-08): |
| 214 | +- `guardian_approval` — guardian approval MVP |
| 215 | +- `request_permissions_tool` — request permissions as a tool call |
| 216 | +- `tool_call_mcp_elicitation` — MCP-style elicitation for tool-call approvals |
| 217 | + |
| 218 | +--- |
| 219 | + |
| 220 | +## Definition of Done |
| 221 | + |
| 222 | +- `CodexFeatureFlags` constants match all `features` entries in pinned `config.schema.json`. |
| 223 | +- Tests in `CodexExecTests` use `CodexFeatureFlags` constants (no raw string literals). |
| 224 | +- Documentation table is complete and up to date. |
0 commit comments