mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +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:
1 parent
66dfadbe66
commit
fd346b8dba
5 files changed
+61
-22
No files matched your search
@@ -140,14 +140,7 @@ async fn cached_evidence(
|
||||
return Err(GuardianReviewReason::MissingScore);
|
||||
};
|
||||
// Elicitations and intercepted execs can expand beyond the original scored action.
|
||||
let mut action = input.action.clone();
|
||||
if action.get("tool").and_then(serde_json::Value::as_str) == Some("mcp_tool_call")
|
||||
&& let Some(fields) = action.as_object_mut()
|
||||
{
|
||||
// Match the action renderer: host descriptions are optional, arguments are not.
|
||||
fields.remove("tool_description");
|
||||
fields.remove("connector_description");
|
||||
}
|
||||
let action = codex_guardian_context::action_for_review(input.action.clone());
|
||||
let max_action_bytes = TruncationPolicy::Tokens(config.max_action_tokens).byte_budget();
|
||||
let action_fits = serde_json::to_string_pretty(&action)
|
||||
.is_ok_and(|action| action.len().saturating_add(1) <= max_action_bytes);
|
||||
|
||||
Reference in new issue
Block a user