mirror of
https://github.com/openai/codex.git
synced 2026-11-25 23:30:49 +00:00
Record root turn IDs in Guardian review analytics (#63837)
## Why The review's `turn_id` alone can't identify the root turn of the action being reviewed. For example, a background terminal can request network access during a later turn. ## What changed Add an optional `root_turn_id` to `codex_guardian_review` events. When a verified execution tag ties a network request to a registered tool call, use the root turn ID captured when the call started. Leave the field unset when the reviewed action's root turn is unknown. ## Testing Extend the MCP approval test to check the reported root turn ID. Cover untagged network requests and verify that a cross-turn network review reports the active turn's `turn_id` alongside the issuing turn's `root_turn_id`. GitOrigin-RevId: f0ae40ec4fc441891b4d843912f823a2385fa36f
This commit is contained in:
@@ -34,6 +34,7 @@ use crate::ReviewCompletion;
|
||||
pub struct ReviewMetadata {
|
||||
pub thread_id: String,
|
||||
pub turn_id: String,
|
||||
pub root_turn_id: Option<String>,
|
||||
/// Origin of the issuing turn, inherited by delegated turns at admission.
|
||||
pub turn_trigger: Option<String>,
|
||||
pub review_id: String,
|
||||
@@ -79,6 +80,7 @@ impl ReviewReport {
|
||||
let tracking = GuardianReviewTrackContext::new(
|
||||
metadata.thread_id,
|
||||
metadata.turn_id.clone(),
|
||||
metadata.root_turn_id,
|
||||
metadata.review_id.clone(),
|
||||
metadata.target_item_id.clone(),
|
||||
metadata.approval_request_source,
|
||||
|
||||
@@ -59,6 +59,7 @@ fn review_report_bounds_turn_origin_on_both_verdicts(
|
||||
let report = ReviewReport::new(ReviewMetadata {
|
||||
thread_id: "thread".into(),
|
||||
turn_id: "turn".into(),
|
||||
root_turn_id: None,
|
||||
turn_trigger: turn_trigger.map(str::to_owned),
|
||||
review_id: "review".into(),
|
||||
target_item_id: None,
|
||||
@@ -168,6 +169,7 @@ fn review_completion_uses_one_monotonic_duration(
|
||||
let mut report = ReviewReport::new(ReviewMetadata {
|
||||
thread_id: "thread".to_string(),
|
||||
turn_id: "turn".to_string(),
|
||||
root_turn_id: None,
|
||||
turn_trigger: None,
|
||||
review_id: "review".to_string(),
|
||||
target_item_id: None,
|
||||
|
||||
@@ -73,6 +73,7 @@ impl ReviewHost for GatedHost {
|
||||
ReviewReport::new(ReviewMetadata {
|
||||
thread_id: "thread".into(),
|
||||
turn_id: "turn".into(),
|
||||
root_turn_id: None,
|
||||
turn_trigger: None,
|
||||
review_id: approval_id.into(),
|
||||
target_item_id: Some("call".into()),
|
||||
|
||||
Reference in New Issue
Block a user