Skip to content

Commit 53b1570

Browse files
authored
Update image outputs to default to high detail (openai#18386)
Do not assume the default `detail`.
1 parent e3c2acb commit 53b1570

35 files changed

Lines changed: 245 additions & 93 deletions

codex-rs/app-server-protocol/schema/json/ClientRequest.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,16 @@
471471
},
472472
{
473473
"properties": {
474+
"detail": {
475+
"anyOf": [
476+
{
477+
"$ref": "#/definitions/ImageDetail"
478+
},
479+
{
480+
"type": "null"
481+
}
482+
]
483+
},
474484
"image_url": {
475485
"type": "string"
476486
},

codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7173,6 +7173,16 @@
71737173
},
71747174
{
71757175
"properties": {
7176+
"detail": {
7177+
"anyOf": [
7178+
{
7179+
"$ref": "#/definitions/v2/ImageDetail"
7180+
},
7181+
{
7182+
"type": "null"
7183+
}
7184+
]
7185+
},
71767186
"image_url": {
71777187
"type": "string"
71787188
},

codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3750,6 +3750,16 @@
37503750
},
37513751
{
37523752
"properties": {
3753+
"detail": {
3754+
"anyOf": [
3755+
{
3756+
"$ref": "#/definitions/ImageDetail"
3757+
},
3758+
{
3759+
"type": "null"
3760+
}
3761+
]
3762+
},
37533763
"image_url": {
37543764
"type": "string"
37553765
},

codex-rs/app-server-protocol/schema/json/v2/RawResponseItemCompletedNotification.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@
2525
},
2626
{
2727
"properties": {
28+
"detail": {
29+
"anyOf": [
30+
{
31+
"$ref": "#/definitions/ImageDetail"
32+
},
33+
{
34+
"type": "null"
35+
}
36+
]
37+
},
2838
"image_url": {
2939
"type": "string"
3040
},

codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@
8383
},
8484
{
8585
"properties": {
86+
"detail": {
87+
"anyOf": [
88+
{
89+
"$ref": "#/definitions/ImageDetail"
90+
},
91+
{
92+
"type": "null"
93+
}
94+
]
95+
},
8696
"image_url": {
8797
"type": "string"
8898
},
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// GENERATED CODE! DO NOT MODIFY BY HAND!
22

33
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
4+
import type { ImageDetail } from "./ImageDetail";
45

5-
export type ContentItem = { "type": "input_text", text: string, } | { "type": "input_image", image_url: string, } | { "type": "output_text", text: string, };
6+
export type ContentItem = { "type": "input_text", text: string, } | { "type": "input_image", image_url: string, detail?: ImageDetail, } | { "type": "output_text", text: string, };

codex-rs/app-server/tests/suite/v2/dynamic_tools.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use codex_app_server_protocol::ThreadStartResponse;
2121
use codex_app_server_protocol::TurnStartParams;
2222
use codex_app_server_protocol::TurnStartResponse;
2323
use codex_app_server_protocol::UserInput as V2UserInput;
24+
use codex_protocol::models::DEFAULT_IMAGE_DETAIL;
2425
use codex_protocol::models::FunctionCallOutputBody;
2526
use codex_protocol::models::FunctionCallOutputContentItem;
2627
use codex_protocol::models::FunctionCallOutputPayload;
@@ -477,7 +478,7 @@ async fn dynamic_tool_call_round_trip_sends_content_items_to_model() -> Result<(
477478
DynamicToolCallOutputContentItem::InputImage { image_url } => {
478479
FunctionCallOutputContentItem::InputImage {
479480
image_url,
480-
detail: None,
481+
detail: Some(DEFAULT_IMAGE_DETAIL),
481482
}
482483
}
483484
})
@@ -535,7 +536,8 @@ async fn dynamic_tool_call_round_trip_sends_content_items_to_model() -> Result<(
535536
},
536537
{
537538
"type": "input_image",
538-
"image_url": "data:image/png;base64,AAA"
539+
"image_url": "data:image/png;base64,AAA",
540+
"detail": "high"
539541
}
540542
])
541543
);

codex-rs/code-mode/src/description.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const EXEC_DESCRIPTION_TEMPLATE: &str = r#"Run JavaScript code to orchestrate/co
2626
- Global helpers:
2727
- `exit()`: Immediately ends the current script successfully (like an early return from the top level).
2828
- `text(value: string | number | boolean | undefined | null)`: Appends a text item. Non-string values are stringified with `JSON.stringify(...)` when possible.
29-
- `image(imageUrlOrItem: string | { image_url: string; detail?: "auto" | "low" | "high" | "original" | null } | ImageContent, detail?: "auto" | "low" | "high" | "original" | null)`: Appends an image item. `image_url` can be an HTTPS URL or a base64-encoded `data:` URL. To forward an MCP tool image, pass an individual `ImageContent` block from `result.content`, for example `image(result.content[0])`. MCP image blocks may request original detail with `_meta: { "codex/imageDetail": "original" }`. When provided, the second `detail` argument overrides any detail embedded in the first argument.
29+
- `image(imageUrlOrItem: string | { image_url: string; detail?: "auto" | "low" | "high" | "original" | null } | ImageContent, detail?: "auto" | "low" | "high" | "original" | null)`: Appends an image item. `image_url` can be an HTTPS URL or a base64-encoded `data:` URL. To forward an MCP tool image, pass an individual `ImageContent` block from `result.content`, for example `image(result.content[0])`. MCP image blocks may request detail with `_meta: { "codex/imageDetail": "original" }`. When provided, the second `detail` argument overrides any detail embedded in the first argument.
3030
- `store(key: string, value: any)`: stores a serializable value under a string key for later `exec` calls in the same session.
3131
- `load(key: string)`: returns the stored value for a string key, or `undefined` if it is missing.
3232
- `notify(value: string | number | boolean | undefined | null)`: immediately injects an extra `custom_tool_call_output` for the current `exec` call. Values are stringified like `text(...)`.

codex-rs/code-mode/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub use description::normalize_code_mode_identifier;
1515
pub use description::parse_exec_source;
1616
pub use description::render_code_mode_sample;
1717
pub use description::render_json_schema_to_typescript;
18+
pub use response::DEFAULT_IMAGE_DETAIL;
1819
pub use response::FunctionCallOutputContentItem;
1920
pub use response::ImageDetail;
2021
pub use runtime::DEFAULT_EXEC_YIELD_TIME_MS;

codex-rs/code-mode/src/response.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ pub enum ImageDetail {
1010
Original,
1111
}
1212

13+
pub const DEFAULT_IMAGE_DETAIL: ImageDetail = ImageDetail::High;
14+
1315
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1416
#[serde(tag = "type", rename_all = "snake_case")]
1517
pub enum FunctionCallOutputContentItem {

0 commit comments

Comments
 (0)