Avoid duplicate sync reviews in Guardian classifier continuations (#49795)

## Why

Retained Guardian classifier conversations already contain previously delivered synchronous reviews. Appending those reviews again repeats evidence and consumes input budget.

## What changed

Track each review completion with a stable identity in host-only history metadata. Filter already delivered reviews before composing and budgeting continuation input, while preserving distinct completions even when their text is identical.

Fresh conversations receive the review evidence again, and shortened messages no longer count as complete delivery. Delivery metadata stays out of model requests.

## Testing

Add coverage for delivering retained reviews once, appending newly completed reviews, restoring evidence after failed streams, and retaining reviews when history lacks complete delivery metadata.

GitOrigin-RevId: b8d58ffdd7d9c484676af707c65fa50020aae73c
This commit is contained in:
felixxia-oai
2026-10-01 01:13:29 +00:00
committed by copyberry
parent 726f1492db
commit 47a8bd7321
21 changed files with 300 additions and 70 deletions
@@ -125,6 +125,7 @@ impl GuardianReviewEvidence {
return;
};
let review = Arc::new(GuardianReviewEvidenceRecord {
delivery_id: codex_protocol::ResponseItemId::new("guardian_review"),
completed_at_ms,
authorization_version,
review_context_revision,
@@ -170,6 +171,8 @@ impl GuardianReviewEvidence {
/// Structured synchronous-review evidence retained for Guardian V2 classification.
#[derive(Debug)]
pub struct GuardianReviewEvidenceRecord {
/// Identifies this immutable completion even if the same action is reviewed again.
pub delivery_id: codex_protocol::ResponseItemId,
pub authorization_version: GuardianAuthorizationVersion,
pub review_context_revision: u64,
pub root_authorization_version: Option<GuardianAuthorizationVersion>,