Files
codex/codex-rs/tools/src/tool_output_tests.rs
T
Hung 2546265e3e Add audio file references with explicit runtime rejection (#58430)
## What changed

- Allow audio inputs to carry uploaded file references via `fileId` in the app-server API and `file_id` in model content, preserving existing inline audio shapes and Python class names.
- Preserve mixed inline and file-backed audio ordering through history reconstruction and migration, and budget file-backed audio conservatively when duration is unknown.
- Keep uploaded audio disabled at runtime: reject it before inference or raw history injection, preserve accompanying text, and prevent rejected attachments from reaching follow-up or resumed requests.

## Testing

Add coverage for wire-format round trips, SDK compatibility, mixed audio history ordering, and rejection during turn start, steering, task completion, and raw injection.

GitOrigin-RevId: 70895c47a2494c0c9936348ad1250eb1b7b892a6
2026-10-30 20:53:25 +00:00

55 lines
1.8 KiB
Rust

use codex_protocol::models::AudioReference;
use codex_protocol::models::ContentItem;
use codex_protocol::models::ImageReference;
use codex_protocol::models::ResponseInputItem;
use pretty_assertions::assert_eq;
use super::response_input_to_code_mode_result;
#[test]
fn code_mode_text_preserves_message_content() {
let response = ResponseInputItem::Message {
role: "user".to_string(),
content: vec![
ContentItem::InputText {
text: "Input text".to_string(),
},
ContentItem::OutputText {
text: "Output text".to_string(),
annotations: Some(vec![serde_json::json!({"type": "citation"})]),
logprobs: Some(vec![serde_json::json!({"token": "Output"})]),
},
ContentItem::InputImage {
image: ImageReference::File {
file_id: "file_123".to_string(),
},
detail: None,
},
ContentItem::InputImage {
image: ImageReference::Inline {
image_url: "data:image/png;base64,abc".to_string(),
},
detail: None,
},
ContentItem::InputAudio {
audio: AudioReference::Inline {
audio_url: "data:audio/wav;base64,def".to_string(),
},
},
ContentItem::InputAudio {
audio: AudioReference::File {
file_id: "file_audio".to_string(),
},
},
],
phase: None,
};
assert_eq!(
response_input_to_code_mode_result(response),
serde_json::json!(
"Input text\nOutput text\nfile_123\ndata:image/png;base64,abc\ndata:audio/wav;base64,def\nfile_audio"
)
);
}