mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
[codex] replace remote images with model-visible error text (#29417)
## What This PR will extend the existing centralized image-preparation path to replace HTTP(S) image inputs with a model visible error message. It won't "ruin" and break existing rollouts, but it will deprecate support for the pathway. App server clients should no longer use HTTP image urls if they'd like to upgrade. The HTTP image url pathway is currently resolved in the responsesapi. It is slow and not reccomended. ## Behavior - HTTP(S) image URL: replace with `input_text` - data URL: use the existing decode and resize path - other image URL schemes: leave unchanged This intentionally does not change app-server ingress. That validation remains a follow-up. ## Test plan - `just test -p codex-core -E 'test(/image_preparation|prepares_image_failures_before_history_insertion|prepares_resumed_history_before_installing_it|responses_lite_prepares_images/)'` — 7 passed - `just fix -p codex-core` - `just fmt`
This commit is contained in:
1 parent
f1945de3b7
commit
7153affa0f
5 files changed
+69
-31
No files matched your search
@@ -32,9 +32,8 @@ fn decoded_image(image_url: &str) -> (Vec<u8>, DynamicImage) {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn preparation_preserves_small_image_bytes_and_non_data_urls() {
|
||||
fn preparation_preserves_small_image_bytes_and_replaces_remote_urls() {
|
||||
let (data_url, original_bytes) = png_data_url(/*width*/ 64, /*height*/ 32);
|
||||
let http_url = "https://example.com/image.png".to_string();
|
||||
let mut items = vec![ResponseItem::Message {
|
||||
id: None,
|
||||
role: "user".to_string(),
|
||||
@@ -44,7 +43,7 @@ fn preparation_preserves_small_image_bytes_and_non_data_urls() {
|
||||
detail: Some(ImageDetail::High),
|
||||
},
|
||||
ContentItem::InputImage {
|
||||
image_url: http_url.clone(),
|
||||
image_url: "https://example.com/image.png".to_string(),
|
||||
detail: Some(ImageDetail::Low),
|
||||
},
|
||||
],
|
||||
@@ -59,16 +58,13 @@ fn preparation_preserves_small_image_bytes_and_non_data_urls() {
|
||||
};
|
||||
let [
|
||||
ContentItem::InputImage { image_url, .. },
|
||||
ContentItem::InputImage {
|
||||
image_url: preserved_http_url,
|
||||
detail: Some(ImageDetail::Low),
|
||||
},
|
||||
ContentItem::InputText { text },
|
||||
] = content.as_slice()
|
||||
else {
|
||||
panic!("expected two images");
|
||||
};
|
||||
assert_eq!(decoded_image(image_url).0, original_bytes);
|
||||
assert_eq!(preserved_http_url, &http_url);
|
||||
assert_eq!(text, REMOTE_IMAGE_URL_PLACEHOLDER);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -173,6 +169,10 @@ fn preparation_replaces_only_failed_tool_images_and_preserves_metadata() {
|
||||
#[test]
|
||||
fn preparation_errors_use_bounded_actionable_placeholders() {
|
||||
let cases = [
|
||||
(
|
||||
ImagePreparationError::RemoteUrlUnsupported,
|
||||
REMOTE_IMAGE_URL_PLACEHOLDER,
|
||||
),
|
||||
(
|
||||
ImagePreparationError::UnsupportedLowDetail,
|
||||
UNSUPPORTED_LOW_DETAIL_PLACEHOLDER,
|
||||
|
||||
Reference in new issue
Block a user