Add app-server support for reverting paginated threads (#38440)

## What changed

- Add the experimental `thread/revert` request, which replaces a loaded paginated thread's durable history with the prefix before `beforeTurnId` while preserving the thread ID.
- Interrupt any active turn, reload the replacement history without unloading the thread, preserve mutable thread settings, and emit `thread/reverted`.
- Return backward pagination cursors for the retained turns and items, reject stale rollout paths after a revert, and document that local file changes are unaffected.

## Testing

- Cover history replacement, pagination, stale paths, missing turns, subsequent turns, active-turn interruption, and preserved thread settings.

GitOrigin-RevId: 435a8163ad4f310cc47219b436f6bdde21f2b83a
This commit is contained in:
Owen Lin authored and copyberry committed 2026-08-13 21:45:02 +00:00
1 parent 1992f8c018
commit 4343b2bdc4
24 files changed
+939 -21

No files matched your search

@@ -51,6 +51,7 @@ pub(super) fn server_notification_thread_target(
ServerNotification::ThreadStatusChanged(notification) => {
Some(notification.thread_id.as_str())
}
ServerNotification::ThreadReverted(notification) => Some(notification.thread_id.as_str()),
ServerNotification::ThreadArchived(notification) => Some(notification.thread_id.as_str()),
ServerNotification::ThreadDeleted(notification) => Some(notification.thread_id.as_str()),
ServerNotification::ThreadUnarchived(notification) => Some(notification.thread_id.as_str()),
@@ -747,10 +747,10 @@ goals = true
let expected_source_tokens = if committed_steer.is_some() { 150 } else { 50 };
assert_eq!(source_goal.objective, RETRY_GOAL);
assert_eq!(source_goal.tokens_used, expected_source_tokens);
assert_eq!(source_goal.time_used_seconds, 12);
assert!(source_goal.time_used_seconds >= 12);
assert_eq!(retry_goal.objective, RETRY_GOAL);
assert!(retry_goal.tokens_used >= expected_source_tokens);
assert!(retry_goal.time_used_seconds >= 12);
assert!(retry_goal.time_used_seconds >= source_goal.time_used_seconds);
let request_bodies = server
.requests()