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
+10 -1
View File
@@ -9,6 +9,7 @@ use crate::session::SessionIo;
use crate::session::SessionSettingsUpdate;
use crate::session::Submission;
use crate::session::emit_subagent_session_started;
use crate::session::inject::validate_injected_response_item;
use crate::session::new_submission_id;
use crate::session::session::AppServerClientMetadata;
use crate::session::session::Session;
@@ -673,11 +674,18 @@ impl CodexThread {
///
/// This is the thread-level bridge to `Session::inject_if_running` for
/// callers that only hold a `CodexThread`.
/// It returns the unchanged items when this thread has no active turn.
/// Returns the unchanged batch when there is no active turn or an item requires typed turn input.
pub async fn inject_if_running(
&self,
items: Vec<ResponseItem>,
) -> Result<(), Vec<ResponseItem>> {
if items
.iter()
.try_for_each(validate_injected_response_item)
.is_err()
{
return Err(items);
}
self.session.inject_if_running(items).await
}
@@ -952,6 +960,7 @@ impl CodexThread {
"items must not be empty".to_string(),
));
}
items.iter().try_for_each(validate_injected_response_item)?;
let had_reference_context = self.session.reference_context_item().await.is_some();
let mut turn_context = if had_reference_context {