mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Trim Guardian tests and tighten request layout assertions (#46063)
## What changed Remove standalone tests across Guardian review sessions, configuration, assessment schemas, transcripts, and trusted skill paths. Strengthen the existing request layout snapshot test to check exact transcript separators, the action header, and parent session ID placement before snapshot whitespace normalization. Concatenate user input text without inserting newlines so the assertions validate the actual request formatting. GitOrigin-RevId: 06d262a1a85b1a8401796958f300c894146d2e1b
This commit is contained in:
1 parent
8ace915ace
commit
e412b93d08
5 files changed
+5
-370
No files matched your search
@@ -50,34 +50,3 @@ fn parse_guardian_assessment_treats_bare_deny_as_high_risk() {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn guardian_output_schema_requires_only_outcome_and_allows_optional_details() {
|
||||
let schema = guardian_output_schema();
|
||||
|
||||
assert_eq!(
|
||||
schema,
|
||||
serde_json::json!({
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"risk_level": {
|
||||
"type": "string",
|
||||
"enum": ["low", "medium", "high", "critical"]
|
||||
},
|
||||
"user_authorization": {
|
||||
"type": "string",
|
||||
"enum": ["unknown", "low", "medium", "high"]
|
||||
},
|
||||
"outcome": {
|
||||
"type": "string",
|
||||
"enum": ["allow", "deny"]
|
||||
},
|
||||
"rationale": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["outcome"]
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -2,7 +2,6 @@ use super::ContextInput;
|
||||
use codex_extension_api::ConversationHistorySnapshot;
|
||||
use codex_extension_api::ResponseItem;
|
||||
use codex_guardian_context::ContextTarget;
|
||||
use codex_guardian_context::truncate_text as truncate_entry;
|
||||
use codex_protocol::AgentPath;
|
||||
use codex_protocol::models::AgentMessageInputContent;
|
||||
use codex_protocol::models::ContentItem;
|
||||
@@ -1029,84 +1028,6 @@ fn transcript_truncates_tool_results_using_standard_budget() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transcript_preserves_outputs_with_call_ids_or_explicit_names() {
|
||||
let mut items = vec![ResponseItem::FunctionCallOutput {
|
||||
id: None,
|
||||
call_id: None,
|
||||
name: Some("notifications".to_owned()),
|
||||
namespace: Some("slack".to_owned()),
|
||||
output: FunctionCallOutputPayload::from_text("new message".to_owned()),
|
||||
internal_chat_message_metadata_passthrough: None,
|
||||
}];
|
||||
items.extend(
|
||||
[
|
||||
(None, "anonymous output"),
|
||||
(Some("missing-call"), "orphaned function output"),
|
||||
]
|
||||
.map(|(call_id, text)| ResponseItem::FunctionCallOutput {
|
||||
id: None,
|
||||
call_id: call_id.map(str::to_string),
|
||||
name: None,
|
||||
namespace: None,
|
||||
output: FunctionCallOutputPayload::from_text(text.to_string()),
|
||||
internal_chat_message_metadata_passthrough: None,
|
||||
}),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
TranscriptConfig::default()
|
||||
.build_context(ContextInput {
|
||||
target: ContextTarget::Async,
|
||||
history: &TestConversationHistory(&items),
|
||||
root_conversation: &[],
|
||||
trusted_user_answers: &[],
|
||||
planned_action: None,
|
||||
previous_reviews: None,
|
||||
trusted_tool: None,
|
||||
trusted_skill_paths: &[],
|
||||
node_repl_images: None,
|
||||
})
|
||||
.expect("collect transcript")
|
||||
.transcript_entries(),
|
||||
vec![
|
||||
"[1] tool slack.notifications result: new message\n",
|
||||
"[2] tool result: orphaned function output\n",
|
||||
]
|
||||
);
|
||||
|
||||
if let ResponseItem::FunctionCallOutput { output, .. } = &mut items[0] {
|
||||
*output = FunctionCallOutputPayload::from_content_items(vec![
|
||||
FunctionCallOutputContentItem::InputImage {
|
||||
image: ImageReference::Inline {
|
||||
image_url: "data:image/png;base64,image".to_owned(),
|
||||
},
|
||||
detail: None,
|
||||
},
|
||||
]);
|
||||
}
|
||||
assert_eq!(
|
||||
TranscriptConfig::default()
|
||||
.build_context(ContextInput {
|
||||
target: ContextTarget::Async,
|
||||
history: &TestConversationHistory(&items),
|
||||
root_conversation: &[],
|
||||
trusted_user_answers: &[],
|
||||
planned_action: None,
|
||||
previous_reviews: None,
|
||||
trusted_tool: None,
|
||||
trusted_skill_paths: &[],
|
||||
node_repl_images: None,
|
||||
})
|
||||
.expect("collect transcript")
|
||||
.transcript_entries(),
|
||||
vec![
|
||||
"[1] tool slack.notifications result: [non-text output]\n",
|
||||
"[2] tool result: orphaned function output\n",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn configured_reasoning_counts_against_message_budget() {
|
||||
for (repeats, include_reasoning) in [(200, true), (1_000, false)] {
|
||||
@@ -1157,17 +1078,6 @@ fn configured_reasoning_counts_against_message_budget() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn truncate_entry_preserves_prefix_suffix_and_utf8_boundaries() {
|
||||
let text = format!("prefix é{}é suffix", "🦀".repeat(2_000));
|
||||
let truncated = truncate_entry(&text, /*max_tokens*/ 200);
|
||||
|
||||
assert!(truncated.starts_with("prefix é"));
|
||||
assert!(truncated.contains("<truncated omitted_approx_tokens=\""));
|
||||
assert!(truncated.ends_with("é suffix"));
|
||||
assert!(truncated.len() <= TruncationPolicy::Tokens(200).byte_budget());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transcript_keeps_only_manual_approval_developer_messages() {
|
||||
let approval_text = format!("{MANUAL_APPROVAL_DEVELOPER_PREFIX}\n\nApproved action:\n{{}}");
|
||||
|
||||
Reference in new issue
Block a user