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
This commit is contained in:
Hung
2026-10-30 20:53:25 +00:00
committed by copyberry
parent b9858217d8
commit 2546265e3e
83 changed files with 2122 additions and 300 deletions
@@ -555,6 +555,28 @@ def test_generated_inline_image_class_names_remain_stable() -> None:
)
def test_generated_audio_inputs_preserve_inline_and_file_shapes() -> None:
"""Existing audio imports still work, and file references round-trip through the unions."""
from openai_codex.generated.v2_all import (
AudioUserInput,
ContentItem,
FileIdUserInput1,
InputAudioContentItem,
UserInput,
)
audio_url = "data:audio/wav;base64,YXVkaW8="
for model, wire in [
(AudioUserInput, {"type": "audio", "url": audio_url}),
(InputAudioContentItem, {"type": "input_audio", "audio_url": audio_url}),
(UserInput, {"type": "audio", "fileId": "file_audio"}),
(FileIdUserInput1, {"type": "audio", "fileId": "file_audio"}),
(ContentItem, {"type": "input_audio", "file_id": "file_audio"}),
]:
audio = model.model_validate(wire)
assert audio.model_dump(by_alias=True, exclude_unset=True, mode="json") == wire
def test_generated_image_generation_thread_item_alias_remains_available() -> None:
"""Existing SDK callers can still construct and validate inline image-generation items."""
from openai_codex.generated.v2_all import (