Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

app-server: accept permission profile overrides (#18279)

Michael Bolin18a26d7bbc9d
diff --git a/codex-rs/app-server-protocol/schema/json/ClientRequest.json b/codex-rs/app-server-protocol/schema/json/ClientRequest.json
index dd5e1a9306..ada860ae27 100644
--- a/codex-rs/app-server-protocol/schema/json/ClientRequest.json
+++ b/codex-rs/app-server-protocol/schema/json/ClientRequest.json
@@ -897,6 +897,217 @@
],
"type": "object"
},
+ "FileSystemAccessMode": {
+ "enum": [
+ "read",
+ "write",
+ "none"
+ ],
+ "type": "string"
+ },
+ "FileSystemPath": {
+ "oneOf": [
+ {
+ "properties": {
+ "path": {
+ "$ref": "#/definitions/AbsolutePathBuf"
+ },
+ "type": {
+ "enum": [
+ "path"
+ ],
+ "title": "PathFileSystemPathType",
+ "type": "string"
+ }
+ },
+ "required": [
+ "path",
+ "type"
+ ],
+ "title": "PathFileSystemPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "type": {
+ "enum": [
+ "glob_pattern"
+ ],
+ "title": "GlobPatternFileSystemPathType",
+ "type": "string"
+ }
+ },
+ "required": [
+ "pattern",
+ "type"
+ ],
+ "title": "GlobPatternFileSystemPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "type": {
+ "enum": [
+ "special"
+ ],
+ "title": "SpecialFileSystemPathType",
+ "type": "string"
+ },
+ "value": {
+ "$ref": "#/definitions/FileSystemSpecialPath"
+ }
+ },
+ "required": [
+ "type",
+ "value"
+ ],
+ "title": "SpecialFileSystemPath",
+ "type": "object"
+ }
+ ]
+ },
+ "FileSystemSandboxEntry": {
+ "properties": {
+ "access": {
+ "$ref": "#/definitions/FileSystemAccessMode"
+ },
+ "path": {
+ "$ref": "#/definitions/FileSystemPath"
+ }
+ },
+ "required": [
+ "access",
+ "path"
+ ],
+ "type": "object"
+ },
+ "FileSystemSpecialPath": {
+ "oneOf": [
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "root"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "RootFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "minimal"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "MinimalFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "current_working_directory"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "CurrentWorkingDirectoryFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "project_roots"
+ ],
+ "type": "string"
+ },
+ "subpath": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "KindFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "tmpdir"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "TmpdirFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "slash_tmp"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "SlashTmpFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "unknown"
+ ],
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "subpath": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "kind",
+ "path"
+ ],
+ "type": "object"
+ }
+ ]
+ },
"FsCopyParams": {
"description": "Copy a file or directory tree on the host filesystem.",
"properties": {
@@ -1657,6 +1868,64 @@
],
"type": "string"
},
+ "PermissionProfile": {
+ "properties": {
+ "fileSystem": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfileFileSystemPermissions"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "network": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfileNetworkPermissions"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "type": "object"
+ },
+ "PermissionProfileFileSystemPermissions": {
+ "properties": {
+ "entries": {
+ "items": {
+ "$ref": "#/definitions/FileSystemSandboxEntry"
+ },
+ "type": "array"
+ },
+ "globScanMaxDepth": {
+ "format": "uint",
+ "minimum": 1.0,
+ "type": [
+ "integer",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "entries"
+ ],
+ "type": "object"
+ },
+ "PermissionProfileNetworkPermissions": {
+ "properties": {
+ "enabled": {
+ "type": [
+ "boolean",
+ "null"
+ ]
+ }
+ },
+ "type": "object"
+ },
"Personality": {
"enum": [
"none",
@@ -3044,6 +3313,17 @@
"null"
]
},
+ "permissionProfile": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfile"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Full permissions override for the forked thread. Cannot be combined with `sandbox`."
+ },
"sandbox": {
"anyOf": [
{
@@ -3436,6 +3716,17 @@
"null"
]
},
+ "permissionProfile": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfile"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Full permissions override for the resumed thread. Cannot be combined with `sandbox`."
+ },
"personality": {
"anyOf": [
{
@@ -3619,6 +3910,17 @@
"null"
]
},
+ "permissionProfile": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfile"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Full permissions override for this thread. Cannot be combined with `sandbox`."
+ },
"personality": {
"anyOf": [
{
@@ -3830,6 +4132,17 @@
"outputSchema": {
"description": "Optional JSON Schema used to constrain the final assistant message for this turn."
},
+ "permissionProfile": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfile"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Override the full permissions profile for this turn and subsequent turns. Cannot be combined with `sandboxPolicy`."
+ },
"personality": {
"anyOf": [
{
diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json
index 677a7fa940..51fb744077 100644
--- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json
+++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json
@@ -14142,6 +14142,17 @@
"null"
]
},
+ "permissionProfile": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/v2/PermissionProfile"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Full permissions override for the forked thread. Cannot be combined with `sandbox`."
+ },
"sandbox": {
"anyOf": [
{
@@ -15560,6 +15571,17 @@
"null"
]
},
+ "permissionProfile": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/v2/PermissionProfile"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Full permissions override for the resumed thread. Cannot be combined with `sandbox`."
+ },
"personality": {
"anyOf": [
{
@@ -15866,6 +15888,17 @@
"null"
]
},
+ "permissionProfile": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/v2/PermissionProfile"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Full permissions override for this thread. Cannot be combined with `sandbox`."
+ },
"personality": {
"anyOf": [
{
@@ -16671,6 +16704,17 @@
"outputSchema": {
"description": "Optional JSON Schema used to constrain the final assistant message for this turn."
},
+ "permissionProfile": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/v2/PermissionProfile"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Override the full permissions profile for this turn and subsequent turns. Cannot be combined with `sandboxPolicy`."
+ },
"personality": {
"anyOf": [
{
diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json
index 421abb76c8..6291b5b987 100644
--- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json
+++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json
@@ -12036,6 +12036,17 @@
"null"
]
},
+ "permissionProfile": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfile"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Full permissions override for the forked thread. Cannot be combined with `sandbox`."
+ },
"sandbox": {
"anyOf": [
{
@@ -13454,6 +13465,17 @@
"null"
]
},
+ "permissionProfile": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfile"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Full permissions override for the resumed thread. Cannot be combined with `sandbox`."
+ },
"personality": {
"anyOf": [
{
@@ -13760,6 +13782,17 @@
"null"
]
},
+ "permissionProfile": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfile"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Full permissions override for this thread. Cannot be combined with `sandbox`."
+ },
"personality": {
"anyOf": [
{
@@ -14565,6 +14598,17 @@
"outputSchema": {
"description": "Optional JSON Schema used to constrain the final assistant message for this turn."
},
+ "permissionProfile": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfile"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Override the full permissions profile for this turn and subsequent turns. Cannot be combined with `sandboxPolicy`."
+ },
"personality": {
"anyOf": [
{
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadForkParams.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadForkParams.json
index a8fa95e2e9..6b227dec34 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/ThreadForkParams.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadForkParams.json
@@ -1,6 +1,10 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
+ "AbsolutePathBuf": {
+ "description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
+ "type": "string"
+ },
"ApprovalsReviewer": {
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `guardian_subagent` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request.",
"enum": [
@@ -59,6 +63,275 @@
}
]
},
+ "FileSystemAccessMode": {
+ "enum": [
+ "read",
+ "write",
+ "none"
+ ],
+ "type": "string"
+ },
+ "FileSystemPath": {
+ "oneOf": [
+ {
+ "properties": {
+ "path": {
+ "$ref": "#/definitions/AbsolutePathBuf"
+ },
+ "type": {
+ "enum": [
+ "path"
+ ],
+ "title": "PathFileSystemPathType",
+ "type": "string"
+ }
+ },
+ "required": [
+ "path",
+ "type"
+ ],
+ "title": "PathFileSystemPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "type": {
+ "enum": [
+ "glob_pattern"
+ ],
+ "title": "GlobPatternFileSystemPathType",
+ "type": "string"
+ }
+ },
+ "required": [
+ "pattern",
+ "type"
+ ],
+ "title": "GlobPatternFileSystemPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "type": {
+ "enum": [
+ "special"
+ ],
+ "title": "SpecialFileSystemPathType",
+ "type": "string"
+ },
+ "value": {
+ "$ref": "#/definitions/FileSystemSpecialPath"
+ }
+ },
+ "required": [
+ "type",
+ "value"
+ ],
+ "title": "SpecialFileSystemPath",
+ "type": "object"
+ }
+ ]
+ },
+ "FileSystemSandboxEntry": {
+ "properties": {
+ "access": {
+ "$ref": "#/definitions/FileSystemAccessMode"
+ },
+ "path": {
+ "$ref": "#/definitions/FileSystemPath"
+ }
+ },
+ "required": [
+ "access",
+ "path"
+ ],
+ "type": "object"
+ },
+ "FileSystemSpecialPath": {
+ "oneOf": [
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "root"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "RootFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "minimal"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "MinimalFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "current_working_directory"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "CurrentWorkingDirectoryFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "project_roots"
+ ],
+ "type": "string"
+ },
+ "subpath": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "KindFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "tmpdir"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "TmpdirFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "slash_tmp"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "SlashTmpFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "unknown"
+ ],
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "subpath": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "kind",
+ "path"
+ ],
+ "type": "object"
+ }
+ ]
+ },
+ "PermissionProfile": {
+ "properties": {
+ "fileSystem": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfileFileSystemPermissions"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "network": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfileNetworkPermissions"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "type": "object"
+ },
+ "PermissionProfileFileSystemPermissions": {
+ "properties": {
+ "entries": {
+ "items": {
+ "$ref": "#/definitions/FileSystemSandboxEntry"
+ },
+ "type": "array"
+ },
+ "globScanMaxDepth": {
+ "format": "uint",
+ "minimum": 1.0,
+ "type": [
+ "integer",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "entries"
+ ],
+ "type": "object"
+ },
+ "PermissionProfileNetworkPermissions": {
+ "properties": {
+ "enabled": {
+ "type": [
+ "boolean",
+ "null"
+ ]
+ }
+ },
+ "type": "object"
+ },
"SandboxMode": {
"enum": [
"read-only",
@@ -139,6 +412,17 @@
"null"
]
},
+ "permissionProfile": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfile"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Full permissions override for the forked thread. Cannot be combined with `sandbox`."
+ },
"sandbox": {
"anyOf": [
{
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.json
index 35a9e5b2a8..d4dce1b650 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.json
@@ -1,6 +1,10 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
+ "AbsolutePathBuf": {
+ "description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
+ "type": "string"
+ },
"ApprovalsReviewer": {
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `guardian_subagent` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request.",
"enum": [
@@ -133,6 +137,217 @@
}
]
},
+ "FileSystemAccessMode": {
+ "enum": [
+ "read",
+ "write",
+ "none"
+ ],
+ "type": "string"
+ },
+ "FileSystemPath": {
+ "oneOf": [
+ {
+ "properties": {
+ "path": {
+ "$ref": "#/definitions/AbsolutePathBuf"
+ },
+ "type": {
+ "enum": [
+ "path"
+ ],
+ "title": "PathFileSystemPathType",
+ "type": "string"
+ }
+ },
+ "required": [
+ "path",
+ "type"
+ ],
+ "title": "PathFileSystemPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "type": {
+ "enum": [
+ "glob_pattern"
+ ],
+ "title": "GlobPatternFileSystemPathType",
+ "type": "string"
+ }
+ },
+ "required": [
+ "pattern",
+ "type"
+ ],
+ "title": "GlobPatternFileSystemPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "type": {
+ "enum": [
+ "special"
+ ],
+ "title": "SpecialFileSystemPathType",
+ "type": "string"
+ },
+ "value": {
+ "$ref": "#/definitions/FileSystemSpecialPath"
+ }
+ },
+ "required": [
+ "type",
+ "value"
+ ],
+ "title": "SpecialFileSystemPath",
+ "type": "object"
+ }
+ ]
+ },
+ "FileSystemSandboxEntry": {
+ "properties": {
+ "access": {
+ "$ref": "#/definitions/FileSystemAccessMode"
+ },
+ "path": {
+ "$ref": "#/definitions/FileSystemPath"
+ }
+ },
+ "required": [
+ "access",
+ "path"
+ ],
+ "type": "object"
+ },
+ "FileSystemSpecialPath": {
+ "oneOf": [
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "root"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "RootFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "minimal"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "MinimalFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "current_working_directory"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "CurrentWorkingDirectoryFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "project_roots"
+ ],
+ "type": "string"
+ },
+ "subpath": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "KindFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "tmpdir"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "TmpdirFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "slash_tmp"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "SlashTmpFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "unknown"
+ ],
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "subpath": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "kind",
+ "path"
+ ],
+ "type": "object"
+ }
+ ]
+ },
"FunctionCallOutputBody": {
"anyOf": [
{
@@ -325,6 +540,64 @@
}
]
},
+ "PermissionProfile": {
+ "properties": {
+ "fileSystem": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfileFileSystemPermissions"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "network": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfileNetworkPermissions"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "type": "object"
+ },
+ "PermissionProfileFileSystemPermissions": {
+ "properties": {
+ "entries": {
+ "items": {
+ "$ref": "#/definitions/FileSystemSandboxEntry"
+ },
+ "type": "array"
+ },
+ "globScanMaxDepth": {
+ "format": "uint",
+ "minimum": 1.0,
+ "type": [
+ "integer",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "entries"
+ ],
+ "type": "object"
+ },
+ "PermissionProfileNetworkPermissions": {
+ "properties": {
+ "enabled": {
+ "type": [
+ "boolean",
+ "null"
+ ]
+ }
+ },
+ "type": "object"
+ },
"Personality": {
"enum": [
"none",
@@ -1052,6 +1325,17 @@
"null"
]
},
+ "permissionProfile": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfile"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Full permissions override for the resumed thread. Cannot be combined with `sandbox`."
+ },
"personality": {
"anyOf": [
{
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadStartParams.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadStartParams.json
index 9b1cba6d1a..a382edd66d 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/ThreadStartParams.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadStartParams.json
@@ -1,6 +1,10 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
+ "AbsolutePathBuf": {
+ "description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
+ "type": "string"
+ },
"ApprovalsReviewer": {
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `guardian_subagent` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request.",
"enum": [
@@ -85,6 +89,275 @@
],
"type": "object"
},
+ "FileSystemAccessMode": {
+ "enum": [
+ "read",
+ "write",
+ "none"
+ ],
+ "type": "string"
+ },
+ "FileSystemPath": {
+ "oneOf": [
+ {
+ "properties": {
+ "path": {
+ "$ref": "#/definitions/AbsolutePathBuf"
+ },
+ "type": {
+ "enum": [
+ "path"
+ ],
+ "title": "PathFileSystemPathType",
+ "type": "string"
+ }
+ },
+ "required": [
+ "path",
+ "type"
+ ],
+ "title": "PathFileSystemPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "type": {
+ "enum": [
+ "glob_pattern"
+ ],
+ "title": "GlobPatternFileSystemPathType",
+ "type": "string"
+ }
+ },
+ "required": [
+ "pattern",
+ "type"
+ ],
+ "title": "GlobPatternFileSystemPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "type": {
+ "enum": [
+ "special"
+ ],
+ "title": "SpecialFileSystemPathType",
+ "type": "string"
+ },
+ "value": {
+ "$ref": "#/definitions/FileSystemSpecialPath"
+ }
+ },
+ "required": [
+ "type",
+ "value"
+ ],
+ "title": "SpecialFileSystemPath",
+ "type": "object"
+ }
+ ]
+ },
+ "FileSystemSandboxEntry": {
+ "properties": {
+ "access": {
+ "$ref": "#/definitions/FileSystemAccessMode"
+ },
+ "path": {
+ "$ref": "#/definitions/FileSystemPath"
+ }
+ },
+ "required": [
+ "access",
+ "path"
+ ],
+ "type": "object"
+ },
+ "FileSystemSpecialPath": {
+ "oneOf": [
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "root"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "RootFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "minimal"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "MinimalFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "current_working_directory"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "CurrentWorkingDirectoryFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "project_roots"
+ ],
+ "type": "string"
+ },
+ "subpath": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "KindFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "tmpdir"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "TmpdirFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "slash_tmp"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "SlashTmpFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "unknown"
+ ],
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "subpath": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "kind",
+ "path"
+ ],
+ "type": "object"
+ }
+ ]
+ },
+ "PermissionProfile": {
+ "properties": {
+ "fileSystem": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfileFileSystemPermissions"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "network": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfileNetworkPermissions"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "type": "object"
+ },
+ "PermissionProfileFileSystemPermissions": {
+ "properties": {
+ "entries": {
+ "items": {
+ "$ref": "#/definitions/FileSystemSandboxEntry"
+ },
+ "type": "array"
+ },
+ "globScanMaxDepth": {
+ "format": "uint",
+ "minimum": 1.0,
+ "type": [
+ "integer",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "entries"
+ ],
+ "type": "object"
+ },
+ "PermissionProfileNetworkPermissions": {
+ "properties": {
+ "enabled": {
+ "type": [
+ "boolean",
+ "null"
+ ]
+ }
+ },
+ "type": "object"
+ },
"Personality": {
"enum": [
"none",
@@ -181,6 +454,17 @@
"null"
]
},
+ "permissionProfile": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfile"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Full permissions override for this thread. Cannot be combined with `sandbox`."
+ },
"personality": {
"anyOf": [
{
diff --git a/codex-rs/app-server-protocol/schema/json/v2/TurnStartParams.json b/codex-rs/app-server-protocol/schema/json/v2/TurnStartParams.json
index 071bc2ac3e..3af55e7294 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/TurnStartParams.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/TurnStartParams.json
@@ -98,6 +98,217 @@
],
"type": "object"
},
+ "FileSystemAccessMode": {
+ "enum": [
+ "read",
+ "write",
+ "none"
+ ],
+ "type": "string"
+ },
+ "FileSystemPath": {
+ "oneOf": [
+ {
+ "properties": {
+ "path": {
+ "$ref": "#/definitions/AbsolutePathBuf"
+ },
+ "type": {
+ "enum": [
+ "path"
+ ],
+ "title": "PathFileSystemPathType",
+ "type": "string"
+ }
+ },
+ "required": [
+ "path",
+ "type"
+ ],
+ "title": "PathFileSystemPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "pattern": {
+ "type": "string"
+ },
+ "type": {
+ "enum": [
+ "glob_pattern"
+ ],
+ "title": "GlobPatternFileSystemPathType",
+ "type": "string"
+ }
+ },
+ "required": [
+ "pattern",
+ "type"
+ ],
+ "title": "GlobPatternFileSystemPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "type": {
+ "enum": [
+ "special"
+ ],
+ "title": "SpecialFileSystemPathType",
+ "type": "string"
+ },
+ "value": {
+ "$ref": "#/definitions/FileSystemSpecialPath"
+ }
+ },
+ "required": [
+ "type",
+ "value"
+ ],
+ "title": "SpecialFileSystemPath",
+ "type": "object"
+ }
+ ]
+ },
+ "FileSystemSandboxEntry": {
+ "properties": {
+ "access": {
+ "$ref": "#/definitions/FileSystemAccessMode"
+ },
+ "path": {
+ "$ref": "#/definitions/FileSystemPath"
+ }
+ },
+ "required": [
+ "access",
+ "path"
+ ],
+ "type": "object"
+ },
+ "FileSystemSpecialPath": {
+ "oneOf": [
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "root"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "RootFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "minimal"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "MinimalFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "current_working_directory"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "CurrentWorkingDirectoryFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "project_roots"
+ ],
+ "type": "string"
+ },
+ "subpath": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "KindFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "tmpdir"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "TmpdirFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "slash_tmp"
+ ],
+ "type": "string"
+ }
+ },
+ "required": [
+ "kind"
+ ],
+ "title": "SlashTmpFileSystemSpecialPath",
+ "type": "object"
+ },
+ {
+ "properties": {
+ "kind": {
+ "enum": [
+ "unknown"
+ ],
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "subpath": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "kind",
+ "path"
+ ],
+ "type": "object"
+ }
+ ]
+ },
"ModeKind": {
"description": "Initial collaboration mode to use when the TUI starts.",
"enum": [
@@ -113,6 +324,64 @@
],
"type": "string"
},
+ "PermissionProfile": {
+ "properties": {
+ "fileSystem": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfileFileSystemPermissions"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "network": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfileNetworkPermissions"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "type": "object"
+ },
+ "PermissionProfileFileSystemPermissions": {
+ "properties": {
+ "entries": {
+ "items": {
+ "$ref": "#/definitions/FileSystemSandboxEntry"
+ },
+ "type": "array"
+ },
+ "globScanMaxDepth": {
+ "format": "uint",
+ "minimum": 1.0,
+ "type": [
+ "integer",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "entries"
+ ],
+ "type": "object"
+ },
+ "PermissionProfileNetworkPermissions": {
+ "properties": {
+ "enabled": {
+ "type": [
+ "boolean",
+ "null"
+ ]
+ }
+ },
+ "type": "object"
+ },
"Personality": {
"enum": [
"none",
@@ -570,6 +839,17 @@
"outputSchema": {
"description": "Optional JSON Schema used to constrain the final assistant message for this turn."
},
+ "permissionProfile": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/PermissionProfile"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Override the full permissions profile for this turn and subsequent turns. Cannot be combined with `sandboxPolicy`."
+ },
"personality": {
"anyOf": [
{
diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ThreadForkParams.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ThreadForkParams.ts
index a7ba311803..bd73b3c3c3 100644
--- a/codex-rs/app-server-protocol/schema/typescript/v2/ThreadForkParams.ts
+++ b/codex-rs/app-server-protocol/schema/typescript/v2/ThreadForkParams.ts
@@ -5,6 +5,7 @@ import type { ServiceTier } from "../ServiceTier";
import type { JsonValue } from "../serde_json/JsonValue";
import type { ApprovalsReviewer } from "./ApprovalsReviewer";
import type { AskForApproval } from "./AskForApproval";
+import type { PermissionProfile } from "./PermissionProfile";
import type { SandboxMode } from "./SandboxMode";
/**
@@ -27,7 +28,11 @@ model?: string | null, modelProvider?: string | null, serviceTier?: ServiceTier
* Override where approval requests are routed for review on this thread
* and subsequent turns.
*/
-approvalsReviewer?: ApprovalsReviewer | null, sandbox?: SandboxMode | null, config?: { [key in string]?: JsonValue } | null, baseInstructions?: string | null, developerInstructions?: string | null, ephemeral?: boolean, /**
+approvalsReviewer?: ApprovalsReviewer | null, sandbox?: SandboxMode | null, /**
+ * Full permissions override for the forked thread. Cannot be combined
+ * with `sandbox`.
+ */
+permissionProfile?: PermissionProfile | null, config?: { [key in string]?: JsonValue } | null, baseInstructions?: string | null, developerInstructions?: string | null, ephemeral?: boolean, /**
* If true, persist additional rollout EventMsg variants required to
* reconstruct a richer thread history on subsequent resume/fork/read.
*/
diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ThreadResumeParams.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ThreadResumeParams.ts
index 770344de8e..d245efe4a2 100644
--- a/codex-rs/app-server-protocol/schema/typescript/v2/ThreadResumeParams.ts
+++ b/codex-rs/app-server-protocol/schema/typescript/v2/ThreadResumeParams.ts
@@ -7,6 +7,7 @@ import type { ServiceTier } from "../ServiceTier";
import type { JsonValue } from "../serde_json/JsonValue";
import type { ApprovalsReviewer } from "./ApprovalsReviewer";
import type { AskForApproval } from "./AskForApproval";
+import type { PermissionProfile } from "./PermissionProfile";
import type { SandboxMode } from "./SandboxMode";
/**
@@ -36,7 +37,11 @@ model?: string | null, modelProvider?: string | null, serviceTier?: ServiceTier
* Override where approval requests are routed for review on this thread
* and subsequent turns.
*/
-approvalsReviewer?: ApprovalsReviewer | null, sandbox?: SandboxMode | null, config?: { [key in string]?: JsonValue } | null, baseInstructions?: string | null, developerInstructions?: string | null, personality?: Personality | null, /**
+approvalsReviewer?: ApprovalsReviewer | null, sandbox?: SandboxMode | null, /**
+ * Full permissions override for the resumed thread. Cannot be combined
+ * with `sandbox`.
+ */
+permissionProfile?: PermissionProfile | null, config?: { [key in string]?: JsonValue } | null, baseInstructions?: string | null, developerInstructions?: string | null, personality?: Personality | null, /**
* If true, persist additional rollout EventMsg variants required to
* reconstruct a richer thread history on subsequent resume/fork/read.
*/
diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ThreadStartParams.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ThreadStartParams.ts
index 904487e81c..8b9dafec9f 100644
--- a/codex-rs/app-server-protocol/schema/typescript/v2/ThreadStartParams.ts
+++ b/codex-rs/app-server-protocol/schema/typescript/v2/ThreadStartParams.ts
@@ -6,6 +6,7 @@ import type { ServiceTier } from "../ServiceTier";
import type { JsonValue } from "../serde_json/JsonValue";
import type { ApprovalsReviewer } from "./ApprovalsReviewer";
import type { AskForApproval } from "./AskForApproval";
+import type { PermissionProfile } from "./PermissionProfile";
import type { SandboxMode } from "./SandboxMode";
import type { ThreadStartSource } from "./ThreadStartSource";
@@ -13,7 +14,11 @@ export type ThreadStartParams = {model?: string | null, modelProvider?: string |
* Override where approval requests are routed for review on this thread
* and subsequent turns.
*/
-approvalsReviewer?: ApprovalsReviewer | null, sandbox?: SandboxMode | null, config?: { [key in string]?: JsonValue } | null, serviceName?: string | null, baseInstructions?: string | null, developerInstructions?: string | null, personality?: Personality | null, ephemeral?: boolean | null, sessionStartSource?: ThreadStartSource | null, /**
+approvalsReviewer?: ApprovalsReviewer | null, sandbox?: SandboxMode | null, /**
+ * Full permissions override for this thread. Cannot be combined with
+ * `sandbox`.
+ */
+permissionProfile?: PermissionProfile | null, config?: { [key in string]?: JsonValue } | null, serviceName?: string | null, baseInstructions?: string | null, developerInstructions?: string | null, personality?: Personality | null, ephemeral?: boolean | null, sessionStartSource?: ThreadStartSource | null, /**
* If true, opt into emitting raw Responses API items on the event stream.
* This is for internal use only (e.g. Codex Cloud).
*/
diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/TurnStartParams.ts b/codex-rs/app-server-protocol/schema/typescript/v2/TurnStartParams.ts
index 8f57a5e68b..3d12e6001c 100644
--- a/codex-rs/app-server-protocol/schema/typescript/v2/TurnStartParams.ts
+++ b/codex-rs/app-server-protocol/schema/typescript/v2/TurnStartParams.ts
@@ -9,6 +9,7 @@ import type { ServiceTier } from "../ServiceTier";
import type { JsonValue } from "../serde_json/JsonValue";
import type { ApprovalsReviewer } from "./ApprovalsReviewer";
import type { AskForApproval } from "./AskForApproval";
+import type { PermissionProfile } from "./PermissionProfile";
import type { SandboxPolicy } from "./SandboxPolicy";
import type { UserInput } from "./UserInput";
@@ -26,6 +27,10 @@ approvalsReviewer?: ApprovalsReviewer | null, /**
* Override the sandbox policy for this turn and subsequent turns.
*/
sandboxPolicy?: SandboxPolicy | null, /**
+ * Override the full permissions profile for this turn and subsequent
+ * turns. Cannot be combined with `sandboxPolicy`.
+ */
+permissionProfile?: PermissionProfile | null, /**
* Override the model for this turn and subsequent turns.
*/
model?: string | null, /**
diff --git a/codex-rs/app-server-protocol/src/protocol/v2.rs b/codex-rs/app-server-protocol/src/protocol/v2.rs
index e15fe5dab9..2e492e3797 100644
--- a/codex-rs/app-server-protocol/src/protocol/v2.rs
+++ b/codex-rs/app-server-protocol/src/protocol/v2.rs
@@ -3147,6 +3147,10 @@ pub struct ThreadStartParams {
pub approvals_reviewer: Option<ApprovalsReviewer>,
#[ts(optional = nullable)]
pub sandbox: Option<SandboxMode>,
+ /// Full permissions override for this thread. Cannot be combined with
+ /// `sandbox`.
+ #[ts(optional = nullable)]
+ pub permission_profile: Option<PermissionProfile>,
#[ts(optional = nullable)]
pub config: Option<HashMap<String, JsonValue>>,
#[ts(optional = nullable)]
@@ -3280,6 +3284,10 @@ pub struct ThreadResumeParams {
pub approvals_reviewer: Option<ApprovalsReviewer>,
#[ts(optional = nullable)]
pub sandbox: Option<SandboxMode>,
+ /// Full permissions override for the resumed thread. Cannot be combined
+ /// with `sandbox`.
+ #[ts(optional = nullable)]
+ pub permission_profile: Option<PermissionProfile>,
#[ts(optional = nullable)]
pub config: Option<HashMap<String, serde_json::Value>>,
#[ts(optional = nullable)]
@@ -3368,6 +3376,10 @@ pub struct ThreadForkParams {
pub approvals_reviewer: Option<ApprovalsReviewer>,
#[ts(optional = nullable)]
pub sandbox: Option<SandboxMode>,
+ /// Full permissions override for the forked thread. Cannot be combined
+ /// with `sandbox`.
+ #[ts(optional = nullable)]
+ pub permission_profile: Option<PermissionProfile>,
#[ts(optional = nullable)]
pub config: Option<HashMap<String, serde_json::Value>>,
#[ts(optional = nullable)]
@@ -4816,6 +4828,10 @@ pub struct TurnStartParams {
/// Override the sandbox policy for this turn and subsequent turns.
#[ts(optional = nullable)]
pub sandbox_policy: Option<SandboxPolicy>,
+ /// Override the full permissions profile for this turn and subsequent
+ /// turns. Cannot be combined with `sandboxPolicy`.
+ #[ts(optional = nullable)]
+ pub permission_profile: Option<PermissionProfile>,
/// Override the model for this turn and subsequent turns.
#[ts(optional = nullable)]
pub model: Option<String>,
@@ -10007,6 +10023,7 @@ mod tests {
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
model: None,
service_tier: None,
effort: None,
diff --git a/codex-rs/app-server/README.md b/codex-rs/app-server/README.md
index 2452cba36b..62e490dee3 100644
--- a/codex-rs/app-server/README.md
+++ b/codex-rs/app-server/README.md
@@ -82,7 +82,7 @@ Use the thread APIs to create, list, or archive conversations. Drive a conversat
- Initialize once per connection: Immediately after opening a transport connection, send an `initialize` request with your client metadata, then emit an `initialized` notification. Any other request on that connection before this handshake gets rejected.
- Start (or resume) a thread: Call `thread/start` to open a fresh conversation. The response returns the thread object and you’ll also get a `thread/started` notification. If you’re continuing an existing conversation, call `thread/resume` with its ID instead. If you want to branch from an existing conversation, call `thread/fork` to create a new thread id with copied history. Like `thread/start`, `thread/fork` also accepts `ephemeral: true` for an in-memory temporary thread.
The returned `thread.ephemeral` flag tells you whether the session is intentionally in-memory only; when it is `true`, `thread.path` is `null`.
-- Begin a turn: To send user input, call `turn/start` with the target `threadId` and the user's input. Optional fields let you override model, cwd, sandbox policy, approval policy, approvals reviewer, etc. This immediately returns the new turn object. The app-server emits `turn/started` when that turn actually begins running.
+- Begin a turn: To send user input, call `turn/start` with the target `threadId` and the user's input. Optional fields let you override model, cwd, sandbox policy or `permissionProfile`, approval policy, approvals reviewer, etc. This immediately returns the new turn object. The app-server emits `turn/started` when that turn actually begins running.
- Stream events: After `turn/start`, keep reading JSON-RPC notifications on stdout. You’ll see `item/started`, `item/completed`, deltas like `item/agentMessage/delta`, tool progress, etc. These represent streaming model output plus any side effects (commands, tool calls, reasoning notes).
- Finish the turn: When the model is done (or the turn is interrupted via making the `turn/interrupt` call), the server sends `turn/completed` with the final turn state and token usage.
@@ -136,9 +136,9 @@ Example with notification opt-out:
## API Overview
-- `thread/start` — create a new thread; emits `thread/started` (including the current `thread.status`) and auto-subscribes you to turn/item events for that thread. When the request includes a `cwd` and the resolved sandbox is `workspace-write` or full access, app-server also marks that project as trusted in the user `config.toml`. Pass `sessionStartSource: "clear"` when starting a replacement thread after clearing the current session so `SessionStart` hooks receive `source: "clear"` instead of the default `"startup"`.
-- `thread/resume` — reopen an existing thread by id so subsequent `turn/start` calls append to it.
-- `thread/fork` — fork an existing thread into a new thread id by copying the stored history; if the source thread is currently mid-turn, the fork records the same interruption marker as `turn/interrupt` instead of inheriting an unmarked partial turn suffix. The returned `thread.forkedFromId` points at the source thread when known. Accepts `ephemeral: true` for an in-memory temporary fork, emits `thread/started` (including the current `thread.status`), and auto-subscribes you to turn/item events for the new thread.
+- `thread/start` — create a new thread; emits `thread/started` (including the current `thread.status`) and auto-subscribes you to turn/item events for that thread. When the request includes a `cwd` and the resolved sandbox is `workspace-write` or full access, app-server also marks that project as trusted in the user `config.toml`. Pass `sessionStartSource: "clear"` when starting a replacement thread after clearing the current session so `SessionStart` hooks receive `source: "clear"` instead of the default `"startup"`. For permissions, prefer `permissionProfile`; the legacy `sandbox` shorthand is still accepted but cannot be combined with `permissionProfile`.
+- `thread/resume` — reopen an existing thread by id so subsequent `turn/start` calls append to it. Accepts the same permission override rules as `thread/start`.
+- `thread/fork` — fork an existing thread into a new thread id by copying the stored history; if the source thread is currently mid-turn, the fork records the same interruption marker as `turn/interrupt` instead of inheriting an unmarked partial turn suffix. The returned `thread.forkedFromId` points at the source thread when known. Accepts `ephemeral: true` for an in-memory temporary fork, emits `thread/started` (including the current `thread.status`), and auto-subscribes you to turn/item events for the new thread. Accepts the same permission override rules as `thread/start`.
- `thread/list` — page through stored rollouts; supports cursor-based pagination and optional `modelProviders`, `sourceKinds`, `archived`, `cwd`, and `searchTerm` filters. Each returned `thread` includes `status` (`ThreadStatus`), defaulting to `notLoaded` when the thread is not currently loaded.
- `thread/loaded/list` — list the thread ids currently loaded in memory.
- `thread/read` — read a stored thread by id without resuming it; optionally include turns via `includeTurns`. The returned `thread` includes `status` (`ThreadStatus`), defaulting to `notLoaded` when the thread is not currently loaded.
@@ -155,7 +155,7 @@ Example with notification opt-out:
- `thread/shellCommand` — run a user-initiated `!` shell command against a thread; this runs unsandboxed with full access rather than inheriting the thread sandbox policy. Returns `{}` immediately while progress streams through standard turn/item notifications and any active turn receives the formatted output in its message stream.
- `thread/backgroundTerminals/clean` — terminate all running background terminals for a thread (experimental; requires `capabilities.experimentalApi`); returns `{}` when the cleanup request is accepted.
- `thread/rollback` — drop the last N turns from the agent’s in-memory context and persist a rollback marker in the rollout so future resumes see the pruned history; returns the updated `thread` (with `turns` populated) on success.
-- `turn/start` — add user input to a thread and begin Codex generation; responds with the initial `turn` object and streams `turn/started`, `item/*`, and `turn/completed` notifications. For `collaborationMode`, `settings.developer_instructions: null` means "use built-in instructions for the selected mode".
+- `turn/start` — add user input to a thread and begin Codex generation; responds with the initial `turn` object and streams `turn/started`, `item/*`, and `turn/completed` notifications. Prefer `permissionProfile` for permission overrides; the legacy `sandboxPolicy` field is still accepted but cannot be combined with `permissionProfile`. For `collaborationMode`, `settings.developer_instructions: null` means "use built-in instructions for the selected mode".
- `thread/inject_items` — append raw Responses API items to a loaded thread’s model-visible history without starting a user turn; returns `{}` on success.
- `turn/steer` — add user input to an already in-flight regular turn without starting a new turn; returns the active `turnId` that accepted the input. Review and manual compaction turns reject `turn/steer`.
- `turn/interrupt` — request cancellation of an in-flight turn by `(thread_id, turn_id)`; success is an empty `{}` response and the turn finishes with `status: "interrupted"`.
@@ -223,6 +223,8 @@ Start a fresh thread when you need a new Codex conversation.
"cwd": "/Users/me/project",
"approvalPolicy": "never",
"sandbox": "workspaceWrite",
+ // Prefer "permissionProfile" for full permission overrides. Do not send
+ // both "sandbox" and "permissionProfile".
"personality": "friendly",
"serviceName": "my_app_server_client", // optional metrics tag (`service_name`)
"sessionStartSource": "startup", // optional: "startup" (default) or "clear"
@@ -545,6 +547,8 @@ You can optionally specify config overrides on the new turn. If specified, these
"writableRoots": ["/Users/me/project"],
"networkAccess": true
},
+ // Prefer "permissionProfile" for full permission overrides. Do not send
+ // both "sandboxPolicy" and "permissionProfile".
"model": "gpt-5.1-codex",
"effort": "medium",
"summary": "concise",
diff --git a/codex-rs/app-server/src/codex_message_processor.rs b/codex-rs/app-server/src/codex_message_processor.rs
index 0eb465e54a..1ab367d078 100644
--- a/codex-rs/app-server/src/codex_message_processor.rs
+++ b/codex-rs/app-server/src/codex_message_processor.rs
@@ -103,6 +103,7 @@ use codex_app_server_protocol::MockExperimentalMethodParams;
use codex_app_server_protocol::MockExperimentalMethodResponse;
use codex_app_server_protocol::ModelListParams;
use codex_app_server_protocol::ModelListResponse;
+use codex_app_server_protocol::PermissionProfile as ApiPermissionProfile;
use codex_app_server_protocol::PluginDetail;
use codex_app_server_protocol::PluginInstallParams;
use codex_app_server_protocol::PluginInstallResponse;
@@ -218,6 +219,7 @@ use codex_backend_client::Client as BackendClient;
use codex_chatgpt::connectors;
use codex_config::types::McpServerTransportConfig;
use codex_core::CodexThread;
+use codex_core::CodexThreadTurnContextOverrides;
use codex_core::ForkSnapshot;
use codex_core::NewThread;
use codex_core::RolloutRecorder;
@@ -2349,6 +2351,7 @@ impl CodexMessageProcessor {
approval_policy,
approvals_reviewer,
sandbox,
+ permission_profile,
config,
service_name,
base_instructions,
@@ -2361,6 +2364,14 @@ impl CodexMessageProcessor {
session_start_source,
persist_extended_history,
} = params;
+ if sandbox.is_some() && permission_profile.is_some() {
+ self.send_invalid_request_error(
+ request_id,
+ "`permissionProfile` cannot be combined with `sandbox`".to_string(),
+ )
+ .await;
+ return;
+ }
let mut typesafe_overrides = self.build_thread_config_overrides(
model,
model_provider,
@@ -2369,6 +2380,7 @@ impl CodexMessageProcessor {
approval_policy,
approvals_reviewer,
sandbox,
+ permission_profile,
base_instructions,
developer_instructions,
personality,
@@ -2498,17 +2510,12 @@ impl CodexMessageProcessor {
// could be downgraded to ReadOnly (perhaps there is no sandbox
// available on Windows or the enterprise config disallows it). The cwd
// should still be considered "trusted" in this case.
- let requested_sandbox_trusts_project = matches!(
- typesafe_overrides.sandbox_mode,
- Some(
- codex_protocol::config_types::SandboxMode::WorkspaceWrite
- | codex_protocol::config_types::SandboxMode::DangerFullAccess
- )
- );
+ let requested_permissions_trust_project =
+ requested_permissions_trust_project(&typesafe_overrides, config.cwd.as_path());
if requested_cwd.is_some()
&& !config.active_project.is_trusted()
- && (requested_sandbox_trusts_project
+ && (requested_permissions_trust_project
|| matches!(
config.permissions.sandbox_policy.get(),
codex_protocol::protocol::SandboxPolicy::WorkspaceWrite { .. }
@@ -2775,6 +2782,7 @@ impl CodexMessageProcessor {
approval_policy: Option<codex_app_server_protocol::AskForApproval>,
approvals_reviewer: Option<codex_app_server_protocol::ApprovalsReviewer>,
sandbox: Option<SandboxMode>,
+ permission_profile: Option<ApiPermissionProfile>,
base_instructions: Option<String>,
developer_instructions: Option<String>,
personality: Option<Personality>,
@@ -2789,6 +2797,7 @@ impl CodexMessageProcessor {
approvals_reviewer: approvals_reviewer
.map(codex_app_server_protocol::ApprovalsReviewer::to_core),
sandbox_mode: sandbox.map(SandboxMode::to_core),
+ permission_profile: permission_profile.map(Into::into),
codex_linux_sandbox_exe: self.arg0_paths.codex_linux_sandbox_exe.clone(),
main_execve_wrapper_exe: self.arg0_paths.main_execve_wrapper_exe.clone(),
base_instructions,
@@ -4341,6 +4350,15 @@ impl CodexMessageProcessor {
return;
}
+ if params.sandbox.is_some() && params.permission_profile.is_some() {
+ self.send_invalid_request_error(
+ request_id,
+ "`permissionProfile` cannot be combined with `sandbox`".to_string(),
+ )
+ .await;
+ return;
+ }
+
if self
.resume_running_thread(request_id.clone(), &params)
.await
@@ -4359,6 +4377,7 @@ impl CodexMessageProcessor {
approval_policy,
approvals_reviewer,
sandbox,
+ permission_profile,
config: mut request_overrides,
base_instructions,
developer_instructions,
@@ -4393,6 +4412,7 @@ impl CodexMessageProcessor {
approval_policy,
approvals_reviewer,
sandbox,
+ permission_profile,
base_instructions,
developer_instructions,
personality,
@@ -4894,12 +4914,21 @@ impl CodexMessageProcessor {
approval_policy,
approvals_reviewer,
sandbox,
+ permission_profile,
config: cli_overrides,
base_instructions,
developer_instructions,
ephemeral,
persist_extended_history,
} = params;
+ if sandbox.is_some() && permission_profile.is_some() {
+ self.send_invalid_request_error(
+ request_id,
+ "`permissionProfile` cannot be combined with `sandbox`".to_string(),
+ )
+ .await;
+ return;
+ }
let (rollout_path, source_thread_id) = if let Some(path) = path {
(path, None)
@@ -4976,6 +5005,7 @@ impl CodexMessageProcessor {
approval_policy,
approvals_reviewer,
sandbox,
+ permission_profile,
base_instructions,
developer_instructions,
/*personality*/ None,
@@ -6800,6 +6830,7 @@ impl CodexMessageProcessor {
|| params.approval_policy.is_some()
|| params.approvals_reviewer.is_some()
|| params.sandbox_policy.is_some()
+ || params.permission_profile.is_some()
|| params.model.is_some()
|| params.service_tier.is_some()
|| params.effort.is_some()
@@ -6807,43 +6838,88 @@ impl CodexMessageProcessor {
|| collaboration_mode.is_some()
|| params.personality.is_some();
- // If any overrides are provided, update the session turn context first.
+ if params.sandbox_policy.is_some() && params.permission_profile.is_some() {
+ self.send_invalid_request_error(
+ request_id,
+ "`permissionProfile` cannot be combined with `sandboxPolicy`".to_string(),
+ )
+ .await;
+ return;
+ }
+
+ let cwd = params.cwd;
+ let approval_policy = params.approval_policy.map(AskForApproval::to_core);
+ let approvals_reviewer = params
+ .approvals_reviewer
+ .map(codex_app_server_protocol::ApprovalsReviewer::to_core);
+ let sandbox_policy = params.sandbox_policy.map(|p| p.to_core());
+ let permission_profile = params.permission_profile.map(Into::into);
+ let model = params.model;
+ let effort = params.effort.map(Some);
+ let summary = params.summary;
+ let service_tier = params.service_tier;
+ let personality = params.personality;
+
+ // If any overrides are provided, validate them synchronously so the
+ // request can fail before accepting user input. The actual update is
+ // still queued together with the input below to preserve submission order.
if has_any_overrides {
- let _ = self
- .submit_core_op(
- &request_id,
- thread.as_ref(),
- Op::OverrideTurnContext {
- cwd: params.cwd,
- approval_policy: params.approval_policy.map(AskForApproval::to_core),
- approvals_reviewer: params
- .approvals_reviewer
- .map(codex_app_server_protocol::ApprovalsReviewer::to_core),
- sandbox_policy: params.sandbox_policy.map(|p| p.to_core()),
- windows_sandbox_level: None,
- model: params.model,
- effort: params.effort.map(Some),
- summary: params.summary,
- service_tier: params.service_tier,
- collaboration_mode,
- personality: params.personality,
- },
+ let result = thread
+ .validate_turn_context_overrides(CodexThreadTurnContextOverrides {
+ cwd: cwd.clone(),
+ approval_policy,
+ approvals_reviewer,
+ sandbox_policy: sandbox_policy.clone(),
+ permission_profile: permission_profile.clone(),
+ windows_sandbox_level: None,
+ model: model.clone(),
+ effort,
+ summary,
+ service_tier,
+ collaboration_mode: collaboration_mode.clone(),
+ personality,
+ })
+ .await;
+ if let Err(err) = result {
+ self.send_invalid_request_error(
+ request_id,
+ format!("invalid turn context override: {err}"),
)
.await;
+ return;
+ }
}
// Start the turn by submitting the user input. Return its submission id as turn_id.
+ let turn_op = if has_any_overrides {
+ Op::UserInputWithTurnContext {
+ items: mapped_items,
+ environments,
+ final_output_json_schema: params.output_schema,
+ responsesapi_client_metadata: params.responsesapi_client_metadata,
+ cwd,
+ approval_policy,
+ approvals_reviewer,
+ sandbox_policy,
+ permission_profile,
+ windows_sandbox_level: None,
+ model,
+ effort,
+ summary,
+ service_tier,
+ collaboration_mode,
+ personality,
+ }
+ } else {
+ Op::UserInput {
+ items: mapped_items,
+ environments,
+ final_output_json_schema: params.output_schema,
+ responsesapi_client_metadata: params.responsesapi_client_metadata,
+ }
+ };
let turn_id = self
- .submit_core_op(
- &request_id,
- thread.as_ref(),
- Op::UserInput {
- items: mapped_items,
- environments,
- final_output_json_schema: params.output_schema,
- responsesapi_client_metadata: params.responsesapi_client_metadata,
- },
- )
+ .submit_core_op(&request_id, thread.as_ref(), turn_op)
.await;
match turn_id {
@@ -8753,6 +8829,16 @@ fn collect_resume_override_mismatches(
));
}
}
+ if let Some(requested_permission_profile) = request.permission_profile.as_ref() {
+ let requested_permission_profile =
+ codex_protocol::models::PermissionProfile::from(requested_permission_profile.clone());
+ if requested_permission_profile != config_snapshot.permission_profile {
+ mismatch_details.push(format!(
+ "permission_profile requested={requested_permission_profile:?} active={:?}",
+ config_snapshot.permission_profile
+ ));
+ }
+ }
if let Some(requested_personality) = request.personality.as_ref()
&& config_snapshot.personality.as_ref() != Some(requested_personality)
{
@@ -9685,6 +9771,34 @@ fn thread_response_permission_profile(
}
}
+fn requested_permissions_trust_project(overrides: &ConfigOverrides, cwd: &Path) -> bool {
+ if matches!(
+ overrides.sandbox_mode,
+ Some(
+ codex_protocol::config_types::SandboxMode::WorkspaceWrite
+ | codex_protocol::config_types::SandboxMode::DangerFullAccess
+ )
+ ) {
+ return true;
+ }
+
+ overrides
+ .permission_profile
+ .as_ref()
+ .is_some_and(|profile| {
+ profile
+ .to_legacy_sandbox_policy(cwd)
+ .is_ok_and(|sandbox_policy| {
+ matches!(
+ sandbox_policy,
+ codex_protocol::protocol::SandboxPolicy::WorkspaceWrite { .. }
+ | codex_protocol::protocol::SandboxPolicy::DangerFullAccess
+ | codex_protocol::protocol::SandboxPolicy::ExternalSandbox { .. }
+ )
+ })
+ })
+}
+
fn parse_datetime(timestamp: Option<&str>) -> Option<DateTime<Utc>> {
timestamp.and_then(|ts| {
chrono::DateTime::parse_from_rfc3339(ts)
@@ -10196,6 +10310,48 @@ mod tests {
);
}
+ #[test]
+ fn requested_permissions_trust_project_uses_permission_profile_intent() {
+ let cwd = test_path_buf("/tmp/project").abs();
+ let full_access_profile =
+ codex_protocol::models::PermissionProfile::from_legacy_sandbox_policy(
+ &SandboxPolicy::DangerFullAccess,
+ cwd.as_path(),
+ );
+ let workspace_write_profile =
+ codex_protocol::models::PermissionProfile::from_legacy_sandbox_policy(
+ &SandboxPolicy::new_workspace_write_policy(),
+ cwd.as_path(),
+ );
+ let read_only_profile =
+ codex_protocol::models::PermissionProfile::from_legacy_sandbox_policy(
+ &SandboxPolicy::new_read_only_policy(),
+ cwd.as_path(),
+ );
+
+ assert!(requested_permissions_trust_project(
+ &ConfigOverrides {
+ permission_profile: Some(full_access_profile),
+ ..Default::default()
+ },
+ cwd.as_path()
+ ));
+ assert!(requested_permissions_trust_project(
+ &ConfigOverrides {
+ permission_profile: Some(workspace_write_profile),
+ ..Default::default()
+ },
+ cwd.as_path()
+ ));
+ assert!(!requested_permissions_trust_project(
+ &ConfigOverrides {
+ permission_profile: Some(read_only_profile),
+ ..Default::default()
+ },
+ cwd.as_path()
+ ));
+ }
+
#[test]
fn config_load_error_marks_cloud_requirements_failures_for_relogin() {
let err = std::io::Error::other(CloudRequirementsLoadError::new(
@@ -10322,6 +10478,7 @@ mod tests {
#[test]
fn collect_resume_override_mismatches_includes_service_tier() {
+ let cwd = test_path_buf("/tmp").abs();
let request = ThreadResumeParams {
thread_id: "thread-1".to_string(),
history: None,
@@ -10333,6 +10490,7 @@ mod tests {
approval_policy: None,
approvals_reviewer: None,
sandbox: None,
+ permission_profile: None,
config: None,
base_instructions: None,
developer_instructions: None,
@@ -10349,9 +10507,9 @@ mod tests {
permission_profile:
codex_protocol::models::PermissionProfile::from_legacy_sandbox_policy(
&codex_protocol::protocol::SandboxPolicy::DangerFullAccess,
- std::path::Path::new("/tmp"),
+ cwd.as_path(),
),
- cwd: test_path_buf("/tmp").abs(),
+ cwd,
ephemeral: false,
reasoning_effort: None,
personality: None,
diff --git a/codex-rs/app-server/src/message_processor/tracing_tests.rs b/codex-rs/app-server/src/message_processor/tracing_tests.rs
index 04178c70bf..e0a1ed4bc4 100644
--- a/codex-rs/app-server/src/message_processor/tracing_tests.rs
+++ b/codex-rs/app-server/src/message_processor/tracing_tests.rs
@@ -717,6 +717,7 @@ async fn turn_start_jsonrpc_span_parents_core_turn_spans() -> Result<()> {
cwd: None,
approval_policy: None,
sandbox_policy: None,
+ permission_profile: None,
approvals_reviewer: None,
model: None,
service_tier: None,
diff --git a/codex-rs/app-server/tests/suite/v2/skills_list.rs b/codex-rs/app-server/tests/suite/v2/skills_list.rs
index 8675b3a429..195c4a86db 100644
--- a/codex-rs/app-server/tests/suite/v2/skills_list.rs
+++ b/codex-rs/app-server/tests/suite/v2/skills_list.rs
@@ -315,6 +315,7 @@ async fn skills_changed_notification_is_emitted_after_skill_change() -> Result<(
approval_policy: None,
approvals_reviewer: None,
sandbox: None,
+ permission_profile: None,
config: None,
service_name: None,
base_instructions: None,
diff --git a/codex-rs/app-server/tests/suite/v2/turn_start.rs b/codex-rs/app-server/tests/suite/v2/turn_start.rs
index 93e2e4c802..c6eb58a432 100644
--- a/codex-rs/app-server/tests/suite/v2/turn_start.rs
+++ b/codex-rs/app-server/tests/suite/v2/turn_start.rs
@@ -26,6 +26,9 @@ use codex_app_server_protocol::FileChangeApprovalDecision;
use codex_app_server_protocol::FileChangeOutputDeltaNotification;
use codex_app_server_protocol::FileChangePatchUpdatedNotification;
use codex_app_server_protocol::FileChangeRequestApprovalResponse;
+use codex_app_server_protocol::FileSystemAccessMode;
+use codex_app_server_protocol::FileSystemPath;
+use codex_app_server_protocol::FileSystemSandboxEntry;
use codex_app_server_protocol::ItemCompletedNotification;
use codex_app_server_protocol::ItemStartedNotification;
use codex_app_server_protocol::JSONRPCError;
@@ -34,6 +37,8 @@ use codex_app_server_protocol::JSONRPCNotification;
use codex_app_server_protocol::JSONRPCResponse;
use codex_app_server_protocol::PatchApplyStatus;
use codex_app_server_protocol::PatchChangeKind;
+use codex_app_server_protocol::PermissionProfile;
+use codex_app_server_protocol::PermissionProfileFileSystemPermissions;
use codex_app_server_protocol::RequestId;
use codex_app_server_protocol::ServerRequest;
use codex_app_server_protocol::ServerRequestResolvedNotification;
@@ -59,6 +64,7 @@ use codex_protocol::config_types::ReasoningSummary;
use codex_protocol::config_types::Settings;
use codex_protocol::openai_models::ReasoningEffort;
use codex_protocol::user_input::MAX_USER_INPUT_TEXT_CHARS;
+use codex_utils_absolute_path::AbsolutePathBuf;
use core_test_support::responses;
use core_test_support::skip_if_no_network;
use pretty_assertions::assert_eq;
@@ -79,6 +85,7 @@ const DEFAULT_READ_TIMEOUT: std::time::Duration = std::time::Duration::from_secs
const DEFAULT_READ_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10);
const TEST_ORIGINATOR: &str = "codex_vscode";
const LOCAL_PRAGMATIC_TEMPLATE: &str = "You are a deeply pragmatic, effective software engineer.";
+const INVALID_REQUEST_ERROR_CODE: i64 = -32600;
fn body_contains(req: &wiremock::Request, text: &str) -> bool {
String::from_utf8(req.body.clone())
@@ -736,6 +743,83 @@ async fn turn_start_rejects_combined_oversized_text_input() -> Result<()> {
Ok(())
}
+#[tokio::test]
+async fn turn_start_rejects_invalid_permission_profile_before_starting_turn() -> Result<()> {
+ let codex_home = TempDir::new()?;
+ let unsupported_write_root = TempDir::new()?;
+ create_config_toml(
+ codex_home.path(),
+ "http://localhost/unused",
+ "never",
+ &BTreeMap::from([(Feature::Personality, true)]),
+ )?;
+
+ let mut mcp = McpProcess::new(codex_home.path()).await?;
+ timeout(DEFAULT_READ_TIMEOUT, mcp.initialize()).await??;
+
+ let thread_req = mcp
+ .send_thread_start_request(ThreadStartParams {
+ model: Some("mock-model".to_string()),
+ ..Default::default()
+ })
+ .await?;
+ let thread_resp: JSONRPCResponse = timeout(
+ DEFAULT_READ_TIMEOUT,
+ mcp.read_stream_until_response_message(RequestId::Integer(thread_req)),
+ )
+ .await??;
+ let ThreadStartResponse { thread, .. } = to_response::<ThreadStartResponse>(thread_resp)?;
+ let unsupported_write_root = AbsolutePathBuf::from_absolute_path(unsupported_write_root.path())
+ .expect("tempdir path should be absolute");
+
+ let turn_req = mcp
+ .send_turn_start_request(TurnStartParams {
+ thread_id: thread.id,
+ input: vec![V2UserInput::Text {
+ text: "Hello".to_string(),
+ text_elements: Vec::new(),
+ }],
+ permission_profile: Some(PermissionProfile {
+ network: None,
+ file_system: Some(PermissionProfileFileSystemPermissions {
+ entries: vec![FileSystemSandboxEntry {
+ path: FileSystemPath::Path {
+ path: unsupported_write_root,
+ },
+ access: FileSystemAccessMode::Write,
+ }],
+ glob_scan_max_depth: None,
+ }),
+ }),
+ ..Default::default()
+ })
+ .await?;
+ let err: JSONRPCError = timeout(
+ DEFAULT_READ_TIMEOUT,
+ mcp.read_stream_until_error_message(RequestId::Integer(turn_req)),
+ )
+ .await??;
+
+ assert_eq!(err.error.code, INVALID_REQUEST_ERROR_CODE);
+ assert!(err.error.message.contains("invalid turn context override"));
+ assert!(
+ err.error
+ .message
+ .contains("filesystem writes outside the workspace root")
+ );
+ let turn_started = tokio::time::timeout(
+ std::time::Duration::from_millis(250),
+ mcp.read_stream_until_notification_message("turn/started"),
+ )
+ .await;
+ assert!(
+ turn_started.is_err(),
+ "did not expect a turn/started notification after rejected permissionProfile"
+ );
+
+ Ok(())
+}
+
#[tokio::test]
async fn turn_start_emits_notifications_and_accepts_model_override() -> Result<()> {
// Provide a mock server and config so model wiring is valid.
@@ -1750,6 +1834,7 @@ async fn turn_start_updates_sandbox_and_cwd_between_turns_v2() -> Result<()> {
exclude_tmpdir_env_var: false,
exclude_slash_tmp: false,
}),
+ permission_profile: None,
model: Some("mock-model".to_string()),
effort: Some(ReasoningEffort::Medium),
summary: Some(ReasoningSummary::Auto),
@@ -1785,6 +1870,7 @@ async fn turn_start_updates_sandbox_and_cwd_between_turns_v2() -> Result<()> {
approval_policy: Some(codex_app_server_protocol::AskForApproval::Never),
approvals_reviewer: None,
sandbox_policy: Some(codex_app_server_protocol::SandboxPolicy::DangerFullAccess),
+ permission_profile: None,
model: Some("mock-model".to_string()),
effort: Some(ReasoningEffort::Medium),
summary: Some(ReasoningSummary::Auto),
diff --git a/codex-rs/core/src/codex_thread.rs b/codex-rs/core/src/codex_thread.rs
index 7c8e9fa68a..cda2d22fb0 100644
--- a/codex-rs/core/src/codex_thread.rs
+++ b/codex-rs/core/src/codex_thread.rs
@@ -2,11 +2,15 @@ use crate::agent::AgentStatus;
use crate::config::ConstraintResult;
use crate::file_watcher::WatchRegistration;
use crate::session::Codex;
+use crate::session::SessionSettingsUpdate;
use crate::session::SteerInputError;
use codex_features::Feature;
use codex_protocol::config_types::ApprovalsReviewer;
+use codex_protocol::config_types::CollaborationMode;
use codex_protocol::config_types::Personality;
+use codex_protocol::config_types::ReasoningSummary;
use codex_protocol::config_types::ServiceTier;
+use codex_protocol::config_types::WindowsSandboxLevel;
use codex_protocol::error::CodexErr;
use codex_protocol::error::Result as CodexResult;
use codex_protocol::mcp::CallToolResult;
@@ -51,6 +55,23 @@ pub struct ThreadConfigSnapshot {
pub session_source: SessionSource,
}
+/// Turn context overrides that app-server validates before starting a turn.
+#[derive(Clone, Default)]
+pub struct CodexThreadTurnContextOverrides {
+ pub cwd: Option<PathBuf>,
+ pub approval_policy: Option<AskForApproval>,
+ pub approvals_reviewer: Option<ApprovalsReviewer>,
+ pub sandbox_policy: Option<SandboxPolicy>,
+ pub permission_profile: Option<PermissionProfile>,
+ pub windows_sandbox_level: Option<WindowsSandboxLevel>,
+ pub model: Option<String>,
+ pub effort: Option<Option<ReasoningEffort>>,
+ pub summary: Option<ReasoningSummary>,
+ pub service_tier: Option<Option<ServiceTier>>,
+ pub collaboration_mode: Option<CollaborationMode>,
+ pub personality: Option<Personality>,
+}
+
pub struct CodexThread {
pub(crate) codex: Codex,
rollout_path: Option<PathBuf>,
@@ -126,6 +147,51 @@ impl CodexThread {
.await
}
+ /// Validate persistent turn context overrides without committing them.
+ pub async fn validate_turn_context_overrides(
+ &self,
+ overrides: CodexThreadTurnContextOverrides,
+ ) -> ConstraintResult<()> {
+ let CodexThreadTurnContextOverrides {
+ cwd,
+ approval_policy,
+ approvals_reviewer,
+ sandbox_policy,
+ permission_profile,
+ windows_sandbox_level,
+ model,
+ effort,
+ summary,
+ service_tier,
+ collaboration_mode,
+ personality,
+ } = overrides;
+ let collaboration_mode = if let Some(collaboration_mode) = collaboration_mode {
+ collaboration_mode
+ } else {
+ self.codex
+ .session
+ .collaboration_mode()
+ .await
+ .with_updates(model, effort, /*developer_instructions*/ None)
+ };
+
+ let updates = SessionSettingsUpdate {
+ cwd,
+ approval_policy,
+ approvals_reviewer,
+ sandbox_policy,
+ permission_profile,
+ windows_sandbox_level,
+ collaboration_mode: Some(collaboration_mode),
+ reasoning_summary: summary,
+ service_tier,
+ personality,
+ ..Default::default()
+ };
+ self.codex.session.validate_settings(&updates).await
+ }
+
/// Use sparingly: this is intended to be removed soon.
pub async fn submit_with_id(&self, sub: Submission) -> CodexResult<()> {
self.codex.submit_with_id(sub).await
diff --git a/codex-rs/core/src/config/config_tests.rs b/codex-rs/core/src/config/config_tests.rs
index f6589ae23a..3765e31f56 100644
--- a/codex-rs/core/src/config/config_tests.rs
+++ b/codex-rs/core/src/config/config_tests.rs
@@ -54,6 +54,9 @@ use codex_model_provider_info::LMSTUDIO_OSS_PROVIDER_ID;
use codex_model_provider_info::OLLAMA_OSS_PROVIDER_ID;
use codex_model_provider_info::WireApi;
use codex_models_manager::bundled_models_response;
+use codex_protocol::models::FileSystemPermissions;
+use codex_protocol::models::NetworkPermissions;
+use codex_protocol::models::PermissionProfile;
use codex_protocol::permissions::FileSystemAccessMode;
use codex_protocol::permissions::FileSystemPath;
use codex_protocol::permissions::FileSystemSandboxEntry;
@@ -62,6 +65,7 @@ use codex_protocol::permissions::FileSystemSpecialPath;
use codex_protocol::permissions::NetworkSandboxPolicy;
use codex_protocol::protocol::ReadOnlyAccess;
use codex_protocol::protocol::RealtimeVoice;
+use codex_protocol::protocol::SandboxPolicy;
use serde::Deserialize;
use tempfile::tempdir;
@@ -801,6 +805,115 @@ async fn default_permissions_profile_populates_runtime_sandbox_policy() -> std::
Ok(())
}
+#[tokio::test]
+async fn permission_profile_override_populates_runtime_permissions() -> std::io::Result<()> {
+ let codex_home = TempDir::new()?;
+ let cwd = TempDir::new()?;
+ let permission_profile = PermissionProfile {
+ network: Some(NetworkPermissions {
+ enabled: Some(true),
+ }),
+ file_system: Some(FileSystemPermissions {
+ entries: vec![FileSystemSandboxEntry {
+ path: FileSystemPath::Special {
+ value: FileSystemSpecialPath::Root,
+ },
+ access: FileSystemAccessMode::Write,
+ }],
+ glob_scan_max_depth: None,
+ }),
+ };
+
+ let config = Config::load_from_base_config_with_overrides(
+ ConfigToml::default(),
+ ConfigOverrides {
+ cwd: Some(cwd.path().to_path_buf()),
+ permission_profile: Some(permission_profile.clone()),
+ ..Default::default()
+ },
+ codex_home.abs(),
+ )
+ .await?;
+
+ assert_eq!(config.permissions.permission_profile(), permission_profile);
+ assert_eq!(
+ config.permissions.sandbox_policy.get(),
+ &SandboxPolicy::DangerFullAccess
+ );
+ Ok(())
+}
+
+#[tokio::test]
+async fn permission_profile_override_preserves_configured_network_proxy() -> std::io::Result<()> {
+ let codex_home = TempDir::new()?;
+ let cwd = TempDir::new()?;
+ let permission_profile = PermissionProfile {
+ network: Some(NetworkPermissions {
+ enabled: Some(true),
+ }),
+ file_system: Some(FileSystemPermissions {
+ entries: vec![FileSystemSandboxEntry {
+ path: FileSystemPath::Special {
+ value: FileSystemSpecialPath::Root,
+ },
+ access: FileSystemAccessMode::Write,
+ }],
+ glob_scan_max_depth: None,
+ }),
+ };
+
+ let config = Config::load_from_base_config_with_overrides(
+ ConfigToml {
+ default_permissions: Some("workspace".to_string()),
+ permissions: Some(PermissionsToml {
+ entries: BTreeMap::from([(
+ "workspace".to_string(),
+ PermissionProfileToml {
+ filesystem: Some(FilesystemPermissionsToml {
+ glob_scan_max_depth: None,
+ entries: BTreeMap::from([(
+ ":minimal".to_string(),
+ FilesystemPermissionToml::Access(FileSystemAccessMode::Read),
+ )]),
+ }),
+ network: Some(NetworkToml {
+ enabled: Some(true),
+ proxy_url: Some("http://127.0.0.1:43128".to_string()),
+ enable_socks5: Some(false),
+ allow_upstream_proxy: Some(false),
+ domains: Some(NetworkDomainPermissionsToml {
+ entries: BTreeMap::from([(
+ "openai.com".to_string(),
+ NetworkDomainPermissionToml::Allow,
+ )]),
+ }),
+ ..Default::default()
+ }),
+ },
+ )]),
+ }),
+ ..Default::default()
+ },
+ ConfigOverrides {
+ cwd: Some(cwd.path().to_path_buf()),
+ permission_profile: Some(permission_profile.clone()),
+ ..Default::default()
+ },
+ codex_home.abs(),
+ )
+ .await?;
+ let network = config
+ .permissions
+ .network
+ .as_ref()
+ .expect("network-enabled override should preserve configured proxy");
+
+ assert_eq!(network.proxy_host_and_port(), "127.0.0.1:43128");
+ assert!(!network.socks_enabled());
+ assert_eq!(config.permissions.permission_profile(), permission_profile);
+ Ok(())
+}
+
#[tokio::test]
async fn project_root_glob_none_compiles_to_filesystem_pattern_entry() -> std::io::Result<()> {
let codex_home = TempDir::new()?;
diff --git a/codex-rs/core/src/config/mod.rs b/codex-rs/core/src/config/mod.rs
index aa9919363e..e89cb7ca0e 100644
--- a/codex-rs/core/src/config/mod.rs
+++ b/codex-rs/core/src/config/mod.rs
@@ -1378,6 +1378,7 @@ pub struct ConfigOverrides {
pub approval_policy: Option<AskForApproval>,
pub approvals_reviewer: Option<ApprovalsReviewer>,
pub sandbox_mode: Option<SandboxMode>,
+ pub permission_profile: Option<PermissionProfile>,
pub model_provider: Option<String>,
pub service_tier: Option<Option<ServiceTier>>,
pub config_profile: Option<String>,
@@ -1596,6 +1597,7 @@ impl Config {
approval_policy: approval_policy_override,
approvals_reviewer: approvals_reviewer_override,
sandbox_mode,
+ permission_profile,
model_provider,
service_tier: service_tier_override,
config_profile: config_profile_key,
@@ -1616,6 +1618,13 @@ impl Config {
additional_writable_roots,
} = overrides;
+ if sandbox_mode.is_some() && permission_profile.is_some() {
+ return Err(std::io::Error::new(
+ std::io::ErrorKind::InvalidInput,
+ "`sandbox_mode` and `permission_profile` overrides cannot both be set",
+ ));
+ }
+
let active_profile_name = config_profile_key
.as_ref()
.or(cfg.profile.as_ref())
@@ -1736,7 +1745,56 @@ impl Config {
sandbox_policy,
file_system_sandbox_policy,
network_sandbox_policy,
- ) = if profiles_are_active {
+ ) = if let Some(permission_profile) = permission_profile {
+ let (mut file_system_sandbox_policy, network_sandbox_policy) =
+ permission_profile.to_runtime_permissions();
+ let configured_network_proxy_config =
+ if network_sandbox_policy.is_enabled() && profiles_are_active {
+ let permissions = cfg.permissions.as_ref().ok_or_else(|| {
+ std::io::Error::new(
+ std::io::ErrorKind::InvalidInput,
+ "default_permissions requires a `[permissions]` table",
+ )
+ })?;
+ let default_permissions = cfg.default_permissions.as_deref().ok_or_else(|| {
+ std::io::Error::new(
+ std::io::ErrorKind::InvalidInput,
+ "default_permissions requires a named permissions profile",
+ )
+ })?;
+ let profile = resolve_permission_profile(permissions, default_permissions)?;
+
+ // PermissionProfile only carries the network enabled bit today. Keep the
+ // configured proxy/allowlist policy so active profiles can round-trip without
+ // broadening network behavior.
+ network_proxy_config_from_profile_network(profile.network.as_ref())
+ } else {
+ NetworkProxyConfig::default()
+ };
+ let mut sandbox_policy = permission_profile
+ .to_legacy_sandbox_policy(resolved_cwd.as_path())
+ .map_err(|err| {
+ std::io::Error::new(
+ std::io::ErrorKind::InvalidInput,
+ format!("invalid permission_profile override: {err}"),
+ )
+ })?;
+ if matches!(sandbox_policy, SandboxPolicy::WorkspaceWrite { .. }) {
+ file_system_sandbox_policy = file_system_sandbox_policy
+ .with_additional_writable_roots(
+ resolved_cwd.as_path(),
+ &additional_writable_roots,
+ );
+ sandbox_policy = file_system_sandbox_policy
+ .to_legacy_sandbox_policy(network_sandbox_policy, resolved_cwd.as_path())?;
+ }
+ (
+ configured_network_proxy_config,
+ sandbox_policy,
+ file_system_sandbox_policy,
+ network_sandbox_policy,
+ )
+ } else if profiles_are_active {
let permissions = cfg.permissions.as_ref().ok_or_else(|| {
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
diff --git a/codex-rs/core/src/lib.rs b/codex-rs/core/src/lib.rs
index 373e57737b..548287958d 100644
--- a/codex-rs/core/src/lib.rs
+++ b/codex-rs/core/src/lib.rs
@@ -18,6 +18,7 @@ pub use session::SteerInputError;
mod codex_thread;
mod compact_remote;
pub use codex_thread::CodexThread;
+pub use codex_thread::CodexThreadTurnContextOverrides;
pub use codex_thread::ThreadConfigSnapshot;
mod agent;
mod codex_delegate;
diff --git a/codex-rs/core/src/session/handlers.rs b/codex-rs/core/src/session/handlers.rs
index bbc66141ec..9c91f78188 100644
--- a/codex-rs/core/src/session/handlers.rs
+++ b/codex-rs/core/src/session/handlers.rs
@@ -162,6 +162,7 @@ pub(super) async fn user_input_or_turn_inner(
approval_policy: Some(approval_policy),
approvals_reviewer,
sandbox_policy: Some(sandbox_policy),
+ permission_profile: None,
windows_sandbox_level: None,
collaboration_mode,
reasoning_summary: summary,
@@ -175,6 +176,56 @@ pub(super) async fn user_input_or_turn_inner(
environments,
)
}
+ Op::UserInputWithTurnContext {
+ cwd,
+ approval_policy,
+ approvals_reviewer,
+ sandbox_policy,
+ permission_profile,
+ windows_sandbox_level,
+ model,
+ effort,
+ summary,
+ service_tier,
+ final_output_json_schema,
+ items,
+ responsesapi_client_metadata,
+ collaboration_mode,
+ personality,
+ environments,
+ } => {
+ let collaboration_mode = if let Some(collab_mode) = collaboration_mode {
+ Some(collab_mode)
+ } else {
+ let state = sess.state.lock().await;
+ Some(
+ state
+ .session_configuration
+ .collaboration_mode
+ .with_updates(model, effort, /*developer_instructions*/ None),
+ )
+ };
+ (
+ items,
+ SessionSettingsUpdate {
+ cwd,
+ approval_policy,
+ approvals_reviewer,
+ sandbox_policy,
+ permission_profile,
+ windows_sandbox_level,
+ collaboration_mode,
+ reasoning_summary: summary,
+ service_tier,
+ final_output_json_schema: Some(final_output_json_schema),
+ personality,
+ app_server_client_name: None,
+ app_server_client_version: None,
+ },
+ responsesapi_client_metadata,
+ environments,
+ )
+ }
Op::UserInput {
items,
environments,
@@ -1062,6 +1113,7 @@ pub(super) async fn submission_loop(
approval_policy,
approvals_reviewer,
sandbox_policy,
+ permission_profile,
windows_sandbox_level,
model,
effort,
@@ -1088,6 +1140,7 @@ pub(super) async fn submission_loop(
approval_policy,
approvals_reviewer,
sandbox_policy,
+ permission_profile,
windows_sandbox_level,
collaboration_mode: Some(collaboration_mode),
reasoning_summary: summary,
@@ -1099,7 +1152,9 @@ pub(super) async fn submission_loop(
.await;
false
}
- Op::UserInput { .. } | Op::UserTurn { .. } => {
+ Op::UserInput { .. }
+ | Op::UserInputWithTurnContext { .. }
+ | Op::UserTurn { .. } => {
user_input_or_turn(&sess, sub.id.clone(), sub.op).await;
false
}
diff --git a/codex-rs/core/src/session/mod.rs b/codex-rs/core/src/session/mod.rs
index 5dc1eadd66..b9c7116973 100644
--- a/codex-rs/core/src/session/mod.rs
+++ b/codex-rs/core/src/session/mod.rs
@@ -189,7 +189,7 @@ use self::review::spawn_review_thread;
use self::session::AppServerClientMetadata;
use self::session::Session;
use self::session::SessionConfiguration;
-use self::session::SessionSettingsUpdate;
+pub(crate) use self::session::SessionSettingsUpdate;
#[cfg(test)]
use self::turn::AssistantMessageStreamParsers;
#[cfg(test)]
@@ -1308,6 +1308,14 @@ impl Session {
Ok(())
}
+ pub(crate) async fn validate_settings(
+ &self,
+ updates: &SessionSettingsUpdate,
+ ) -> ConstraintResult<()> {
+ let state = self.state.lock().await;
+ state.session_configuration.apply(updates).map(|_| ())
+ }
+
pub(crate) async fn set_session_startup_prewarm(
&self,
startup_prewarm: SessionStartupPrewarmHandle,
diff --git a/codex-rs/core/src/session/session.rs b/codex-rs/core/src/session/session.rs
index 29b6f4e299..c64b1c30ac 100644
--- a/codex-rs/core/src/session/session.rs
+++ b/codex-rs/core/src/session/session.rs
@@ -1,4 +1,5 @@
use super::*;
+use crate::config::ConstraintError;
use tokio::sync::Semaphore;
/// Context for an initialized model agent
@@ -139,13 +140,6 @@ impl SessionConfiguration {
if let Some(approvals_reviewer) = updates.approvals_reviewer {
next_configuration.approvals_reviewer = approvals_reviewer;
}
- let mut sandbox_policy_changed = false;
- if let Some(sandbox_policy) = updates.sandbox_policy.clone() {
- next_configuration.sandbox_policy.set(sandbox_policy)?;
- next_configuration.network_sandbox_policy =
- NetworkSandboxPolicy::from(next_configuration.sandbox_policy.get());
- sandbox_policy_changed = true;
- }
if let Some(windows_sandbox_level) = updates.windows_sandbox_level {
next_configuration.windows_sandbox_level = windows_sandbox_level;
}
@@ -166,13 +160,53 @@ impl SessionConfiguration {
let cwd_changed = absolute_cwd.as_path() != self.cwd.as_path();
next_configuration.cwd = absolute_cwd;
- if sandbox_policy_changed {
+
+ if let Some(permission_profile) = updates.permission_profile.clone() {
+ let sandbox_policy = permission_profile
+ .to_legacy_sandbox_policy(&next_configuration.cwd)
+ .map_err(|err| ConstraintError::InvalidValue {
+ field_name: "permission_profile",
+ candidate: format!("{permission_profile:?}"),
+ allowed: format!(
+ "permission profiles that can be represented by the active sandbox constraints: {err}"
+ ),
+ requirement_source: codex_config::RequirementSource::Unknown,
+ })?;
+ next_configuration.sandbox_policy.set(sandbox_policy)?;
+ let (mut file_system_sandbox_policy, network_sandbox_policy) =
+ permission_profile.to_runtime_permissions();
+ if file_system_sandbox_policy.glob_scan_max_depth.is_none() {
+ file_system_sandbox_policy.glob_scan_max_depth =
+ self.file_system_sandbox_policy.glob_scan_max_depth;
+ }
+ for deny_entry in self
+ .file_system_sandbox_policy
+ .entries
+ .iter()
+ .filter(|entry| {
+ entry.access == codex_protocol::permissions::FileSystemAccessMode::None
+ })
+ {
+ if !file_system_sandbox_policy
+ .entries
+ .iter()
+ .any(|entry| entry == deny_entry)
+ {
+ file_system_sandbox_policy.entries.push(deny_entry.clone());
+ }
+ }
+ next_configuration.file_system_sandbox_policy = file_system_sandbox_policy;
+ next_configuration.network_sandbox_policy = network_sandbox_policy;
+ } else if let Some(sandbox_policy) = updates.sandbox_policy.clone() {
+ next_configuration.sandbox_policy.set(sandbox_policy)?;
next_configuration.file_system_sandbox_policy =
FileSystemSandboxPolicy::from_legacy_sandbox_policy_preserving_deny_entries(
next_configuration.sandbox_policy.get(),
&next_configuration.cwd,
&self.file_system_sandbox_policy,
);
+ next_configuration.network_sandbox_policy =
+ NetworkSandboxPolicy::from(next_configuration.sandbox_policy.get());
} else if cwd_changed && file_system_policy_matches_legacy {
// Preserve richer split policies across cwd-only updates; only
// rederive when the session is already using the legacy bridge.
@@ -198,6 +232,7 @@ pub(crate) struct SessionSettingsUpdate {
pub(crate) approval_policy: Option<AskForApproval>,
pub(crate) approvals_reviewer: Option<ApprovalsReviewer>,
pub(crate) sandbox_policy: Option<SandboxPolicy>,
+ pub(crate) permission_profile: Option<PermissionProfile>,
pub(crate) windows_sandbox_level: Option<WindowsSandboxLevel>,
pub(crate) collaboration_mode: Option<CollaborationMode>,
pub(crate) reasoning_summary: Option<ReasoningSummaryConfig>,
diff --git a/codex-rs/core/src/session/tests.rs b/codex-rs/core/src/session/tests.rs
index 5e50ea5fb1..b88b8a4083 100644
--- a/codex-rs/core/src/session/tests.rs
+++ b/codex-rs/core/src/session/tests.rs
@@ -108,6 +108,7 @@ use codex_protocol::protocol::TurnStartedEvent;
use codex_protocol::protocol::UserMessageEvent;
use codex_protocol::protocol::W3cTraceContext;
use core_test_support::PathBufExt;
+use core_test_support::PathExt;
use core_test_support::context_snapshot;
use core_test_support::context_snapshot::ContextSnapshotOptions;
use core_test_support::context_snapshot::ContextSnapshotRenderMode;
@@ -1545,6 +1546,7 @@ async fn fork_startup_context_then_first_turn_diff_snapshot() -> anyhow::Result<
approval_policy: Some(AskForApproval::Never),
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -2714,6 +2716,53 @@ async fn session_configuration_apply_preserves_split_file_system_policy_on_cwd_o
);
}
+#[tokio::test]
+async fn session_configuration_apply_permission_profile_preserves_existing_deny_read_entries() {
+ let mut session_configuration = make_session_configuration_for_tests().await;
+ let cwd = tempfile::tempdir().expect("create temp dir");
+ session_configuration.cwd = cwd.path().abs();
+
+ let workspace_policy = SandboxPolicy::new_workspace_write_policy();
+ session_configuration.sandbox_policy =
+ codex_config::Constrained::allow_any(workspace_policy.clone());
+ let deny_entry = FileSystemSandboxEntry {
+ path: FileSystemPath::GlobPattern {
+ pattern: "**/*.env".to_string(),
+ },
+ access: FileSystemAccessMode::None,
+ };
+ let mut existing_file_system_policy = FileSystemSandboxPolicy::from_legacy_sandbox_policy(
+ &workspace_policy,
+ session_configuration.cwd.as_path(),
+ );
+ existing_file_system_policy.glob_scan_max_depth = Some(2);
+ existing_file_system_policy.entries.push(deny_entry.clone());
+ session_configuration.file_system_sandbox_policy = existing_file_system_policy;
+
+ let requested_file_system_policy = FileSystemSandboxPolicy::from_legacy_sandbox_policy(
+ &workspace_policy,
+ session_configuration.cwd.as_path(),
+ );
+ let permission_profile = codex_protocol::models::PermissionProfile::from_runtime_permissions(
+ &requested_file_system_policy,
+ NetworkSandboxPolicy::Restricted,
+ );
+ let updated = session_configuration
+ .apply(&SessionSettingsUpdate {
+ permission_profile: Some(permission_profile),
+ ..Default::default()
+ })
+ .expect("permission profile update should succeed");
+
+ let mut expected_file_system_policy = requested_file_system_policy;
+ expected_file_system_policy.glob_scan_max_depth = Some(2);
+ expected_file_system_policy.entries.push(deny_entry);
+ assert_eq!(
+ updated.file_system_sandbox_policy,
+ expected_file_system_policy
+ );
+}
+
#[cfg_attr(windows, ignore)]
#[tokio::test]
async fn new_default_turn_uses_config_aware_skills_for_role_overrides() {
@@ -3715,6 +3764,7 @@ fn op_kind_distinguishes_turn_ops() {
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -3736,6 +3786,28 @@ fn op_kind_distinguishes_turn_ops() {
.kind(),
"user_input"
);
+ assert_eq!(
+ Op::UserInputWithTurnContext {
+ environments: None,
+ items: vec![],
+ final_output_json_schema: None,
+ responsesapi_client_metadata: None,
+ cwd: None,
+ approval_policy: None,
+ approvals_reviewer: None,
+ sandbox_policy: None,
+ permission_profile: None,
+ windows_sandbox_level: None,
+ model: None,
+ effort: None,
+ summary: None,
+ service_tier: None,
+ collaboration_mode: None,
+ personality: None,
+ }
+ .kind(),
+ "user_input_with_turn_context"
+ );
}
#[tokio::test]
diff --git a/codex-rs/core/tests/suite/collaboration_instructions.rs b/codex-rs/core/tests/suite/collaboration_instructions.rs
index 3f8d2378ad..3cc8bd8298 100644
--- a/codex-rs/core/tests/suite/collaboration_instructions.rs
+++ b/codex-rs/core/tests/suite/collaboration_instructions.rs
@@ -128,6 +128,7 @@ async fn user_input_includes_collaboration_instructions_after_override() -> Resu
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -229,6 +230,7 @@ async fn override_then_next_turn_uses_updated_collaboration_instructions() -> Re
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -283,6 +285,7 @@ async fn user_turn_overrides_collaboration_instructions_after_override() -> Resu
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -355,6 +358,7 @@ async fn collaboration_mode_update_emits_new_instruction_message() -> Result<()>
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -384,6 +388,7 @@ async fn collaboration_mode_update_emits_new_instruction_message() -> Result<()>
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -442,6 +447,7 @@ async fn collaboration_mode_update_noop_does_not_append() -> Result<()> {
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -471,6 +477,7 @@ async fn collaboration_mode_update_noop_does_not_append() -> Result<()> {
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -528,6 +535,7 @@ async fn collaboration_mode_update_emits_new_instruction_message_when_mode_chang
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -560,6 +568,7 @@ async fn collaboration_mode_update_emits_new_instruction_message_when_mode_chang
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -621,6 +630,7 @@ async fn collaboration_mode_update_noop_does_not_append_when_mode_is_unchanged()
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -653,6 +663,7 @@ async fn collaboration_mode_update_noop_does_not_append_when_mode_is_unchanged()
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -720,6 +731,7 @@ async fn resume_replays_collaboration_instructions() -> Result<()> {
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -787,6 +799,7 @@ async fn empty_collaboration_instructions_are_ignored() -> Result<()> {
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
diff --git a/codex-rs/core/tests/suite/compact.rs b/codex-rs/core/tests/suite/compact.rs
index c37326ffc9..da4c09345c 100644
--- a/codex-rs/core/tests/suite/compact.rs
+++ b/codex-rs/core/tests/suite/compact.rs
@@ -3083,6 +3083,7 @@ async fn snapshot_request_shape_pre_turn_compaction_including_incoming_user_mess
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
diff --git a/codex-rs/core/tests/suite/compact_remote.rs b/codex-rs/core/tests/suite/compact_remote.rs
index 58ed42c288..a8a2e44f83 100644
--- a/codex-rs/core/tests/suite/compact_remote.rs
+++ b/codex-rs/core/tests/suite/compact_remote.rs
@@ -2103,6 +2103,7 @@ async fn snapshot_request_shape_remote_pre_turn_compaction_including_incoming_us
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -2218,6 +2219,7 @@ async fn snapshot_request_shape_remote_pre_turn_compaction_strips_incoming_model
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: Some(next_model.to_string()),
effort: None,
diff --git a/codex-rs/core/tests/suite/compact_resume_fork.rs b/codex-rs/core/tests/suite/compact_resume_fork.rs
index 48d359529b..1252298738 100644
--- a/codex-rs/core/tests/suite/compact_resume_fork.rs
+++ b/codex-rs/core/tests/suite/compact_resume_fork.rs
@@ -575,6 +575,7 @@ async fn snapshot_rollback_followup_turn_trims_context_updates() -> Result<()> {
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
diff --git a/codex-rs/core/tests/suite/model_overrides.rs b/codex-rs/core/tests/suite/model_overrides.rs
index f7fe7cc322..9f8835f19f 100644
--- a/codex-rs/core/tests/suite/model_overrides.rs
+++ b/codex-rs/core/tests/suite/model_overrides.rs
@@ -30,6 +30,7 @@ async fn override_turn_context_does_not_persist_when_config_exists() {
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: Some("o3".to_string()),
effort: Some(Some(ReasoningEffort::High)),
@@ -68,6 +69,7 @@ async fn override_turn_context_does_not_create_config_file() {
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: Some("o3".to_string()),
effort: Some(Some(ReasoningEffort::Medium)),
diff --git a/codex-rs/core/tests/suite/model_switching.rs b/codex-rs/core/tests/suite/model_switching.rs
index 54c2d1035f..db760d8f89 100644
--- a/codex-rs/core/tests/suite/model_switching.rs
+++ b/codex-rs/core/tests/suite/model_switching.rs
@@ -147,6 +147,7 @@ async fn model_change_appends_model_instructions_developer_message() -> Result<(
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: Some(next_model.to_string()),
effort: None,
@@ -246,6 +247,7 @@ async fn model_and_personality_change_only_appends_model_instructions() -> Resul
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: Some(next_model.to_string()),
effort: None,
@@ -1038,6 +1040,7 @@ async fn model_switch_to_smaller_model_updates_token_context_window() -> Result<
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: Some(smaller_model_slug.to_string()),
effort: None,
diff --git a/codex-rs/core/tests/suite/model_visible_layout.rs b/codex-rs/core/tests/suite/model_visible_layout.rs
index c93294121c..6cbbb7389c 100644
--- a/codex-rs/core/tests/suite/model_visible_layout.rs
+++ b/codex-rs/core/tests/suite/model_visible_layout.rs
@@ -458,6 +458,7 @@ async fn snapshot_model_visible_layout_resume_override_matches_rollout_model() -
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: Some("gpt-5.2".to_string()),
effort: None,
diff --git a/codex-rs/core/tests/suite/override_updates.rs b/codex-rs/core/tests/suite/override_updates.rs
index 13ace1fe6d..63d2b6ed43 100644
--- a/codex-rs/core/tests/suite/override_updates.rs
+++ b/codex-rs/core/tests/suite/override_updates.rs
@@ -118,6 +118,7 @@ async fn override_turn_context_without_user_turn_does_not_record_permissions_upd
approval_policy: Some(AskForApproval::Never),
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -160,6 +161,7 @@ async fn override_turn_context_without_user_turn_does_not_record_environment_upd
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -199,6 +201,7 @@ async fn override_turn_context_without_user_turn_does_not_record_collaboration_u
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
diff --git a/codex-rs/core/tests/suite/permissions_messages.rs b/codex-rs/core/tests/suite/permissions_messages.rs
index fb0acf7519..838a20f00a 100644
--- a/codex-rs/core/tests/suite/permissions_messages.rs
+++ b/codex-rs/core/tests/suite/permissions_messages.rs
@@ -105,6 +105,7 @@ async fn permissions_message_added_on_override_change() -> Result<()> {
approval_policy: Some(AskForApproval::Never),
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -237,6 +238,7 @@ async fn permissions_message_omitted_when_disabled() -> Result<()> {
approval_policy: Some(AskForApproval::Never),
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -325,6 +327,7 @@ async fn resume_replays_permissions_messages() -> Result<()> {
approval_policy: Some(AskForApproval::Never),
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -430,6 +433,7 @@ async fn resume_and_fork_append_permissions_messages() -> Result<()> {
approval_policy: Some(AskForApproval::Never),
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
diff --git a/codex-rs/core/tests/suite/personality.rs b/codex-rs/core/tests/suite/personality.rs
index 7c72478ace..9232dc71cd 100644
--- a/codex-rs/core/tests/suite/personality.rs
+++ b/codex-rs/core/tests/suite/personality.rs
@@ -352,6 +352,7 @@ async fn user_turn_personality_some_adds_update_message() -> anyhow::Result<()>
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -459,6 +460,7 @@ async fn user_turn_personality_same_value_does_not_add_update_message() -> anyho
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -579,6 +581,7 @@ async fn user_turn_personality_skips_if_feature_disabled() -> anyhow::Result<()>
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -860,6 +863,7 @@ async fn user_turn_personality_remote_model_template_includes_update_message() -
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
diff --git a/codex-rs/core/tests/suite/prompt_caching.rs b/codex-rs/core/tests/suite/prompt_caching.rs
index cee43e9820..834bab73fb 100644
--- a/codex-rs/core/tests/suite/prompt_caching.rs
+++ b/codex-rs/core/tests/suite/prompt_caching.rs
@@ -444,6 +444,7 @@ async fn overrides_turn_context_but_keeps_cached_prefix_and_key_constant() -> an
approval_policy: Some(AskForApproval::Never),
approvals_reviewer: None,
sandbox_policy: Some(new_policy.clone()),
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: Some(Some(ReasoningEffort::High)),
@@ -529,6 +530,7 @@ async fn override_before_first_turn_emits_environment_context() -> anyhow::Resul
approval_policy: Some(AskForApproval::Never),
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: Some("gpt-5.4".to_string()),
effort: Some(Some(ReasoningEffort::Low)),
diff --git a/codex-rs/core/tests/suite/remote_models.rs b/codex-rs/core/tests/suite/remote_models.rs
index e62fa0c323..f2b9d16ba2 100644
--- a/codex-rs/core/tests/suite/remote_models.rs
+++ b/codex-rs/core/tests/suite/remote_models.rs
@@ -595,6 +595,7 @@ async fn remote_models_remote_model_uses_unified_exec() -> Result<()> {
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: Some(REMOTE_MODEL_SLUG.to_string()),
effort: None,
@@ -840,6 +841,7 @@ async fn remote_models_apply_remote_base_instructions() -> Result<()> {
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: Some(model.to_string()),
effort: None,
diff --git a/codex-rs/core/tests/suite/resume.rs b/codex-rs/core/tests/suite/resume.rs
index febeb926b1..ab0fcba9b6 100644
--- a/codex-rs/core/tests/suite/resume.rs
+++ b/codex-rs/core/tests/suite/resume.rs
@@ -428,6 +428,7 @@ async fn resume_model_switch_is_not_duplicated_after_pre_turn_override() -> Resu
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: Some("gpt-5.4".to_string()),
effort: None,
diff --git a/codex-rs/core/tests/suite/review.rs b/codex-rs/core/tests/suite/review.rs
index faf469c981..c375dbbd0a 100644
--- a/codex-rs/core/tests/suite/review.rs
+++ b/codex-rs/core/tests/suite/review.rs
@@ -839,6 +839,7 @@ async fn review_uses_overridden_cwd_for_base_branch_merge_base() {
approval_policy: None,
approvals_reviewer: None,
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
diff --git a/codex-rs/exec/src/lib.rs b/codex-rs/exec/src/lib.rs
index ca3b650778..43c5e45250 100644
--- a/codex-rs/exec/src/lib.rs
+++ b/codex-rs/exec/src/lib.rs
@@ -391,6 +391,7 @@ pub async fn run_main(cli: Cli, arg0_paths: Arg0DispatchPaths) -> anyhow::Result
approval_policy: Some(AskForApproval::Never),
approvals_reviewer: None,
sandbox_mode,
+ permission_profile: None,
cwd: resolved_cwd,
model_provider: model_provider.clone(),
service_tier: None,
@@ -750,6 +751,7 @@ async fn run_exec_session(args: ExecRunArgs) -> anyhow::Result<()> {
approval_policy: Some(default_approval_policy.into()),
approvals_reviewer: None,
sandbox_policy: Some(default_sandbox_policy.clone().into()),
+ permission_profile: None,
model: None,
service_tier: None,
effort: default_effort,
diff --git a/codex-rs/protocol/src/models.rs b/codex-rs/protocol/src/models.rs
index a97fc70702..551723c773 100644
--- a/codex-rs/protocol/src/models.rs
+++ b/codex-rs/protocol/src/models.rs
@@ -318,6 +318,13 @@ impl PermissionProfile {
self.file_system_sandbox_policy()
.to_legacy_sandbox_policy(self.network_sandbox_policy(), cwd)
}
+
+ pub fn to_runtime_permissions(&self) -> (FileSystemSandboxPolicy, NetworkSandboxPolicy) {
+ (
+ self.file_system_sandbox_policy(),
+ self.network_sandbox_policy(),
+ )
+ }
}
impl From<NetworkSandboxPolicy> for NetworkPermissions {
diff --git a/codex-rs/protocol/src/protocol.rs b/codex-rs/protocol/src/protocol.rs
index dfbe085a8a..9ef9b9f84a 100644
--- a/codex-rs/protocol/src/protocol.rs
+++ b/codex-rs/protocol/src/protocol.rs
@@ -38,6 +38,7 @@ use crate::message_history::HistoryEntry;
use crate::models::BaseInstructions;
use crate::models::ContentItem;
use crate::models::MessagePhase;
+use crate::models::PermissionProfile;
use crate::models::ResponseInputItem;
use crate::models::ResponseItem;
use crate::models::WebSearchAction;
@@ -442,6 +443,79 @@ pub enum Op {
responsesapi_client_metadata: Option<HashMap<String, String>>,
},
+ /// Similar to [`Op::UserInput`], but first applies persistent turn-context
+ /// overrides in the same queued operation. This preserves submission order
+ /// and prevents the input from starting if the overrides are rejected.
+ UserInputWithTurnContext {
+ /// User input items, see `InputItem`
+ items: Vec<UserInput>,
+ /// Optional turn-scoped environment selections.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ environments: Option<Vec<TurnEnvironmentSelection>>,
+ /// Optional JSON Schema used to constrain the final assistant message for this turn.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ final_output_json_schema: Option<Value>,
+ /// Optional turn-scoped Responses API `client_metadata`.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ responsesapi_client_metadata: Option<HashMap<String, String>>,
+
+ /// Updated `cwd` for sandbox/tool calls.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ cwd: Option<PathBuf>,
+
+ /// Updated command approval policy.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ approval_policy: Option<AskForApproval>,
+
+ /// Updated approval reviewer for future approval prompts.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ approvals_reviewer: Option<ApprovalsReviewer>,
+
+ /// Updated sandbox policy for tool calls.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ sandbox_policy: Option<SandboxPolicy>,
+
+ /// Updated permissions profile for tool calls.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ permission_profile: Option<PermissionProfile>,
+
+ /// Updated Windows sandbox mode for tool execution.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ windows_sandbox_level: Option<WindowsSandboxLevel>,
+
+ /// Updated model slug. When set, the model info is derived
+ /// automatically.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ model: Option<String>,
+
+ /// Updated reasoning effort (honored only for reasoning-capable models).
+ ///
+ /// Use `Some(Some(_))` to set a specific effort, `Some(None)` to clear
+ /// the effort, or `None` to leave the existing value unchanged.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ effort: Option<Option<ReasoningEffortConfig>>,
+
+ /// Updated reasoning summary preference (honored only for reasoning-capable models).
+ #[serde(skip_serializing_if = "Option::is_none")]
+ summary: Option<ReasoningSummaryConfig>,
+
+ /// Updated service tier preference for future turns.
+ ///
+ /// Use `Some(Some(_))` to set a specific tier, `Some(None)` to clear the
+ /// preference, or `None` to leave the existing value unchanged.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ service_tier: Option<Option<ServiceTier>>,
+
+ /// EXPERIMENTAL - set a pre-set collaboration mode.
+ /// Takes precedence over model, effort, and developer instructions if set.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ collaboration_mode: Option<CollaborationMode>,
+
+ /// Updated personality preference.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ personality: Option<Personality>,
+ },
+
/// Similar to [`Op::UserInput`], but contains additional context required
/// for a turn of a [`crate::codex_thread::CodexThread`].
UserTurn {
@@ -532,6 +606,10 @@ pub enum Op {
#[serde(skip_serializing_if = "Option::is_none")]
sandbox_policy: Option<SandboxPolicy>,
+ /// Updated permissions profile for tool calls.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ permission_profile: Option<PermissionProfile>,
+
/// Updated Windows sandbox mode for tool execution.
#[serde(skip_serializing_if = "Option::is_none")]
windows_sandbox_level: Option<WindowsSandboxLevel>,
@@ -800,6 +878,7 @@ impl Op {
Self::RealtimeConversationClose => "realtime_conversation_close",
Self::RealtimeConversationListVoices => "realtime_conversation_list_voices",
Self::UserInput { .. } => "user_input",
+ Self::UserInputWithTurnContext { .. } => "user_input_with_turn_context",
Self::UserTurn { .. } => "user_turn",
Self::InterAgentCommunication { .. } => "inter_agent_communication",
Self::OverrideTurnContext { .. } => "override_turn_context",
diff --git a/codex-rs/tui/src/app/tests.rs b/codex-rs/tui/src/app/tests.rs
index c498d3d41d..a1a658a24d 100644
--- a/codex-rs/tui/src/app/tests.rs
+++ b/codex-rs/tui/src/app/tests.rs
@@ -1651,6 +1651,7 @@ async fn update_feature_flags_enabling_guardian_selects_guardian_approvals() ->
approval_policy: Some(guardian_approvals.approval_policy),
approvals_reviewer: Some(guardian_approvals.approvals_reviewer),
sandbox_policy: Some(guardian_approvals.sandbox_policy.clone()),
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -1742,6 +1743,7 @@ async fn update_feature_flags_disabling_guardian_clears_review_policy_and_restor
approval_policy: None,
approvals_reviewer: Some(ApprovalsReviewer::User),
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -1821,6 +1823,7 @@ async fn update_feature_flags_enabling_guardian_overrides_explicit_manual_review
approval_policy: Some(guardian_approvals.approval_policy),
approvals_reviewer: Some(guardian_approvals.approvals_reviewer),
sandbox_policy: Some(guardian_approvals.sandbox_policy.clone()),
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -1878,6 +1881,7 @@ async fn update_feature_flags_disabling_guardian_clears_manual_review_policy_wit
approval_policy: None,
approvals_reviewer: Some(ApprovalsReviewer::User),
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -1937,6 +1941,7 @@ async fn update_feature_flags_enabling_guardian_in_profile_sets_profile_auto_rev
approval_policy: Some(guardian_approvals.approval_policy),
approvals_reviewer: Some(guardian_approvals.approvals_reviewer),
sandbox_policy: Some(guardian_approvals.sandbox_policy.clone()),
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
@@ -2024,6 +2029,7 @@ guardian_approval = true
approval_policy: None,
approvals_reviewer: Some(ApprovalsReviewer::User),
sandbox_policy: None,
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,
diff --git a/codex-rs/tui/src/app_command.rs b/codex-rs/tui/src/app_command.rs
index 45425c3494..9bd024679a 100644
--- a/codex-rs/tui/src/app_command.rs
+++ b/codex-rs/tui/src/app_command.rs
@@ -184,6 +184,7 @@ impl AppCommand {
approval_policy,
approvals_reviewer,
sandbox_policy,
+ permission_profile: None,
windows_sandbox_level,
model,
effort,
@@ -317,6 +318,7 @@ impl AppCommand {
approval_policy,
approvals_reviewer,
sandbox_policy,
+ permission_profile: _,
windows_sandbox_level,
model,
effort,
diff --git a/codex-rs/tui/src/app_server_session.rs b/codex-rs/tui/src/app_server_session.rs
index 26746b8b19..8470c575dd 100644
--- a/codex-rs/tui/src/app_server_session.rs
+++ b/codex-rs/tui/src/app_server_session.rs
@@ -540,6 +540,7 @@ impl AppServerSession {
approval_policy: Some(approval_policy.into()),
approvals_reviewer: Some(approvals_reviewer.into()),
sandbox_policy: Some(sandbox_policy.into()),
+ permission_profile: None,
model: Some(model),
service_tier,
effort,
diff --git a/codex-rs/tui/src/chatwidget/tests/permissions.rs b/codex-rs/tui/src/chatwidget/tests/permissions.rs
index c1e142c4e1..92ca170605 100644
--- a/codex-rs/tui/src/chatwidget/tests/permissions.rs
+++ b/codex-rs/tui/src/chatwidget/tests/permissions.rs
@@ -632,6 +632,7 @@ async fn permissions_selection_sends_approvals_reviewer_in_override_turn_context
approval_policy: Some(AskForApproval::OnRequest),
approvals_reviewer: Some(ApprovalsReviewer::GuardianSubagent),
sandbox_policy: Some(SandboxPolicy::new_workspace_write_policy()),
+ permission_profile: None,
windows_sandbox_level: None,
model: None,
effort: None,