mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:22:05 +00:00
Persist realtime events in the thread timeline (#40508)
## Why Clients need a bounded view of realtime conversations that preserves the order of speech, agent work, and turn lifecycle events without loading the full thread history. ## What changed - Persist realtime session boundaries, transcript segments, and promoted agent items in paginated thread rollouts. - Add the experimental `thread/timeline/list` API to page ordinary items, realtime items, and turn boundaries in canonical rollout order. Include `activeRealtimeSessionAtPageStart` so each page can be rendered independently. - Emit typed `thread/realtime/item/started`, `thread/realtime/item/transcript/delta`, and `thread/realtime/item/completed` notifications around durable realtime items. - Keep the existing `thread/items/list` response and legacy thread history behavior unchanged. ## Testing - Cover mixed timeline pagination, realtime-session state at page boundaries, rollout replay, subagent history prefixes, transcript streaming, steering, and promoted agent artifacts. GitOrigin-RevId: faa2c420192d63e060e8fb32446e3c797422656e
This commit is contained in:
1 parent
80e871309a
commit
41ca88e95c
80 files changed
+5140
-47
No files matched your search
@@ -528,6 +528,9 @@ impl TurnRequestProcessor {
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
self.seal_realtime_transcript_before_user_input(thread_id, &mapped_items)
|
||||
.await?;
|
||||
|
||||
let submission = thread
|
||||
.start_or_steer_turn(
|
||||
TurnInputRequest::new(TurnInput::UserInput {
|
||||
@@ -901,12 +904,12 @@ impl TurnRequestProcessor {
|
||||
request_id: &ConnectionRequestId,
|
||||
params: TurnSteerParams,
|
||||
) -> Result<TurnSteerResponse, JSONRPCErrorError> {
|
||||
let (_, thread) = self
|
||||
.load_thread(¶ms.thread_id)
|
||||
.await
|
||||
.inspect_err(|error| {
|
||||
self.track_error_response(request_id, error, /*error_type*/ None);
|
||||
})?;
|
||||
let (thread_id, thread) =
|
||||
self.load_thread(¶ms.thread_id)
|
||||
.await
|
||||
.inspect_err(|error| {
|
||||
self.track_error_response(request_id, error, /*error_type*/ None);
|
||||
})?;
|
||||
self.ensure_direct_input_allowed(request_id, thread.as_ref())
|
||||
.await?;
|
||||
|
||||
@@ -932,6 +935,9 @@ impl TurnRequestProcessor {
|
||||
.collect();
|
||||
let additional_context = map_additional_context(params.additional_context);
|
||||
|
||||
self.seal_realtime_transcript_before_user_input(thread_id, &mapped_items)
|
||||
.await?;
|
||||
|
||||
let submission = thread
|
||||
.steer_turn(
|
||||
TurnInputRequest::new(TurnInput::UserInput {
|
||||
@@ -1027,6 +1033,37 @@ impl TurnRequestProcessor {
|
||||
Ok(TurnSteerResponse { turn_id })
|
||||
}
|
||||
|
||||
async fn seal_realtime_transcript_before_user_input(
|
||||
&self,
|
||||
thread_id: ThreadId,
|
||||
input: &[CoreInputItem],
|
||||
) -> Result<(), JSONRPCErrorError> {
|
||||
let thread_state = self.thread_state_manager.thread_state(thread_id).await;
|
||||
if !thread_state
|
||||
.lock()
|
||||
.await
|
||||
.realtime_history
|
||||
.should_seal_user_input(input)
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
let listener = self
|
||||
.thread_state_manager
|
||||
.current_listener_command_tx(thread_id)
|
||||
.ok_or_else(|| internal_error("thread listener is not running"))?;
|
||||
let (completion_tx, completion_rx) = tokio::sync::oneshot::channel();
|
||||
listener
|
||||
.send(ThreadListenerCommand::SealRealtimeUserInput {
|
||||
input: input.to_vec(),
|
||||
completion_tx,
|
||||
})
|
||||
.map_err(|_| internal_error("thread listener is not running"))?;
|
||||
completion_rx
|
||||
.await
|
||||
.map_err(|_| internal_error("thread listener stopped before sealing realtime input"))?
|
||||
.map_err(internal_error)
|
||||
}
|
||||
|
||||
async fn prepare_realtime_conversation_thread(
|
||||
&self,
|
||||
request_id: &ConnectionRequestId,
|
||||
|
||||
Reference in new issue
Block a user