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
+4 -7
View File
@@ -10,7 +10,7 @@ use crate::state::TaskKind;
use codex_features::Feature;
use codex_model_provider::RemoteCompactionSupport;
use codex_protocol::protocol::CodexErrorInfo;
use codex_protocol::user_input::UserInput;
use codex_user_input::ResolvedUserInput;
use tokio_util::sync::CancellationToken;
#[derive(Clone, Copy, Default)]
@@ -82,16 +82,13 @@ impl SessionTask for CompactTask {
"local",
/*manual*/ true,
);
let input = vec![UserInput::Text {
text: ctx
.config
let input = vec![ResolvedUserInput::text(
ctx.config
.compact_prompt
.as_deref()
.unwrap_or(crate::compact::SUMMARIZATION_PROMPT)
.to_string(),
// Compaction prompt is synthesized; no UI element ranges to preserve.
text_elements: Vec::new(),
}];
)];
crate::compact::run_compact_task(session.clone(), step_context, world_state, input)
.await
}
+4 -1
View File
@@ -95,7 +95,10 @@ async fn task_finish_rejects_uploaded_audio_without_losing_other_pending_input()
file_id: "file_disabled_at_finish".to_string(),
},
},
],
]
.into_iter()
.map(codex_user_input::ResolvedUserInput::from_client)
.collect(),
client_id: None,
metadata: Default::default(),
}],
+2 -2
View File
@@ -26,8 +26,8 @@ use crate::session::session::Session;
use crate::session::turn_context::TurnContext;
use crate::state::TaskKind;
use codex_features::Feature;
use codex_protocol::user_input::UserInput;
use codex_thread_store::PersistContext;
use codex_user_input::ResolvedUserInput;
use super::SessionTask;
use super::SessionTaskResult;
@@ -98,7 +98,7 @@ impl SessionTask for ReviewTask {
async fn start_review_conversation(
session: Arc<Session>,
ctx: Arc<TurnContext>,
input: Vec<UserInput>,
input: Vec<ResolvedUserInput>,
cancellation_token: CancellationToken,
) -> Option<async_channel::Receiver<Event>> {
let config = ctx.config.clone();