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
+5 -11
View File
@@ -8,7 +8,7 @@ use codex_history::ResponseItemEnvelope;
use codex_protocol::ThreadId;
use codex_protocol::models::ResponseItem;
use codex_protocol::turn_input::TurnStartOptions;
use codex_protocol::user_input::UserInput;
use codex_user_input::ResolvedUserInput;
use serde::Deserialize;
use serde::Serialize;
use std::collections::BTreeMap;
@@ -43,7 +43,7 @@ pub struct UserInputMetadata {
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum TurnInput {
UserInput {
content: Vec<UserInput>,
content: Vec<ResolvedUserInput>,
client_id: Option<String>,
#[serde(flatten)]
metadata: UserInputMetadata,
@@ -569,7 +569,7 @@ mod tests {
use codex_history::CodexHarnessMetadata;
use codex_protocol::AgentPath;
use codex_protocol::protocol::InterAgentCommunication;
use codex_protocol::user_input::UserInput;
use codex_user_input::ResolvedUserInput;
use pretty_assertions::assert_eq;
#[test]
@@ -697,10 +697,7 @@ mod tests {
&turn_state,
vec![TurnInput::UserInput {
metadata: Default::default(),
content: vec![UserInput::Text {
text: "steer".to_string(),
text_elements: Vec::new(),
}],
content: vec![ResolvedUserInput::text("steer".to_string())],
client_id: None,
}],
)
@@ -789,10 +786,7 @@ mod tests {
&turn_state,
vec![TurnInput::UserInput {
metadata: Default::default(),
content: vec![UserInput::Text {
text: "already pending".to_string(),
text_elements: Vec::new(),
}],
content: vec![ResolvedUserInput::text("already pending".to_string())],
client_id: None,
}],
)