mirror of
https://github.com/openai/codex.git
synced 2026-04-25 07:05:38 +00:00
## Why
We need a way to auto-reject specific approval prompt categories without
switching all approvals off.
The goal is to let users independently control:
- sandbox escalation approvals,
- execpolicy `prompt` rule approvals,
- MCP elicitation prompts.
## What changed
- Added a new primary approval mode in `protocol/src/protocol.rs`:
```rust
pub enum AskForApproval {
// ...
Reject(RejectConfig),
// ...
}
pub struct RejectConfig {
pub sandbox_approval: bool,
pub rules: bool,
pub mcp_elicitations: bool,
}
```
- Wired `RejectConfig` semantics through approval paths in `core`:
- `core/src/exec_policy.rs`
- rejects rule-driven prompts when `rules = true`
- rejects sandbox/escalation prompts when `sandbox_approval = true`
- preserves rule priority when both rule and sandbox prompt conditions
are present
- `core/src/tools/sandboxing.rs`
- applies `sandbox_approval` to default exec approval decisions and
sandbox-failure retry gating
- `core/src/safety.rs`
- keeps `Reject { all false }` behavior aligned with `OnRequest` for
patch safety
- rejects out-of-root patch approvals when `sandbox_approval = true`
- `core/src/mcp_connection_manager.rs`
- auto-declines MCP elicitations when `mcp_elicitations = true`
- Ensured approval policy used by MCP elicitation flow stays in sync
with constrained session policy updates.
- Updated app-server v2 conversions and generated schema/TypeScript
artifacts for the new `Reject` shape.
## Verification
Added focused unit coverage for the new behavior in:
- `core/src/exec_policy.rs`
- `core/src/tools/sandboxing.rs`
- `core/src/mcp_connection_manager.rs`
- `core/src/safety.rs`
- `core/src/tools/runtimes/apply_patch.rs`
Key cases covered include rule-vs-sandbox prompt precedence, MCP
auto-decline behavior, and patch/sandbox retry behavior under
`RejectConfig`.
161 lines
3.9 KiB
JSON
161 lines
3.9 KiB
JSON
{
|
||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||
"definitions": {
|
||
"AskForApproval": {
|
||
"description": "Determines the conditions under which the user is consulted to approve running the command proposed by Codex.",
|
||
"oneOf": [
|
||
{
|
||
"description": "Under this policy, only \"known safe\" commands—as determined by `is_safe_command()`—that **only read files** are auto‑approved. Everything else will ask the user to approve.",
|
||
"enum": [
|
||
"untrusted"
|
||
],
|
||
"type": "string"
|
||
},
|
||
{
|
||
"description": "DEPRECATED: *All* commands are auto‑approved, but they are expected to run inside a sandbox where network access is disabled and writes are confined to a specific set of paths. If the command fails, it will be escalated to the user to approve execution without a sandbox. Prefer `OnRequest` for interactive runs or `Never` for non-interactive runs.",
|
||
"enum": [
|
||
"on-failure"
|
||
],
|
||
"type": "string"
|
||
},
|
||
{
|
||
"description": "The model decides when to ask the user for approval.",
|
||
"enum": [
|
||
"on-request"
|
||
],
|
||
"type": "string"
|
||
},
|
||
{
|
||
"additionalProperties": false,
|
||
"description": "Fine-grained rejection controls for approval prompts.\n\nWhen a field is `true`, prompts of that category are automatically rejected instead of shown to the user.",
|
||
"properties": {
|
||
"reject": {
|
||
"$ref": "#/definitions/RejectConfig"
|
||
}
|
||
},
|
||
"required": [
|
||
"reject"
|
||
],
|
||
"title": "RejectAskForApproval",
|
||
"type": "object"
|
||
},
|
||
{
|
||
"description": "Never ask the user to approve commands. Failures are immediately returned to the model, and never escalated to the user for approval.",
|
||
"enum": [
|
||
"never"
|
||
],
|
||
"type": "string"
|
||
}
|
||
]
|
||
},
|
||
"RejectConfig": {
|
||
"properties": {
|
||
"mcp_elicitations": {
|
||
"description": "Reject MCP elicitation prompts.",
|
||
"type": "boolean"
|
||
},
|
||
"rules": {
|
||
"description": "Reject prompts triggered by execpolicy `prompt` rules.",
|
||
"type": "boolean"
|
||
},
|
||
"sandbox_approval": {
|
||
"description": "Reject approval prompts related to sandbox escalation.",
|
||
"type": "boolean"
|
||
}
|
||
},
|
||
"required": [
|
||
"mcp_elicitations",
|
||
"rules",
|
||
"sandbox_approval"
|
||
],
|
||
"type": "object"
|
||
},
|
||
"SandboxMode": {
|
||
"enum": [
|
||
"read-only",
|
||
"workspace-write",
|
||
"danger-full-access"
|
||
],
|
||
"type": "string"
|
||
}
|
||
},
|
||
"properties": {
|
||
"approvalPolicy": {
|
||
"anyOf": [
|
||
{
|
||
"$ref": "#/definitions/AskForApproval"
|
||
},
|
||
{
|
||
"type": "null"
|
||
}
|
||
]
|
||
},
|
||
"baseInstructions": {
|
||
"type": [
|
||
"string",
|
||
"null"
|
||
]
|
||
},
|
||
"compactPrompt": {
|
||
"type": [
|
||
"string",
|
||
"null"
|
||
]
|
||
},
|
||
"config": {
|
||
"additionalProperties": true,
|
||
"type": [
|
||
"object",
|
||
"null"
|
||
]
|
||
},
|
||
"cwd": {
|
||
"type": [
|
||
"string",
|
||
"null"
|
||
]
|
||
},
|
||
"developerInstructions": {
|
||
"type": [
|
||
"string",
|
||
"null"
|
||
]
|
||
},
|
||
"includeApplyPatchTool": {
|
||
"type": [
|
||
"boolean",
|
||
"null"
|
||
]
|
||
},
|
||
"model": {
|
||
"type": [
|
||
"string",
|
||
"null"
|
||
]
|
||
},
|
||
"modelProvider": {
|
||
"type": [
|
||
"string",
|
||
"null"
|
||
]
|
||
},
|
||
"profile": {
|
||
"type": [
|
||
"string",
|
||
"null"
|
||
]
|
||
},
|
||
"sandbox": {
|
||
"anyOf": [
|
||
{
|
||
"$ref": "#/definitions/SandboxMode"
|
||
},
|
||
{
|
||
"type": "null"
|
||
}
|
||
]
|
||
}
|
||
},
|
||
"title": "NewConversationParams",
|
||
"type": "object"
|
||
} |