mirror of
https://github.com/openai/codex.git
synced 2026-11-26 07:26:11 +00:00
Preserve restored input after resolved misalignment errors (#42399)
## Why Replaying a thread after a later turn has continued can treat an earlier misalignment policy violation as still active, clearing the restored draft and queued follow-up input. ## What changed - Track the latest turn independently of the bounded replay buffer. - Omit misalignment errors from older turns during snapshot and stored-turn replay while preserving an error on the latest turn. - Keep interrupted tool calls from the older turn visible in history. ## Testing Added buffered replay coverage for restored drafts and queued messages, buffer eviction, current-turn violations, and interrupted tool rendering. GitOrigin-RevId: d6c223d9c5a1905fe1b48dc5f9514a7ccbf61d92
This commit is contained in:
1 parent
e6a944ad75
commit
54a4077c8b
7 files changed
+266
-6
No files matched your search
@@ -30,6 +30,7 @@ impl ChatWidget {
|
||||
/// avoid triggering side effects. Event ids are passed as `None` to
|
||||
/// distinguish replayed events from live ones.
|
||||
pub(crate) fn replay_thread_turns(&mut self, turns: Vec<Turn>, replay_kind: ReplayKind) {
|
||||
let latest_turn_id = turns.last().map(|turn| turn.id.clone());
|
||||
let hidden_nested_review_turns = std::iter::once(/*value*/ false)
|
||||
.chain(turns.windows(/*size*/ 2).map(|turns| {
|
||||
crate::app_backtrack::is_hidden_nested_review_turn(&turns[0], &turns[1])
|
||||
@@ -41,7 +42,7 @@ impl ChatWidget {
|
||||
items_view: _,
|
||||
items,
|
||||
status,
|
||||
error,
|
||||
mut error,
|
||||
started_at,
|
||||
completed_at,
|
||||
duration_ms,
|
||||
@@ -62,6 +63,15 @@ impl ChatWidget {
|
||||
} else {
|
||||
status
|
||||
};
|
||||
// A resolved historical precaution must not clear the restored draft or input queue.
|
||||
if Some(&turn_id) != latest_turn_id.as_ref()
|
||||
&& error.as_ref().is_some_and(|error| {
|
||||
error.codex_error_info
|
||||
== Some(AppServerCodexErrorInfo::MisalignmentPolicyViolation)
|
||||
})
|
||||
{
|
||||
error = None;
|
||||
}
|
||||
if matches!(
|
||||
status,
|
||||
TurnStatus::Completed | TurnStatus::Interrupted | TurnStatus::Failed
|
||||
|
||||
Reference in new issue
Block a user