Include node_repl images in Guardian review evidence (#38454)

## What changed

- Preserve valid image content from completed `node_repl` Code Mode responses alongside text evidence for Guardian reviews.
- Enable multimodal evidence for models that require automatic `node_repl` review, or when both `guardian_enhanced_node_repl_transcripts` and `guardian_node_repl_transcript_images` are enabled.
- Bound retained and rendered evidence, deduplicate images already present in review history, and fall back to text-only evidence when the reviewer lacks image support or prompt capacity.
- Keep review evidence out of the parent turn input.

## Testing

- Cover feature gating, mixed text and image ordering, truncation and eviction, unsupported reviewers, prompt pressure, image detail normalization, and reused review sessions.

GitOrigin-RevId: a3e482402f7b3484401b231dadc662e6e3504fdf
This commit is contained in:
Ankush Gupta authored and copyberry committed 2026-08-13 23:29:52 +00:00
1 parent 1b4ea8b3be
commit 4d9f3021c8
14 files changed
+713 -87

No files matched your search

+29 -6
View File
@@ -102,7 +102,18 @@ pub fn load_for_prompt_bytes(
return Ok(image);
}
let image = (move || {
let image = load_for_prompt_bytes_uncached(&path_buf, file_bytes, mode)?;
cache_image(&IMAGE_CACHE, key, image.clone(), MAX_IMAGE_CACHE_BYTES);
Ok(image)
}
fn load_for_prompt_bytes_uncached(
path: &Path,
file_bytes: Vec<u8>,
mode: PromptImageMode,
) -> Result<EncodedImage, ImageProcessingError> {
let path_buf = path.to_path_buf();
(move || {
let guessed_format = image::guess_format(&file_bytes)
.map_err(|source| ImageProcessingError::decode_error(&path_buf, source))?;
let format = match guessed_format {
@@ -194,10 +205,7 @@ pub fn load_for_prompt_bytes(
};
Ok(encoded)
})()?;
cache_image(&IMAGE_CACHE, key, image.clone(), MAX_IMAGE_CACHE_BYTES);
Ok(image)
})()
}
fn cache_image(cache: &ImageCache, key: ImageCacheKey, image: EncodedImage, byte_capacity: usize) {
@@ -223,6 +231,21 @@ fn cache_image(cache: &ImageCache, key: ImageCacheKey, image: EncodedImage, byte
pub fn load_data_url_for_prompt(
image_url: &str,
mode: PromptImageMode,
) -> Result<EncodedImage, ImageProcessingError> {
load_data_url_for_prompt_with(image_url, mode, load_for_prompt_bytes)
}
pub fn load_data_url_for_prompt_uncached(
image_url: &str,
mode: PromptImageMode,
) -> Result<EncodedImage, ImageProcessingError> {
load_data_url_for_prompt_with(image_url, mode, load_for_prompt_bytes_uncached)
}
fn load_data_url_for_prompt_with(
image_url: &str,
mode: PromptImageMode,
load: impl FnOnce(&Path, Vec<u8>, PromptImageMode) -> Result<EncodedImage, ImageProcessingError>,
) -> Result<EncodedImage, ImageProcessingError> {
let rest = image_url
.get(..DATA_URL_PREFIX.len())
@@ -266,7 +289,7 @@ pub fn load_data_url_for_prompt(
});
}
load_for_prompt_bytes(Path::new("<data-url-image>"), file_bytes, mode)
load(Path::new("<data-url-image>"), file_bytes, mode)
}
fn prompt_image_output_dimensions_for_limits(