mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +00:00
Centralize Guardian action preparation for review (#45987)
## What changed Move duplicated action preparation into `codex_guardian_context::action_for_review`, shared by approval rendering and cached-evidence size checks. Preserve the existing behavior: omit top-level `tool_description` and `connector_description` metadata from MCP tool calls while keeping tool arguments intact. ## Testing Add unit tests verifying that MCP arguments retain description fields, including nested fields, and that other action types remain unchanged. GitOrigin-RevId: 8e890fb263556596f695177f917750377c04d43c
This commit is contained in:
@@ -537,20 +537,8 @@ pub(crate) fn guardian_request_turn_id<'a>(
|
||||
pub(crate) fn format_guardian_action_pretty(
|
||||
action: &GuardianApprovalRequest,
|
||||
) -> serde_json::Result<String> {
|
||||
let mut value = guardian_action_for_review(action)?;
|
||||
let mut value =
|
||||
codex_guardian_context::action_for_review(guardian_approval_request_to_json(action)?);
|
||||
value.sort_all_objects();
|
||||
serde_json::to_string_pretty(&value)
|
||||
}
|
||||
|
||||
fn guardian_action_for_review(action: &GuardianApprovalRequest) -> serde_json::Result<Value> {
|
||||
let mut value = guardian_approval_request_to_json(action)?;
|
||||
if matches!(action, GuardianApprovalRequest::McpToolCall { .. })
|
||||
&& let Some(fields) = value.as_object_mut()
|
||||
{
|
||||
// Only host-provided metadata is optional. A nested argument named
|
||||
// "description" is still part of the exact action under review.
|
||||
fields.remove("tool_description");
|
||||
fields.remove("connector_description");
|
||||
}
|
||||
Ok(value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user