Seed realtime V3 sessions with initial text items (#34067)

## What changed

- Add an optional `initialItems` field to `thread/realtime/start` for seeding
  realtime V3 session history with `user`, `developer`, and `assistant` text.
- Encode the items in Frameless Bidi session bootstrap payloads for websocket
  and WebRTC transports while preserving existing payloads when the list is
  omitted or empty.
- Reject non-empty initial items for V1 and V2, more than 128 items, any item
  over 8,192 estimated tokens, or a combined total over 8,192 estimated tokens.

## Testing

- Cover protocol serialization, app-server forwarding, websocket and WebRTC
  payloads, empty-list compatibility, version checks, and size limits.

GitOrigin-RevId: 09af367f9a07543e3f8d59b7fa5387f932dc5a6a
This commit is contained in:
jiayuhuang-openai authored and copyberry committed 2026-07-18 20:59:57 +00:00
1 parent 35eaf3ffb0
commit 312caf176a
25 files changed
+657 -9

No files matched your search

@@ -4375,3 +4375,14 @@ fn realtime_append_text_defaults_role_to_user() {
}
);
}
#[test]
fn realtime_start_omitted_initial_items_remain_none() {
let params = serde_json::from_value::<ThreadRealtimeStartParams>(json!({
"threadId": "thread_123",
"outputModality": "audio",
}))
.expect("params should deserialize");
assert_eq!(params.initial_items, None);
}