Relax resumed snapshot invariant

Keep the local truncate invariant visible in debug builds, but fall back to forked history instead of panicking if a resumed history ever reaches snapshot_fork_history.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Charles Cunningham
2026-03-19 16:27:41 -07:00
parent 51ee2891f5
commit 095e8bcf2f

View File

@@ -877,7 +877,23 @@ fn snapshot_fork_history(
history.push(RolloutItem::ResponseItem(interrupted_turn_history_marker()));
InitialHistory::Forked(history)
}
(InitialHistory::Resumed(_), _) => unreachable!("truncate_before_nth_user_message"),
(InitialHistory::Resumed(resumed), ForkSnapshotMode::Committed) => {
debug_assert!(
false,
"truncate_before_nth_user_message should not return InitialHistory::Resumed"
);
InitialHistory::Forked(resumed.history)
}
(InitialHistory::Resumed(mut resumed), ForkSnapshotMode::Interrupted) => {
debug_assert!(
false,
"truncate_before_nth_user_message should not return InitialHistory::Resumed"
);
resumed
.history
.push(RolloutItem::ResponseItem(interrupted_turn_history_marker()));
InitialHistory::Forked(resumed.history)
}
}
}