Move Guardian image selection into shared context sections (#43601)

## What changed

Move bounded transcript image collection into `codex-guardian-context` and expose it through an optional `TranscriptImages` section. Update the async scorer to consume this section, preserving source filtering, image detail, omission accounting, and the existing limits of four images and 8 MiB of image URL data.

## Testing

Add coverage for source order, tool-output filtering, disabled image collection, oldest-image eviction, oversized images, and omitted-byte accounting.

GitOrigin-RevId: 097799ea1be6d73b347088f959de1fd23f02ec2c
This commit is contained in:
felixxia-oai authored and copyberry committed 2026-09-07 21:46:23 +00:00
1 parent f5331dc237
commit b4373e53ab
10 files changed
+316 -99

No files matched your search

+11
View File
@@ -239,6 +239,7 @@ pub(crate) async fn build_guardian_prompt_items_with_parent_turn(
push_text(headings.intro.to_string());
let mut action_items = Vec::new();
let mut permission_items = Vec::new();
let mut image_items = Vec::new();
for section in sections {
match section {
ContextSection::RootConversation { items }
@@ -253,6 +254,14 @@ pub(crate) async fn build_guardian_prompt_items_with_parent_turn(
| ContextSection::TrustedSkills(_) => {
unreachable!("trusted review and tool sections are async-only")
}
ContextSection::TranscriptImages(images) => {
image_items.extend(images.images.into_iter().filter_map(|image| match image {
codex_protocol::models::ContentItem::InputImage { image_url, detail } => {
Some(UserInput::Image { image_url, detail })
}
_ => None,
}));
}
ContextSection::ConversationTranscript { .. } => {}
ContextSection::PermissionContext { items } => permission_items = items,
ContextSection::PlannedAction(action) => {
@@ -276,6 +285,7 @@ pub(crate) async fn build_guardian_prompt_items_with_parent_turn(
for text in permission_items {
push_text(text);
}
items.extend(image_items);
let mut node_repl_evidence_sequence = reviewed_node_repl_evidence_sequence;
if node_repl_transcripts_enabled
&& let Some(fragment) = session
@@ -488,6 +498,7 @@ pub(super) fn collect_guardian_context(
previous_reviews: None,
trusted_tool: None,
trusted_skill_paths: &[],
images: None,
})
}