Allow custom Codex instructions for realtime transitions (#36408)

## What changed

- Add optional `realtimeStartInstructions` and `realtimeEndInstructions` fields to `thread/realtime/start`.
- Apply the instructions when Codex enters and leaves realtime mode, while preserving the existing defaults when either field is omitted.
- Limit each field to 8,192 estimated tokens.

## Testing

- Cover custom entry and exit instructions across realtime state transitions.
- Cover token-limit validation for both fields.

GitOrigin-RevId: b9cfa1ff22e084d8a6b2ed56bd27d95ffdd6b6bd
This commit is contained in:
guinness-oai
2026-07-31 23:51:33 +00:00
committed by copyberry
parent 64b2a3008e
commit 670f69416b
18 changed files with 395 additions and 33 deletions
+1 -1
View File
@@ -8808,7 +8808,7 @@ async fn record_context_updates_emits_realtime_end_when_session_stops_being_live
assert!(
developer_texts
.iter()
.any(|text| text.contains("Reason: inactive")),
.any(|text| text.contains("<realtime_conversation>")),
"expected a realtime end update, got {developer_texts:?}"
);
}
+11 -4
View File
@@ -96,12 +96,19 @@ impl Session {
{
world_state.add_section(ContextWindowGuidanceState::new(guidance));
}
let realtime_mode_instructions = self.conversation.mode_instructions().await;
world_state.add_section(RealtimeState::new(
turn_context.realtime_active,
turn_context
.config
.experimental_realtime_start_instructions
.as_deref(),
realtime_mode_instructions
.as_ref()
.and_then(|instructions| instructions.start.as_deref())
.or(turn_context
.config
.experimental_realtime_start_instructions
.as_deref()),
realtime_mode_instructions
.as_ref()
.and_then(|instructions| instructions.end.as_deref()),
));
world_state.add_section(AgentsMdState::new(step_context.loaded_agents_md.as_deref()));
if turn_context.config.include_permissions_instructions {