mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Bound TUI thread replay buffers by delta size (#39081)
## Why The per-thread replay buffer limited its event count, but streamed agent-message deltas could still retain an unbounded amount of text while a thread was inactive. ## What changed - Coalesce adjacent deltas for the same thread, turn, and item into chunks of up to 4 KiB. - Limit buffered agent-message deltas to 256 KiB, discard a single delta larger than that limit, and evict the oldest events when either buffer limit is exceeded. - Keep pending input and approval state in sync when eviction removes the corresponding request, including clearing side-thread status indicators. ## Testing Added coverage for delta coalescing, byte-based eviction, oversized deltas, replaying only retained text, and side-thread status updates after eviction. GitOrigin-RevId: 88d85353a124467d467822d2fd9854312b68d547
This commit is contained in:
1 parent
8ef139667f
commit
9c099e94a2
7 files changed
+496
-43
No files matched your search
@@ -49,6 +49,7 @@ pub(super) struct ThreadEventStore {
|
||||
pub(super) input_state: Option<ThreadInputState>,
|
||||
pub(super) capacity: usize,
|
||||
pub(super) active: bool,
|
||||
pub(super) buffered_agent_message_delta_bytes: usize,
|
||||
}
|
||||
|
||||
impl ThreadEventStore {
|
||||
@@ -76,6 +77,7 @@ impl ThreadEventStore {
|
||||
input_state: None,
|
||||
capacity,
|
||||
active: false,
|
||||
buffered_agent_message_delta_bytes: 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +100,7 @@ impl ThreadEventStore {
|
||||
|
||||
pub(super) fn rebase_buffer_after_session_refresh(&mut self) {
|
||||
self.buffer.retain(Self::event_survives_session_refresh);
|
||||
self.buffered_agent_message_delta_bytes = 0;
|
||||
}
|
||||
|
||||
pub(super) fn set_turns(&mut self, turns: Vec<Turn>) {
|
||||
@@ -160,31 +163,13 @@ impl ThreadEventStore {
|
||||
return;
|
||||
}
|
||||
|
||||
self.buffer
|
||||
.push_back(ThreadBufferedEvent::Notification(Box::new(
|
||||
notification.into_owned(),
|
||||
)));
|
||||
if self.buffer.len() > self.capacity
|
||||
&& let Some(removed) = self.buffer.pop_front()
|
||||
&& let ThreadBufferedEvent::Request(request) = &removed
|
||||
{
|
||||
self.pending_interactive_replay
|
||||
.note_evicted_server_request(request.as_ref());
|
||||
}
|
||||
self.push_replay_notification(notification);
|
||||
}
|
||||
|
||||
pub(super) fn push_request(&mut self, request: ServerRequest) {
|
||||
self.pending_interactive_replay
|
||||
.note_server_request(&request);
|
||||
self.buffer
|
||||
.push_back(ThreadBufferedEvent::Request(Box::new(request)));
|
||||
if self.buffer.len() > self.capacity
|
||||
&& let Some(removed) = self.buffer.pop_front()
|
||||
&& let ThreadBufferedEvent::Request(request) = &removed
|
||||
{
|
||||
self.pending_interactive_replay
|
||||
.note_evicted_server_request(request.as_ref());
|
||||
}
|
||||
self.push_buffered_event(ThreadBufferedEvent::Request(Box::new(request)));
|
||||
}
|
||||
|
||||
pub(super) fn pending_replay_requests(&self) -> Vec<ServerRequest> {
|
||||
|
||||
Reference in new issue
Block a user