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 -4
View File
@@ -31,7 +31,6 @@ use codex_otel::HOOK_RUN_DURATION_METRIC;
use codex_otel::HOOK_RUN_METRIC;
use codex_protocol::items::FunctionCallOutputItem;
use codex_protocol::items::TurnItem;
use codex_protocol::items::UserMessageItem;
use codex_protocol::models::ContentItem;
use codex_protocol::models::ResponseItem;
use codex_protocol::openai_models::ModelInfo;
@@ -54,6 +53,7 @@ use codex_protocol::protocol::WarningEvent;
use codex_rollout::state_db;
use codex_thread_store::PersistContext;
use codex_thread_store::ReadThreadParams;
use codex_user_input::ResolvedUserInput;
use codex_utils_absolute_path::AbsolutePathBuf;
use serde_json::Map;
use serde_json::Value;
@@ -722,7 +722,10 @@ pub(crate) async fn inspect_pending_input(
transcript_path: sess.hook_transcript_path().await,
model: turn_context.model_info().slug.clone(),
permission_mode: hook_permission_mode(turn_context.approval_policy()),
prompt: UserMessageItem::new(content).message(),
prompt: content
.iter()
.filter_map(ResolvedUserInput::as_text)
.collect(),
};
let hooks = with_environment_hooks(
sess,
@@ -763,8 +766,6 @@ pub(crate) async fn record_pending_input(
client_id,
metadata,
} => {
// Prompt telemetry can contain full text. Emit it only for prompts selected for recording.
turn_context.session_telemetry.user_prompt(&content);
sess.record_user_prompt_and_emit_turn_item(
turn_context.as_ref(),
model_info,