Capture local attachments before queuing turn input (#61962)

## Why

Queued input can outlive its local attachment files. Reading those files only when rendering a model message can lose media submitted while turn admission is pending.

## What changed

- Introduce `ResolvedUserInput` to carry captured image bytes, audio data URLs, or read errors through session queues and agent input.
- Resolve client attachments on the submitting host before queuing, using a blocking task for local file reads.
- Render messages from captured payloads while preserving original paths and text spans for display, along with image position mappings.

## Testing

Add coverage for rendering and serialization after source files are removed, steered audio retained during pending admission, and local audio errors and display content.

GitOrigin-RevId: 4bbb6bda44167439a8cfdae15d3c476a7b1d336b
This commit is contained in:
Adam Perry @ OpenAI
2026-11-17 04:08:00 +00:00
committed by copyberry
parent 65a4450886
commit d8d840d32a
50 changed files with 1060 additions and 573 deletions
-11
View File
@@ -64,8 +64,6 @@ use crate::request_user_input::RequestUserInputResponse;
use crate::response_item_id::OptionalWireItemId;
use crate::turn_input::CyberAccessProgram;
use crate::turn_input::SuspendTurnOutcome;
use crate::turn_input::TurnInputMode;
use crate::turn_input::TurnInputRequest;
use crate::turn_input::TurnInputSubmission;
use crate::turn_input::TurnStartOptions;
use codex_extension_items::image_generation::GeneratedImageRef;
@@ -786,14 +784,6 @@ pub enum Op {
/// Request the list of voices supported by realtime conversation streams.
RealtimeConversationListVoices,
/// Submit turn input using the requested routing behavior.
#[debug("TurnInput {{ requested_settings: {:?} }}", request.thread_settings)]
TurnInput {
request: Box<TurnInputRequest>,
mode: TurnInputMode,
reply: oneshot::Sender<CodexResult<TurnInputSubmission>>,
},
/// Resume an interrupted regular turn.
#[debug("RecoverTurn {{ requested_settings: {thread_settings:?} }}")]
RecoverTurn {
@@ -1149,7 +1139,6 @@ impl Op {
Self::RealtimeConversationClose => "realtime_conversation_close",
Self::RealtimeConversationDetach { .. } => "realtime_conversation_detach",
Self::RealtimeConversationListVoices => "realtime_conversation_list_voices",
Self::TurnInput { .. } => "turn_input",
Self::RecoverTurn { .. } => "recover_turn",
Self::SuspendTurnAndShutdown { .. } => "suspend_turn_and_shutdown",
Self::ThreadSettings { .. } => "thread_settings",
+7 -7
View File
@@ -27,9 +27,9 @@ pub enum SuspendTurnOutcome {
/// Input consumed by a regular turn.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum TurnInput {
pub enum TurnInput<I = UserInput> {
UserInput {
content: Vec<UserInput>,
content: Vec<I>,
client_id: Option<String>,
},
ResponseItem(ResponseItem),
@@ -107,8 +107,8 @@ impl From<ResponseItem> for InjectedResponseItem {
/// Callers choose start-or-steer, idle-start, or steer-only behavior through
/// the corresponding `CodexThread` method.
#[derive(Clone, Debug)]
pub struct TurnInputRequest {
pub input: TurnInput,
pub struct TurnInputRequest<I = UserInput> {
pub input: TurnInput<I>,
/// Optional host-assigned UUID for the Responses message created from [`TurnInput::UserInput`].
/// Ignored for all other inputs, including raw user-role Responses items.
pub user_item_uuid: Option<uuid::Uuid>,
@@ -169,9 +169,9 @@ pub struct RecoverTurnRequest {
pub cyber_access_program: Option<CyberAccessProgram>,
}
impl TurnInputRequest {
impl<I> TurnInputRequest<I> {
/// Creates turn input that can be passed to one of the submission methods.
pub fn new(input: TurnInput) -> Self {
pub fn new(input: TurnInput<I>) -> Self {
Self {
input,
user_item_uuid: None,
@@ -185,7 +185,7 @@ impl TurnInputRequest {
}
/// Creates ordinary user input without a client-provided message id.
pub fn user_input(content: Vec<UserInput>) -> Self {
pub fn user_input(content: Vec<I>) -> Self {
Self::new(TurnInput::UserInput {
content,
client_id: None,