mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:22:05 +00:00
Record realtime conversation history in Core (#41924)
## Why Realtime history should be recorded consistently for every Core host, including when no app-server event listener is attached. ## What changed - Move transcript segmentation, session boundaries, and backing-agent artifact promotion into Core for paginated threads. - Persist canonical realtime items through the thread store in event order and emit dedicated history lifecycle events for hosts to present. - Translate those Core events into the existing app-server realtime item notifications without app-server persisting the items a second time. ## Testing - Cover Core-only persistence across repeated sessions, ephemeral sessions, accepted and rejected steering, typed input ordering, and artifact promotion. - Verify app-server notifications correspond to the persisted timeline. GitOrigin-RevId: 7cbef14129d77f6d6d7099b733be91f5279c55f5
This commit is contained in:
1 parent
34c4f7e72d
commit
64c9cde458
22 files changed
+971
-472
No files matched your search
@@ -619,10 +619,6 @@ impl TurnRequestProcessor {
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
if let TurnInput::UserInput { content, .. } = &input {
|
||||
self.seal_realtime_transcript_before_user_input(thread_id, content)
|
||||
.await?;
|
||||
}
|
||||
|
||||
let submission = thread
|
||||
.start_or_steer_turn(
|
||||
@@ -997,12 +993,12 @@ impl TurnRequestProcessor {
|
||||
request_id: &ConnectionRequestId,
|
||||
params: TurnSteerParams,
|
||||
) -> Result<TurnSteerResponse, JSONRPCErrorError> {
|
||||
let (thread_id, thread) =
|
||||
self.load_thread(¶ms.thread_id)
|
||||
.await
|
||||
.inspect_err(|error| {
|
||||
self.track_error_response(request_id, error, /*error_type*/ None);
|
||||
})?;
|
||||
let (_, 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?;
|
||||
|
||||
@@ -1028,9 +1024,6 @@ 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 {
|
||||
@@ -1127,37 +1120,6 @@ 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