mirror of
https://github.com/openai/codex.git
synced 2026-11-28 23:34:06 +00:00
Remove the deprecated thread/rollback API (#44915)
## What changed Remove `thread/rollback`, its request and response types, generated bindings, and the core `Op::ThreadRollback` operation. Requests now follow the generic unknown-method rejection path. Document `thread/revert` as the alternative for paginated threads. Keep historical `ThreadRolledBack` markers and legacy error deserialization so existing rollouts remain compatible with replay and migration. ## Testing Adapt retained-context and Guardian history tests to append legacy rollback markers and resume threads, preserving coverage of surviving instructions, answers, and review history. GitOrigin-RevId: b3da1becdf86b1869275aacb0ffc2817cee5af2e
This commit is contained in:
1 parent
c62d191c4c
commit
3052bbcf8c
65 files changed
+124
-5472
No files matched your search
@@ -11,8 +11,6 @@ pub(super) struct ListenerTaskContext {
|
||||
pub(super) outgoing: Arc<OutgoingMessageSender>,
|
||||
pub(super) pending_thread_unloads: Arc<Mutex<HashSet<ThreadId>>>,
|
||||
pub(super) thread_watch_manager: ThreadWatchManager,
|
||||
pub(super) thread_list_state_permit: Arc<Semaphore>,
|
||||
pub(super) fallback_model_provider: String,
|
||||
pub(super) codex_home: PathBuf,
|
||||
pub(super) thread_unload_delay: Duration,
|
||||
pub(super) skills_watcher: Arc<SkillsWatcher>,
|
||||
@@ -271,8 +269,6 @@ pub(super) async fn ensure_listener_task_running(
|
||||
thread_state_manager,
|
||||
pending_thread_unloads,
|
||||
thread_watch_manager,
|
||||
thread_list_state_permit,
|
||||
fallback_model_provider,
|
||||
codex_home,
|
||||
turn_cost_worker,
|
||||
..
|
||||
@@ -353,8 +349,6 @@ pub(super) async fn ensure_listener_task_running(
|
||||
thread_outgoing,
|
||||
thread_state.clone(),
|
||||
thread_watch_manager.clone(),
|
||||
thread_list_state_permit.clone(),
|
||||
fallback_model_provider.clone(),
|
||||
)
|
||||
.await;
|
||||
if matches!(event.msg, EventMsg::ShutdownComplete)
|
||||
|
||||
@@ -30,9 +30,6 @@ use std::ops::ControlFlow;
|
||||
|
||||
pub(super) const THREAD_LIST_DEFAULT_LIMIT: usize = 25;
|
||||
pub(super) const THREAD_LIST_MAX_LIMIT: usize = 100;
|
||||
const CODEX_TUI_CLIENT_NAME: &str = "codex-tui";
|
||||
const THREAD_ROLLBACK_DEPRECATION_SUMMARY: &str =
|
||||
"thread/rollback is deprecated and will be removed soon";
|
||||
const PAGINATED_FULL_HISTORY_DEPRECATION_SUMMARY: &str = "Full-history hydration is deprecated for paginated threads; use `excludeTurns: true`, then page with `thread/turns/list` and `thread/items/list`.";
|
||||
const PAGINATED_THREAD_READ_DEPRECATION_SUMMARY: &str = "Full-history hydration is deprecated for paginated threads; omit `includeTurns` or set it to `false`, then page with `thread/turns/list` and `thread/items/list`.";
|
||||
|
||||
@@ -808,24 +805,6 @@ impl ThreadRequestProcessor {
|
||||
.map(|response| Some(response.into()))
|
||||
}
|
||||
|
||||
pub(crate) async fn thread_rollback(
|
||||
&self,
|
||||
request_id: &ConnectionRequestId,
|
||||
params: ThreadRollbackParams,
|
||||
app_server_client_name: Option<&str>,
|
||||
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
|
||||
if app_server_client_name != Some(CODEX_TUI_CLIENT_NAME) {
|
||||
self.send_deprecation_notice(
|
||||
request_id.connection_id,
|
||||
THREAD_ROLLBACK_DEPRECATION_SUMMARY,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
self.thread_rollback_inner(request_id, params)
|
||||
.await
|
||||
.map(|()| None)
|
||||
}
|
||||
|
||||
async fn send_deprecation_notice(&self, connection_id: ConnectionId, summary: &str) {
|
||||
self.outgoing
|
||||
.send_server_notification_to_connections(
|
||||
@@ -1102,8 +1081,6 @@ impl ThreadRequestProcessor {
|
||||
outgoing: Arc::clone(&self.outgoing),
|
||||
pending_thread_unloads: Arc::clone(&self.pending_thread_unloads),
|
||||
thread_watch_manager: self.thread_watch_manager.clone(),
|
||||
thread_list_state_permit: self.thread_list_state_permit.clone(),
|
||||
fallback_model_provider: self.config.model_provider_id.clone(),
|
||||
codex_home: self.config.codex_home.to_path_buf(),
|
||||
thread_unload_delay: self.config.thread_unload_delay,
|
||||
skills_watcher: Arc::clone(&self.skills_watcher),
|
||||
@@ -1234,8 +1211,6 @@ impl ThreadRequestProcessor {
|
||||
outgoing: Arc::clone(&self.outgoing),
|
||||
pending_thread_unloads: Arc::clone(&self.pending_thread_unloads),
|
||||
thread_watch_manager: self.thread_watch_manager.clone(),
|
||||
thread_list_state_permit: self.thread_list_state_permit.clone(),
|
||||
fallback_model_provider: self.config.model_provider_id.clone(),
|
||||
codex_home: self.config.codex_home.to_path_buf(),
|
||||
thread_unload_delay: self.config.thread_unload_delay,
|
||||
skills_watcher: Arc::clone(&self.skills_watcher),
|
||||
@@ -2118,14 +2093,6 @@ impl ThreadRequestProcessor {
|
||||
Ok((ThreadUnarchiveResponse { thread }, thread_id))
|
||||
}
|
||||
|
||||
async fn thread_rollback_inner(
|
||||
&self,
|
||||
request_id: &ConnectionRequestId,
|
||||
params: ThreadRollbackParams,
|
||||
) -> Result<(), JSONRPCErrorError> {
|
||||
self.thread_rollback_start(request_id, params).await
|
||||
}
|
||||
|
||||
async fn thread_revert_response(
|
||||
&self,
|
||||
request_id: &ConnectionRequestId,
|
||||
@@ -2353,71 +2320,6 @@ impl ThreadRequestProcessor {
|
||||
})
|
||||
}
|
||||
|
||||
async fn thread_rollback_start(
|
||||
&self,
|
||||
request_id: &ConnectionRequestId,
|
||||
params: ThreadRollbackParams,
|
||||
) -> Result<(), JSONRPCErrorError> {
|
||||
let ThreadRollbackParams {
|
||||
thread_id,
|
||||
num_turns,
|
||||
} = params;
|
||||
|
||||
if num_turns == 0 {
|
||||
return Err(invalid_request("numTurns must be >= 1"));
|
||||
}
|
||||
|
||||
let (thread_id, thread) = self.load_thread(&thread_id).await?;
|
||||
ensure_direct_input_allowed(thread.as_ref()).await?;
|
||||
if matches!(
|
||||
thread.config_snapshot().await.history_mode,
|
||||
ThreadHistoryMode::Paginated
|
||||
) {
|
||||
return Err(invalid_request(
|
||||
"paginated threads do not support thread/rollback",
|
||||
));
|
||||
}
|
||||
|
||||
let request = request_id.clone();
|
||||
let (completion_tx, completion_rx) = tokio::sync::oneshot::channel();
|
||||
|
||||
let rollback_already_in_progress = {
|
||||
let thread_state = self.thread_state_manager.thread_state(thread_id).await;
|
||||
let mut thread_state = thread_state.lock().await;
|
||||
if thread_state.pending_rollbacks.is_some() {
|
||||
true
|
||||
} else {
|
||||
thread_state.pending_rollbacks = Some((request, completion_tx));
|
||||
false
|
||||
}
|
||||
};
|
||||
if rollback_already_in_progress {
|
||||
return Err(invalid_request(
|
||||
"rollback already in progress for this thread",
|
||||
));
|
||||
}
|
||||
|
||||
if let Err(err) = self
|
||||
.submit_core_op(
|
||||
request_id,
|
||||
thread.as_ref(),
|
||||
Op::ThreadRollback { num_turns },
|
||||
)
|
||||
.await
|
||||
{
|
||||
// No ThreadRollback event will arrive if an error occurs.
|
||||
// Clean up and reply immediately.
|
||||
let thread_state = self.thread_state_manager.thread_state(thread_id).await;
|
||||
thread_state.lock().await.pending_rollbacks = None;
|
||||
|
||||
return Err(internal_error(format!("failed to start rollback: {err}")));
|
||||
}
|
||||
// The listener drops the sender after queuing the response, including errors.
|
||||
// Keep the RPC's drain admission alive until then, without holding thread state.
|
||||
let _ = completion_rx.await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn thread_compact_start_inner(
|
||||
&self,
|
||||
request_id: &ConnectionRequestId,
|
||||
|
||||
@@ -85,7 +85,6 @@ pub(crate) struct TurnRequestProcessor {
|
||||
pending_thread_unloads: Arc<Mutex<HashSet<ThreadId>>>,
|
||||
thread_state_manager: ThreadStateManager,
|
||||
thread_watch_manager: ThreadWatchManager,
|
||||
thread_list_state_permit: Arc<Semaphore>,
|
||||
skills_watcher: Arc<SkillsWatcher>,
|
||||
turn_cost_worker: Option<crate::turn_cost_worker::TurnCostWorkerHandle>,
|
||||
}
|
||||
@@ -149,7 +148,6 @@ impl TurnRequestProcessor {
|
||||
pending_thread_unloads: Arc<Mutex<HashSet<ThreadId>>>,
|
||||
thread_state_manager: ThreadStateManager,
|
||||
thread_watch_manager: ThreadWatchManager,
|
||||
thread_list_state_permit: Arc<Semaphore>,
|
||||
skills_watcher: Arc<SkillsWatcher>,
|
||||
turn_cost_worker: Option<crate::turn_cost_worker::TurnCostWorkerHandle>,
|
||||
) -> Self {
|
||||
@@ -166,7 +164,6 @@ impl TurnRequestProcessor {
|
||||
pending_thread_unloads,
|
||||
thread_state_manager,
|
||||
thread_watch_manager,
|
||||
thread_list_state_permit,
|
||||
skills_watcher,
|
||||
turn_cost_worker,
|
||||
}
|
||||
@@ -1657,8 +1654,6 @@ impl TurnRequestProcessor {
|
||||
outgoing: Arc::clone(&self.outgoing),
|
||||
pending_thread_unloads: Arc::clone(&self.pending_thread_unloads),
|
||||
thread_watch_manager: self.thread_watch_manager.clone(),
|
||||
thread_list_state_permit: self.thread_list_state_permit.clone(),
|
||||
fallback_model_provider: self.config.model_provider_id.clone(),
|
||||
codex_home: self.config.codex_home.to_path_buf(),
|
||||
thread_unload_delay: self.config.thread_unload_delay,
|
||||
skills_watcher: Arc::clone(&self.skills_watcher),
|
||||
|
||||
Reference in new issue
Block a user