mirror of
https://github.com/openai/codex.git
synced 2026-11-25 07:23:22 +00:00
Support image references by file ID in inputs and tool outputs (#45794)
## What changed - Accept `fileId` alongside the existing `url` form for app-server image inputs, and forward file references to the Responses API as `file_id`. Update generated schemas and client types. - Preserve file references, image detail hints, and mixed inline/file image ordering through user-message events, thread history, and rollout migration. Retain file images when truncating tool output. - Pass file references through image preparation without resolving them, while keeping resize-notice numbering correct. Omit them from unsupported TUI display and Guardian image context. - Reject image-edit requests whose recent-image window includes a file reference, preventing selection of an older inline image instead. ## Testing Add coverage for serialization, request and rollout preservation, mixed-image history ordering, incomplete ordering metadata, tool-output truncation, and rejection of unsupported image-edit selections. GitOrigin-RevId: 6ca20a8577155cc934b720803c3b7b3bffdf972a
This commit is contained in:
1 parent
c51cb968e4
commit
7b8b17b97a
95 files changed
+2434
-324
No files matched your search
@@ -9,6 +9,8 @@ use codex_protocol::config_types::ModeKind;
|
||||
use codex_protocol::config_types::Settings;
|
||||
use codex_protocol::items::AgentMessageContent;
|
||||
use codex_protocol::items::TurnItem;
|
||||
use codex_protocol::models::ImageDetail;
|
||||
use codex_protocol::models::ImageReference;
|
||||
use codex_protocol::models::PermissionProfile;
|
||||
use codex_protocol::models::WebSearchAction;
|
||||
use codex_protocol::protocol::AskForApproval;
|
||||
@@ -81,13 +83,21 @@ async fn user_message_item_is_emitted() -> anyhow::Result<()> {
|
||||
ByteRange { start: 0, end: 6 },
|
||||
Some("<file>".into()),
|
||||
)];
|
||||
let expected_input = UserInput::Text {
|
||||
text: "please inspect sample.txt".into(),
|
||||
text_elements: text_elements.clone(),
|
||||
};
|
||||
let expected_input = vec![
|
||||
UserInput::Text {
|
||||
text: "please inspect sample.txt".into(),
|
||||
text_elements: text_elements.clone(),
|
||||
},
|
||||
UserInput::Image {
|
||||
image: ImageReference::File {
|
||||
file_id: "file_123".into(),
|
||||
},
|
||||
detail: Some(ImageDetail::High),
|
||||
},
|
||||
];
|
||||
|
||||
codex
|
||||
.start_or_steer_turn(TurnInputRequest::user_input(vec![expected_input.clone()]))
|
||||
.start_or_steer_turn(TurnInputRequest::user_input(expected_input.clone()))
|
||||
.await?;
|
||||
|
||||
let started_item = wait_for_event_match(&codex, |ev| match ev {
|
||||
@@ -108,8 +118,8 @@ async fn user_message_item_is_emitted() -> anyhow::Result<()> {
|
||||
.await;
|
||||
|
||||
assert_eq!(started_item.id, completed_item.id);
|
||||
assert_eq!(started_item.content, vec![expected_input.clone()]);
|
||||
assert_eq!(completed_item.content, vec![expected_input]);
|
||||
assert_eq!(started_item.content, expected_input);
|
||||
assert_eq!(completed_item.content, started_item.content);
|
||||
|
||||
let legacy_message = wait_for_event_match(&codex, |ev| match ev {
|
||||
EventMsg::UserMessage(event) => Some(event.clone()),
|
||||
@@ -118,6 +128,12 @@ async fn user_message_item_is_emitted() -> anyhow::Result<()> {
|
||||
.await;
|
||||
assert_eq!(legacy_message.message, "please inspect sample.txt");
|
||||
assert_eq!(legacy_message.text_elements, text_elements);
|
||||
assert_eq!(legacy_message.file_ids, Some(vec!["file_123".into()]));
|
||||
assert_eq!(
|
||||
legacy_message.file_id_details,
|
||||
vec![Some(ImageDetail::High)]
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user