Skip to content

Commit 09f53a1

Browse files
charley-oaicodex
andcommitted
document output schema behavior
Co-authored-by: Codex <noreply@openai.com>
1 parent 67e4070 commit 09f53a1

10 files changed

Lines changed: 38 additions & 16 deletions

File tree

codex-rs/app-server-protocol/schema/json/ClientRequest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2570,7 +2570,7 @@
25702570
]
25712571
},
25722572
"outputSchema": {
2573-
"description": "Optional JSON Schema used to constrain the final assistant message for this turn."
2573+
"description": "Optional JSON Schema used to constrain the final assistant message for this turn.\n\nWhen set, Codex requests a strict JSON response matching this schema. This applies only to the final assistant message for the current turn; it does not constrain tool calls or become the default for later turns."
25742574
},
25752575
"personality": {
25762576
"anyOf": [

codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15250,7 +15250,7 @@
1525015250
]
1525115251
},
1525215252
"outputSchema": {
15253-
"description": "Optional JSON Schema used to constrain the final assistant message for this turn."
15253+
"description": "Optional JSON Schema used to constrain the final assistant message for this turn.\n\nWhen set, Codex requests a strict JSON response matching this schema. This applies only to the final assistant message for the current turn; it does not constrain tool calls or become the default for later turns."
1525415254
},
1525515255
"personality": {
1525615256
"anyOf": [

codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14044,7 +14044,7 @@
1404414044
]
1404514045
},
1404614046
"outputSchema": {
14047-
"description": "Optional JSON Schema used to constrain the final assistant message for this turn."
14047+
"description": "Optional JSON Schema used to constrain the final assistant message for this turn.\n\nWhen set, Codex requests a strict JSON response matching this schema. This applies only to the final assistant message for the current turn; it does not constrain tool calls or become the default for later turns."
1404814048
},
1404914049
"personality": {
1405014050
"anyOf": [

codex-rs/app-server-protocol/schema/json/v2/TurnStartParams.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@
527527
]
528528
},
529529
"outputSchema": {
530-
"description": "Optional JSON Schema used to constrain the final assistant message for this turn."
530+
"description": "Optional JSON Schema used to constrain the final assistant message for this turn.\n\nWhen set, Codex requests a strict JSON response matching this schema. This applies only to the final assistant message for the current turn; it does not constrain tool calls or become the default for later turns."
531531
},
532532
"personality": {
533533
"anyOf": [

codex-rs/app-server-protocol/schema/typescript/v2/TurnStartParams.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ summary?: ReasoningSummary | null, /**
3636
* Override the personality for this turn and subsequent turns.
3737
*/
3838
personality?: Personality | null, /**
39-
* Optional JSON Schema used to constrain the final assistant message for this turn.
39+
* Optional JSON Schema used to constrain the final assistant message for
40+
* this turn.
41+
*
42+
* When set, Codex requests a strict JSON response matching this schema.
43+
* This applies only to the final assistant message for the current turn, * it does not constrain tool calls or become the default for later turns.
4044
*/
4145
outputSchema?: JsonValue | null, /**
4246
* EXPERIMENTAL - Set a pre-set collaboration mode.

codex-rs/app-server-protocol/src/protocol/v1.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,12 @@ pub struct SendUserTurnParams {
429429
pub service_tier: Option<Option<ServiceTier>>,
430430
pub effort: Option<ReasoningEffort>,
431431
pub summary: ReasoningSummary,
432-
/// Optional JSON Schema used to constrain the final assistant message for this turn.
432+
/// Optional JSON Schema used to constrain the final assistant message for
433+
/// this turn.
434+
///
435+
/// When set, Codex requests a strict JSON response matching this schema.
436+
/// This applies only to the final assistant message for the current turn.
437+
/// It does not constrain tool calls or become the default for later turns.
433438
pub output_schema: Option<serde_json::Value>,
434439
}
435440

codex-rs/app-server-protocol/src/protocol/v2.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2985,7 +2985,12 @@ pub struct TurnStartParams {
29852985
/// Override the personality for this turn and subsequent turns.
29862986
#[ts(optional = nullable)]
29872987
pub personality: Option<Personality>,
2988-
/// Optional JSON Schema used to constrain the final assistant message for this turn.
2988+
/// Optional JSON Schema used to constrain the final assistant message for
2989+
/// this turn.
2990+
///
2991+
/// When set, Codex requests a strict JSON response matching this schema.
2992+
/// This applies only to the final assistant message for the current turn;
2993+
/// it does not constrain tool calls or become the default for later turns.
29892994
#[ts(optional = nullable)]
29902995
pub output_schema: Option<JsonValue>,
29912996

codex-rs/app-server/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,9 @@ Turns attach user input (text or images) to a thread and trigger Codex generatio
401401
- `{"type":"image","url":"https://…png"}`
402402
- `{"type":"localImage","path":"/tmp/screenshot.png"}`
403403

404-
You can optionally specify config overrides on the new turn. If specified, these settings become the default for subsequent turns on the same thread. `outputSchema` applies only to the current turn.
404+
You can optionally specify config overrides on the new turn. If specified, these settings become the default for subsequent turns on the same thread. `outputSchema` is the exception: it applies only to the current turn.
405+
406+
When `outputSchema` is set, Codex asks the model for a strict JSON final answer matching that schema. This constrains only the final assistant message for the turn. It does not affect tool-call arguments or outputs, and it does not persist as the default for later turns.
405407

406408
```json
407409
{ "method": "turn/start", "id": 30, "params": {

codex-rs/core/src/tools/handlers/shell.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,14 @@ impl ShellHandler {
343343
.map_err(FunctionCallError::RespondToModel)?;
344344

345345
// Approval policy guard for the sandboxed additional-permissions flow.
346-
if exec_params.sandbox_permissions.uses_additional_permissions() && !matches!(
347-
turn.approval_policy.value(),
348-
codex_protocol::protocol::AskForApproval::OnRequest
349-
) {
346+
if exec_params
347+
.sandbox_permissions
348+
.uses_additional_permissions()
349+
&& !matches!(
350+
turn.approval_policy.value(),
351+
codex_protocol::protocol::AskForApproval::OnRequest
352+
)
353+
{
350354
let approval_policy = turn.approval_policy.value();
351355
return Err(FunctionCallError::RespondToModel(format!(
352356
"approval policy is {approval_policy:?}; reject command — you should not ask for additional sandbox permissions if the approval policy is {approval_policy:?}"

codex-rs/core/src/tools/handlers/unified_exec.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,12 @@ impl ToolHandler for UnifiedExecHandler {
171171
let request_permission_enabled =
172172
session.features().enabled(Feature::RequestPermissions);
173173

174-
if sandbox_permissions.uses_additional_permissions() && !matches!(
175-
context.turn.approval_policy.value(),
176-
codex_protocol::protocol::AskForApproval::OnRequest
177-
) {
174+
if sandbox_permissions.uses_additional_permissions()
175+
&& !matches!(
176+
context.turn.approval_policy.value(),
177+
codex_protocol::protocol::AskForApproval::OnRequest
178+
)
179+
{
178180
let approval_policy = context.turn.approval_policy.value();
179181
manager.release_process_id(&process_id).await;
180182
return Err(FunctionCallError::RespondToModel(format!(

0 commit comments

Comments
 (0)