mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:10:47 +00:00
Log probe results when Guardian V3 prepares a review (#63327)
## What changed Carry the serving probe result from the tool step into the review context. Include `tool_call_id` and `probe_review` in the Guardian V3 preparation log so the result can be correlated with the tool call. Record the probe as `required`, `not_required`, or `not_reported`. Approval decisions continue to follow the review verdict. ## Testing Extend the pending MCP action integration test to check the logged tool call ID and probe status for all three cases while exercising the same revocation and reapproval flow. GitOrigin-RevId: 43cd3691ae20af29f690ee2697d3d46bcc3bd8ce
This commit is contained in:
@@ -49,13 +49,18 @@ fn received_user_instruction(request: &responses::ResponsesRequest, text: &str)
|
||||
})
|
||||
}
|
||||
|
||||
#[test_case(ReviewCase::V3; "v3_follows_subscribed_revocation_and_reapproval")]
|
||||
#[test_case(ReviewCase::V3WithReconsideration; "v3_resamples_a_terminal_denial_once")]
|
||||
#[test_case(ReviewCase::V3RoutingFailure; "v3_denies_when_pending_routing_fails")]
|
||||
#[test_case(ReviewCase::Native; "native_without_v3")]
|
||||
#[test_case(ReviewCase::EphemeralV3; "ephemeral_uses_native_with_v3")]
|
||||
#[test_case(ReviewCase::V3, None; "v3_follows_subscribed_revocation_and_reapproval")]
|
||||
#[test_case(ReviewCase::V3, Some(true); "v3_reports_high_probe_without_changing_verdicts")]
|
||||
#[test_case(ReviewCase::V3, Some(false); "v3_reports_low_probe_without_changing_verdicts")]
|
||||
#[test_case(ReviewCase::V3WithReconsideration, None; "v3_resamples_a_terminal_denial_once")]
|
||||
#[test_case(ReviewCase::V3RoutingFailure, None; "v3_denies_when_pending_routing_fails")]
|
||||
#[test_case(ReviewCase::Native, None; "native_without_v3")]
|
||||
#[test_case(ReviewCase::EphemeralV3, None; "ephemeral_uses_native_with_v3")]
|
||||
#[tokio::test]
|
||||
async fn pending_mcp_action_uses_the_configured_reviewer(case: ReviewCase) -> Result<()> {
|
||||
async fn pending_mcp_action_uses_the_configured_reviewer(
|
||||
case: ReviewCase,
|
||||
probe: Option<bool>,
|
||||
) -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
let reconsider = matches!(case, ReviewCase::V3WithReconsideration);
|
||||
let uses_board = matches!(
|
||||
@@ -138,15 +143,22 @@ async fn pending_mcp_action_uses_the_configured_reviewer(case: ReviewCase) -> Re
|
||||
response
|
||||
};
|
||||
} else if let Some(call_id) = actor_call.lock().expect("next actor call").take() {
|
||||
responses::sse(vec![
|
||||
responses::ev_function_call_with_namespace(
|
||||
let mut call = responses::ev_function_call_with_namespace(
|
||||
call_id,
|
||||
"mcp__codex_apps__browser",
|
||||
"_js",
|
||||
r#"{"code":"release-action"}"#,
|
||||
),
|
||||
responses::ev_completed(call_id),
|
||||
])
|
||||
);
|
||||
call["item"]["id"] = json!(call_id);
|
||||
let mut events = vec![responses::ev_response_created(call_id)];
|
||||
if let Some(requires_review) = probe {
|
||||
events.push(json!({
|
||||
"type": "response.metadata", "response_id": call_id,
|
||||
"metadata": {"guardian": {"item_id": call_id, "requires_review": requires_review}},
|
||||
}));
|
||||
}
|
||||
events.extend([call, responses::ev_completed(call_id)]);
|
||||
responses::sse(events)
|
||||
} else {
|
||||
responses::sse(vec![
|
||||
responses::ev_assistant_message("actor", "Done."),
|
||||
@@ -282,6 +294,13 @@ async fn pending_mcp_action_uses_the_configured_reviewer(case: ReviewCase) -> Re
|
||||
|event| {
|
||||
let fields = &event["fields"];
|
||||
fields["message"] == "Guardian V3 review preparation started"
|
||||
&& fields["tool_call_id"] == call_id
|
||||
&& fields["probe_review"]
|
||||
== match probe {
|
||||
Some(true) => "required",
|
||||
Some(false) => "not_required",
|
||||
None => "not_reported",
|
||||
}
|
||||
&& fields["review_id"]
|
||||
.as_str()
|
||||
.is_some_and(|id| Some(id) != previous_review_id.as_deref())
|
||||
|
||||
@@ -99,6 +99,8 @@ pub(crate) use codex_guardian_reviewer::GUARDIAN_MAX_NODE_REPL_TOOL_RESULT_TOKEN
|
||||
pub(crate) struct GuardianReviewContext {
|
||||
pub(crate) request_country: RequestCountry,
|
||||
pub(crate) serving_assessment: Option<Arc<ServingAssessment>>,
|
||||
/// Observational serving probe; never an approval decision.
|
||||
pub(crate) guardian_probe: Option<bool>,
|
||||
/// The latest response ID and its connection affinity when review was requested.
|
||||
pub(crate) parent_response: Option<Arc<ParentResponse>>,
|
||||
/// A host-verified, still-running tool invocation that requested this nested review.
|
||||
@@ -147,6 +149,7 @@ impl GuardianReviewContext {
|
||||
Self {
|
||||
request_country: settings.request_country().clone(),
|
||||
serving_assessment: None,
|
||||
guardian_probe: None,
|
||||
review_execution: None,
|
||||
enclosing_invocation_id: None,
|
||||
parent_response: turn.extension_data.get::<ParentResponse>(),
|
||||
@@ -176,6 +179,7 @@ impl From<&Arc<StepContext>> for GuardianReviewContext {
|
||||
Self {
|
||||
request_country: step.settings.request_country().clone(),
|
||||
serving_assessment: step.serving_assessment.clone(),
|
||||
guardian_probe: step.guardian_probe,
|
||||
review_execution: None,
|
||||
enclosing_invocation_id: None,
|
||||
parent_response: step.turn.extension_data.get::<ParentResponse>(),
|
||||
@@ -197,6 +201,7 @@ impl From<Arc<TurnContext>> for GuardianReviewContext {
|
||||
Self {
|
||||
request_country: turn.initial_settings.request_country().clone(),
|
||||
serving_assessment: None,
|
||||
guardian_probe: None,
|
||||
review_execution: None,
|
||||
enclosing_invocation_id: None,
|
||||
parent_response: turn.extension_data.get::<ParentResponse>(),
|
||||
|
||||
@@ -218,7 +218,16 @@ impl ReviewHost for super::super::runtime::ReviewRuntime {
|
||||
};
|
||||
drop(history);
|
||||
let started = Instant::now();
|
||||
tracing::info!(%review_id, "Guardian V3 review preparation started");
|
||||
tracing::info!(
|
||||
%review_id,
|
||||
tool_call_id = self.request.tool_call_id.as_deref(),
|
||||
probe_review = match context.guardian_probe {
|
||||
Some(true) => "required",
|
||||
Some(false) => "not_required",
|
||||
None => "not_reported",
|
||||
},
|
||||
"Guardian V3 review preparation started"
|
||||
);
|
||||
let result = AttachedApproval::prepare(
|
||||
provider,
|
||||
authorization,
|
||||
|
||||
Reference in New Issue
Block a user