mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Centralize bounded Guardian review evidence in guardian-context (#43595)
## What changed Move prior-review rendering and developer-message construction into `codex_guardian_context`, and route async scorer evidence through a dedicated `PreviousReviews` context section. Validate a maximum of eight review fragments and a per-fragment byte budget equivalent to 1,000 approximate tokens. Reject oversized evidence without rewriting or dropping records, and fail closed when validation fails. Preserve authorization-version filtering and the existing developer-role delivery. Keep review contents out of debug output. ## Testing Add coverage for count and UTF-8 byte-size boundaries, preservation of accepted fragments, async-only section delivery, and omission of review contents from debug output. GitOrigin-RevId: 05e9f53a6405f490b2424b2491a834cd90ab24f0
This commit is contained in:
@@ -10,6 +10,7 @@ use std::sync::Mutex;
|
||||
use std::sync::PoisonError;
|
||||
|
||||
use codex_extension_api::ConversationHistorySnapshot;
|
||||
use codex_guardian_context::MAX_PREVIOUS_REVIEWS;
|
||||
use codex_protocol::models::ContentItemKind;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
use codex_protocol::protocol::GuardianAssessmentEvent;
|
||||
@@ -23,7 +24,7 @@ use crate::codex_thread::GuardianAuthorizationVersion;
|
||||
use crate::codex_thread::GuardianRootMessage;
|
||||
use crate::guardian::guardian_truncate_text;
|
||||
|
||||
const MAX_RETAINED_REVIEWS: usize = 8;
|
||||
const MAX_RETAINED_USER_INPUTS: usize = 8;
|
||||
const MAX_TRUSTED_SKILLS: usize = 16;
|
||||
const MAX_TRUSTED_SKILL_PATHS_BYTES: usize = 2_048;
|
||||
const MAX_GUARDIAN_USER_INPUT_ANSWERS: usize = 8;
|
||||
@@ -117,7 +118,7 @@ impl GuardianReviewEvidence {
|
||||
let mut state = self.state.lock().unwrap_or_else(PoisonError::into_inner);
|
||||
state.user_input_response_count = state.user_input_response_count.saturating_add(1);
|
||||
state.user_inputs.push_back((call_id.to_owned(), fragment));
|
||||
while state.user_inputs.len() > MAX_RETAINED_REVIEWS {
|
||||
while state.user_inputs.len() > MAX_RETAINED_USER_INPUTS {
|
||||
state.user_inputs.pop_front();
|
||||
}
|
||||
}
|
||||
@@ -265,7 +266,7 @@ impl GuardianReviewEvidence {
|
||||
.reviews
|
||||
.make_contiguous()
|
||||
.sort_by_key(|review| review.completed_at_ms);
|
||||
while state.reviews.len() > MAX_RETAINED_REVIEWS {
|
||||
while state.reviews.len() > MAX_PREVIOUS_REVIEWS {
|
||||
state.reviews.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user