mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Persist timestamped realtime frames before acknowledging completion (#61473)
## What changed - Record voice transcripts as `frame` items with a `voice_transcript` channel for eligible threads, while retaining legacy transcript support and the existing app-server live and mixed timeline representation. - Assign first-observed timestamps that never move backward, retain them through completion, and restore the clock floor from history and compaction checkpoints. - Flush realtime records before completion notifications, including file and initial directory durability barriers for local rollouts. - Generate a distinct default session ID for each new call, use the call ID when attaching to an existing call, and derive opening record IDs from session IDs. - Add protocol types for turn-input acceptance and session-end input receipts, excluding those receipts from live notifications and mixed timelines. Update generated schemas and SDK types. ## Testing Add coverage for frame serialization and required voice payloads, clock rollback and checkpoint restoration, durability barrier failures and retries, per-call session IDs, and persisted transcript availability immediately after completion. GitOrigin-RevId: 3f6632b517d563861aee085b723475b8945c391c
This commit is contained in:
@@ -798,6 +798,10 @@ impl ThreadStore for LocalThreadStore {
|
||||
Box::pin(async move { projects::delete_project(self, project_id).await })
|
||||
}
|
||||
|
||||
fn realtime_frames_enabled(&self, _thread_id: ThreadId) -> ThreadStoreFuture<'_, bool> {
|
||||
Box::pin(async { Ok(self.state_db.is_some()) })
|
||||
}
|
||||
|
||||
fn supports_paginated_history_lists(&self) -> bool {
|
||||
self.state_db.is_some()
|
||||
}
|
||||
|
||||
@@ -283,6 +283,7 @@ async fn fork_version_stops_before_older_segments_once_resolved() {
|
||||
next_item_ordinal: None,
|
||||
rejected_audio_file_ids: Default::default(),
|
||||
dynamic_tools: None,
|
||||
observation_clock_floor_ms: None,
|
||||
multi_agent_version: Some(MultiAgentVersion::V2),
|
||||
last_started_turn_id: None,
|
||||
turn_attribution: None,
|
||||
|
||||
@@ -430,6 +430,7 @@ async fn timeline_interleaves_items_and_restores_page_boundary_session_state() {
|
||||
RealtimeItem {
|
||||
id: "voice-1:started".to_string(),
|
||||
realtime_session_id: "voice-1".to_string(),
|
||||
observed_at_ms: None,
|
||||
content: RealtimeItemContent::RealtimeSessionStarted,
|
||||
},
|
||||
),
|
||||
@@ -438,6 +439,7 @@ async fn timeline_interleaves_items_and_restores_page_boundary_session_state() {
|
||||
RealtimeItem {
|
||||
id: "voice-1:source:0".to_string(),
|
||||
realtime_session_id: "voice-1".to_string(),
|
||||
observed_at_ms: None,
|
||||
content: RealtimeItemContent::TranscriptSegment {
|
||||
role: RealtimeTranscriptRole::Assistant,
|
||||
text: "Before the artifact".to_string(),
|
||||
@@ -449,6 +451,7 @@ async fn timeline_interleaves_items_and_restores_page_boundary_session_state() {
|
||||
RealtimeItem {
|
||||
id: "artifact".to_string(),
|
||||
realtime_session_id: "voice-1".to_string(),
|
||||
observed_at_ms: None,
|
||||
content: RealtimeItemContent::BemItemPromoted {
|
||||
turn_id: "turn-1".to_string(),
|
||||
item_id: "middle".to_string(),
|
||||
@@ -461,6 +464,7 @@ async fn timeline_interleaves_items_and_restores_page_boundary_session_state() {
|
||||
RealtimeItem {
|
||||
id: "voice-1:closed".to_string(),
|
||||
realtime_session_id: "voice-1".to_string(),
|
||||
observed_at_ms: None,
|
||||
content: RealtimeItemContent::RealtimeSessionClosed {
|
||||
outcome: RealtimeSessionOutcome::Ended,
|
||||
},
|
||||
@@ -727,6 +731,7 @@ async fn timeline_page_state_excludes_realtime_events_after_fork_cutoff() {
|
||||
RealtimeItem {
|
||||
id: "voice:started".to_string(),
|
||||
realtime_session_id: "voice".to_string(),
|
||||
observed_at_ms: None,
|
||||
content: RealtimeItemContent::RealtimeSessionStarted,
|
||||
},
|
||||
),
|
||||
@@ -735,6 +740,7 @@ async fn timeline_page_state_excludes_realtime_events_after_fork_cutoff() {
|
||||
RealtimeItem {
|
||||
id: "voice:closed".to_string(),
|
||||
realtime_session_id: "voice".to_string(),
|
||||
observed_at_ms: None,
|
||||
content: RealtimeItemContent::RealtimeSessionClosed {
|
||||
outcome: RealtimeSessionOutcome::Ended,
|
||||
},
|
||||
|
||||
@@ -130,6 +130,7 @@ ORDER BY rollout_ordinal DESC, item_id DESC LIMIT ?7
|
||||
SELECT rollout_ordinal, 2 AS kind, item_id AS id, NULL AS turn_id, item_json
|
||||
FROM thread_realtime_items
|
||||
WHERE thread_id = ?1 AND rollout_ordinal >= ?2
|
||||
AND item_type NOT IN ('turn_input_accepted', 'session_end_input_saved')
|
||||
AND rollout_ordinal < ?3 AND rollout_ordinal <= ?4
|
||||
AND (rollout_ordinal, 2, item_id) < (?4, ?5, ?6)
|
||||
ORDER BY rollout_ordinal DESC, item_id DESC LIMIT ?7
|
||||
|
||||
@@ -626,11 +626,13 @@ async fn paginated_realtime_items_materialize_separately_in_rollout_order() {
|
||||
RolloutItem::RealtimeItem(RealtimeItem {
|
||||
id: "voice:started".to_string(),
|
||||
realtime_session_id: "voice".to_string(),
|
||||
observed_at_ms: None,
|
||||
content: RealtimeItemContent::RealtimeSessionStarted,
|
||||
}),
|
||||
RolloutItem::RealtimeItem(RealtimeItem {
|
||||
id: "voice:transcript:0".to_string(),
|
||||
realtime_session_id: "voice".to_string(),
|
||||
observed_at_ms: None,
|
||||
content: RealtimeItemContent::TranscriptSegment {
|
||||
role: RealtimeTranscriptRole::Assistant,
|
||||
text: "Here is the result.".to_string(),
|
||||
@@ -640,6 +642,7 @@ async fn paginated_realtime_items_materialize_separately_in_rollout_order() {
|
||||
RolloutItem::RealtimeItem(RealtimeItem {
|
||||
id: "voice:promoted:agent-1".to_string(),
|
||||
realtime_session_id: "voice".to_string(),
|
||||
observed_at_ms: None,
|
||||
content: RealtimeItemContent::BemItemPromoted {
|
||||
turn_id: "turn-1".to_string(),
|
||||
item_id: "agent-1".to_string(),
|
||||
@@ -664,6 +667,7 @@ async fn paginated_realtime_items_materialize_separately_in_rollout_order() {
|
||||
RolloutItem::RealtimeItem(RealtimeItem {
|
||||
id: "voice:closed".to_string(),
|
||||
realtime_session_id: "voice".to_string(),
|
||||
observed_at_ms: None,
|
||||
content: RealtimeItemContent::RealtimeSessionClosed {
|
||||
outcome: RealtimeSessionOutcome::Ended,
|
||||
},
|
||||
@@ -797,6 +801,7 @@ async fn paginated_realtime_items_materialize_separately_in_rollout_order() {
|
||||
items: vec![RolloutItem::RealtimeItem(RealtimeItem {
|
||||
id: "legacy:started".to_string(),
|
||||
realtime_session_id: "legacy".to_string(),
|
||||
observed_at_ms: None,
|
||||
content: RealtimeItemContent::RealtimeSessionStarted,
|
||||
})],
|
||||
})
|
||||
@@ -1487,6 +1492,7 @@ async fn subagent_prefix_advances_projection_without_materializing_history() {
|
||||
RolloutItem::RealtimeItem(RealtimeItem {
|
||||
id: "parent:started".to_string(),
|
||||
realtime_session_id: "parent".to_string(),
|
||||
observed_at_ms: None,
|
||||
content: RealtimeItemContent::RealtimeSessionStarted,
|
||||
}),
|
||||
turn_started("parent-turn"),
|
||||
@@ -1504,6 +1510,7 @@ async fn subagent_prefix_advances_projection_without_materializing_history() {
|
||||
RolloutItem::RealtimeItem(RealtimeItem {
|
||||
id: "child:started".to_string(),
|
||||
realtime_session_id: "child".to_string(),
|
||||
observed_at_ms: None,
|
||||
content: RealtimeItemContent::RealtimeSessionStarted,
|
||||
}),
|
||||
completed_item(
|
||||
|
||||
@@ -547,6 +547,11 @@ pub trait ThreadStore: Any + Send + Sync {
|
||||
})
|
||||
}
|
||||
|
||||
/// Whether this live thread writes canonical realtime frames and handoff receipts.
|
||||
fn realtime_frames_enabled(&self, _thread_id: ThreadId) -> ThreadStoreFuture<'_, bool> {
|
||||
Box::pin(async { Ok(false) })
|
||||
}
|
||||
|
||||
/// Whether paginated threads can hydrate durable history through turn and item lists.
|
||||
fn supports_paginated_history_lists(&self) -> bool {
|
||||
false
|
||||
|
||||
Reference in New Issue
Block a user