Preserve Guardian review evidence across compaction (#41846)

## Why

Context compaction can replace original conversation items that Guardian still needs to review approval-sensitive actions.

## What changed

- Retain a bounded, chronological review history independently of the model's compacted history.
- Keep separate limits for user messages and other transcript items so tool traffic cannot evict user instructions.
- Use the retained evidence for synchronous and asynchronous Guardian transcripts, while resetting it after rollback or history reconstruction.

## Testing

- Cover retention through compaction and eviction, reset behavior after rollback, independent size limits, and asynchronous transcript construction.

GitOrigin-RevId: c5851e992820504fc18de8cfec7f6f9f1b69f316
This commit is contained in:
jif authored and copyberry committed 2026-08-31 13:57:59 +00:00
1 parent e45226e771
commit 1c1e17782a
15 files changed
+468 -31

No files matched your search

+3 -9
View File
@@ -335,16 +335,10 @@ pub async fn thread_rollback(sess: &Arc<Session>, sub_id: String, num_turns: u32
.collect::<Vec<_>>();
sess.apply_rollout_reconstruction(turn_context.as_ref(), replay_items.as_slice())
.await;
if sess
.services
sess.services
.thread_extension_data
.remove::<NodeReplReviewEvidence>()
.is_some()
{
sess.guardian_review_session
.invalidate_for_node_repl_evidence()
.await;
}
.remove::<NodeReplReviewEvidence>();
sess.guardian_review_session.invalidate().await;
sess.services
.agent_control
.rollout_budget()