mirror of
https://github.com/openai/codex.git
synced 2026-11-17 22:10:37 +00:00
Distinguish image and tool audio attachment uploads (#62047)
## What changed Introduce `UploadContent::Image` and `UploadContent::ToolAudio` in `UploadRequest`. Keep image filenames and policy tags on the image variant, and carry tool audio's declared MIME type explicitly instead of encoding its type and MIME metadata in tags. Update image preparation, image generation, and tool audio callers to use the typed content. Preserve inline bytes for both variants and redact their payloads from debug output. Document that persistent backends must verify the declared audio MIME type against the uploaded bytes. ## Testing Add coverage for inline tool audio byte preservation and audio debug redaction. Update integration assertions for typed image and audio uploads, and verify that Code Mode does not upload audio when `FileBackedToolAudio` is disabled. GitOrigin-RevId: 7dbd69922b377aead2dc28d1e5b3938cce6343b7
This commit is contained in:
@@ -10,6 +10,7 @@ use crate::original_image_detail::can_request_original_image_detail;
|
||||
use codex_analytics::ImageDetailSetting;
|
||||
use codex_analytics::ImagePreparationMetadata;
|
||||
use codex_attachment_store::AttachmentStore;
|
||||
use codex_attachment_store::UploadContent;
|
||||
use codex_attachment_store::UploadRequest;
|
||||
use codex_attachment_store::UploadResult;
|
||||
use codex_context_fragments::AnnotatedContent;
|
||||
@@ -449,9 +450,11 @@ async fn prepare_image(
|
||||
let request = UploadRequest {
|
||||
thread_id: origin.thread_id.to_owned(),
|
||||
ephemeral: origin.ephemeral,
|
||||
file_name: None,
|
||||
tags: HashMap::new(),
|
||||
data: prepared.encoded.bytes.to_vec(),
|
||||
content: UploadContent::Image {
|
||||
file_name: None,
|
||||
tags: HashMap::new(),
|
||||
data: prepared.encoded.bytes.to_vec(),
|
||||
},
|
||||
};
|
||||
let prepared_image = match preparation.image_store.upload(request).await {
|
||||
Ok(UploadResult::Inline { bytes }) => ImageReference::Inline {
|
||||
|
||||
@@ -11,6 +11,7 @@ use std::time::Duration;
|
||||
use codex_attachment_store::AttachmentStore;
|
||||
use codex_attachment_store::FormatSpecificMetadata;
|
||||
use codex_attachment_store::ResolveRequest;
|
||||
use codex_attachment_store::UploadContent;
|
||||
use codex_attachment_store::UploadRequest;
|
||||
use codex_attachment_store::UploadResult;
|
||||
use codex_history::ResponseItemEnvelope;
|
||||
@@ -184,18 +185,14 @@ async fn store_tool_audio(
|
||||
};
|
||||
}
|
||||
};
|
||||
// These tags come from Core. MCP servers and Code Mode never supply attachment IDs or policy tags.
|
||||
let tags = HashMap::from([
|
||||
("usage".to_string(), "tool_audio".to_string()),
|
||||
("mime_type".to_string(), mime.to_string()),
|
||||
]);
|
||||
let result = store
|
||||
.upload(UploadRequest {
|
||||
thread_id: thread_id.to_owned(),
|
||||
ephemeral,
|
||||
file_name: None,
|
||||
tags,
|
||||
data,
|
||||
content: UploadContent::ToolAudio {
|
||||
declared_mime_type: mime.to_owned(),
|
||||
data,
|
||||
},
|
||||
})
|
||||
.await;
|
||||
tool_audio_after_upload(result, mime, inline_url)
|
||||
|
||||
Reference in New Issue
Block a user