mirror of
https://github.com/openai/codex.git
synced 2026-10-25 18:28:38 +00:00
Record Guardian context mode in review and classification telemetry (#49294)
## Why Guardian review and classification telemetry lacks the context mode needed to distinguish `legacy`, `independent`, and `thread_owned` reviews. ## What changed - Add `guardian_context_mode` to review and classification analytics and `context_mode` to their metrics. - Capture the mode from the conversation history snapshot before review preparation or classification setup so failure metrics retain it, including when review preparation or reviewer startup fails. - Use `unknown` for review metric tags when no context mode is available. ## Testing Update metric assertions to cover `thread_owned` classification tags and the `unknown` review fallback. GitOrigin-RevId: 79f7d11b3e4ccfc53681890d75fbc7c54e1ce7de
This commit is contained in:
@@ -15,6 +15,15 @@ pub enum GuardianContextMode {
|
||||
}
|
||||
|
||||
impl GuardianContextMode {
|
||||
/// Stable, bounded label for the context actually selected for a review.
|
||||
pub fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
Self::Legacy => "legacy",
|
||||
Self::Independent => "independent",
|
||||
Self::ThreadOwned => "thread_owned",
|
||||
}
|
||||
}
|
||||
|
||||
/// Read reviewer policy from the same snapshot as its evidence, including delayed reviews.
|
||||
pub fn from_history(history: &dyn ConversationHistorySnapshot) -> Self {
|
||||
if history.uses_independent_review_history() {
|
||||
|
||||
@@ -207,13 +207,22 @@ pub(crate) async fn run_guardian_review_session(
|
||||
pool: Arc<ReviewerPool<GuardianReviewSession>>,
|
||||
params: GuardianReviewSessionParams,
|
||||
) -> (GuardianReviewSessionOutcome, GuardianReviewAnalyticsResult) {
|
||||
match prepare_review(params).await {
|
||||
let context_mode = GuardianContextMode::from_history(
|
||||
params
|
||||
.parent_history
|
||||
.conversation_history_snapshot()
|
||||
.as_ref(),
|
||||
);
|
||||
let (outcome, mut analytics) = match prepare_review(params).await {
|
||||
Ok(prepared) => pool.review(prepared).await,
|
||||
Err(error) => (
|
||||
GuardianReviewSessionOutcome::PromptBuildFailed(error),
|
||||
GuardianReviewAnalyticsResult::without_session(),
|
||||
),
|
||||
}
|
||||
};
|
||||
// Keep the captured mode even when preparation or reviewer startup fails.
|
||||
analytics.guardian_context_mode = Some(context_mode.as_str());
|
||||
(outcome, analytics)
|
||||
}
|
||||
|
||||
pub(super) async fn prepare_review(
|
||||
|
||||
Reference in New Issue
Block a user