mirror of
https://github.com/openai/codex.git
synced 2026-11-26 23:40:43 +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:
@@ -453,6 +453,7 @@ pub struct GuardianReviewEventParams {
|
||||
pub guardian_context_mode: Option<&'static str>,
|
||||
pub thread_id: String,
|
||||
pub turn_id: String,
|
||||
pub root_turn_id: Option<String>,
|
||||
pub review_id: String,
|
||||
pub target_item_id: Option<String>,
|
||||
pub approval_request_source: GuardianApprovalRequestSource,
|
||||
@@ -493,6 +494,7 @@ pub struct GuardianReviewEventParams {
|
||||
pub struct GuardianReviewTrackContext {
|
||||
thread_id: String,
|
||||
turn_id: String,
|
||||
root_turn_id: Option<String>,
|
||||
review_id: String,
|
||||
target_item_id: Option<String>,
|
||||
approval_request_source: GuardianApprovalRequestSource,
|
||||
@@ -502,9 +504,11 @@ pub struct GuardianReviewTrackContext {
|
||||
}
|
||||
|
||||
impl GuardianReviewTrackContext {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
thread_id: String,
|
||||
turn_id: String,
|
||||
root_turn_id: Option<String>,
|
||||
review_id: String,
|
||||
target_item_id: Option<String>,
|
||||
approval_request_source: GuardianApprovalRequestSource,
|
||||
@@ -514,6 +518,7 @@ impl GuardianReviewTrackContext {
|
||||
Self {
|
||||
thread_id,
|
||||
turn_id,
|
||||
root_turn_id,
|
||||
review_id,
|
||||
target_item_id,
|
||||
approval_request_source,
|
||||
@@ -534,6 +539,7 @@ impl GuardianReviewTrackContext {
|
||||
guardian_context_mode: result.guardian_context_mode,
|
||||
thread_id: self.thread_id.clone(),
|
||||
turn_id: self.turn_id.clone(),
|
||||
root_turn_id: self.root_turn_id.clone(),
|
||||
review_id: self.review_id.clone(),
|
||||
target_item_id: self.target_item_id.clone(),
|
||||
approval_request_source: self.approval_request_source,
|
||||
|
||||
@@ -298,6 +298,7 @@ async fn guardian_review_event_ingests_custom_fact_with_optional_target_item() {
|
||||
guardian_context_mode: None,
|
||||
thread_id: "thread-guardian".to_string(),
|
||||
turn_id: "turn-guardian".to_string(),
|
||||
root_turn_id: None,
|
||||
review_id: "review-guardian".to_string(),
|
||||
target_item_id: None,
|
||||
approval_request_source: GuardianApprovalRequestSource::DelegatedSubagent,
|
||||
|
||||
Reference in New Issue
Block a user