Refactor image content to use a shared ImageReference type (#45543)

## What changed

Represent images in `ContentItem` and `FunctionCallOutputContentItem` with `ImageReference::Inline`, flattened to preserve the existing `image_url` wire format. Update image producers and consumers and regenerate app-server schemas and SDK artifacts.

Preserve the Python SDK's `InputImageContentItem` and `InputImageFunctionCallOutputContentItem` class names during generation.

## Testing

Add a regression test for stable Python image class names and adapt existing image tests to the shared representation.

GitOrigin-RevId: c38a780ac3314c2ac2deb3afc1b93b94b6f93fec
This commit is contained in:
Krish Chainani authored and copyberry committed 2026-09-14 23:25:09 +00:00
1 parent 6ae5e71458
commit 5a66d460d3
79 files changed
+994 -312

No files matched your search

+9 -2
View File
@@ -7,6 +7,7 @@ use std::collections::HashSet;
use codex_protocol::models::ContentItem;
use codex_protocol::models::ImageDetail;
use codex_protocol::models::ImageReference;
use codex_protocol::protocol::TruncationPolicy;
use crate::ComposedContext;
@@ -90,7 +91,10 @@ impl ComposedContext {
pub fn retain_images(&mut self, mut admit: impl FnMut(&str, &mut Option<ImageDetail>) -> bool) {
for section in &mut self.sections {
retain_content(section, &mut self.truncations, |_, item| match item {
ContentItem::InputImage { image_url, detail } => admit(image_url, detail),
ContentItem::InputImage {
image: ImageReference::Inline { image_url },
detail,
} => admit(image_url, detail),
_ => true,
});
}
@@ -273,7 +277,10 @@ fn retain_content(
if !keep {
let original_bytes = match &item.content {
ContentItem::InputText { text } | ContentItem::OutputText { text } => text.len(),
ContentItem::InputImage { image_url, .. } => image_url.len(),
ContentItem::InputImage {
image: ImageReference::Inline { image_url },
..
} => image_url.len(),
ContentItem::InputAudio { audio_url } => audio_url.len(),
};
truncations.push(TruncationObservation {