mirror of
https://github.com/openai/codex.git
synced 2026-11-30 00:10:49 +00:00
Preserve per-image metadata in app-server image generation items (#62871)
## Why App-server clients lose metadata supplied by the image backend when Codex turns the response into a completed image generation item. ## What changed Expose the backend's `image_metadata` as optional `imageMetadata` in app-server items and preserve nested values through thread persistence, resume, and legacy history replay and migration. Keep this metadata out of model tool output. Omit empty metadata and discard non-object, oversized, or deeply nested metadata without dropping the generated image. ## Testing Extend coverage for per-image parsing, metadata limits, and round trips through app-server completion, persisted history, and thread resume. GitOrigin-RevId: 7211a9db1149cb05e6176b08b0462ca173ac72d5
This commit is contained in:
committed by
copyberry
parent
e346540867
commit
0bfb8467da
@@ -5748,6 +5748,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
+5
@@ -24805,6 +24805,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
+5
@@ -22501,6 +22501,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
@@ -1841,6 +1841,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
@@ -1841,6 +1841,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
@@ -2057,6 +2057,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
@@ -2671,6 +2671,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
@@ -1841,6 +1841,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
@@ -2462,6 +2462,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
+5
@@ -2462,6 +2462,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
@@ -2462,6 +2462,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
@@ -2723,6 +2723,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
@@ -2462,6 +2462,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
+5
@@ -2473,6 +2473,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
@@ -2671,6 +2671,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
@@ -2462,6 +2462,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
@@ -2057,6 +2057,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
@@ -2462,6 +2462,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
@@ -2057,6 +2057,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
@@ -2057,6 +2057,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
@@ -2057,6 +2057,11 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageMetadata": {
|
||||
"additionalProperties": true,
|
||||
"description": "Per-image metadata selected by the backend for the receiving surface.",
|
||||
"type": "object"
|
||||
},
|
||||
"inputImages": {
|
||||
"description": "Observed local inputs for a completed generation, absent on older items.",
|
||||
"items": {
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -4,6 +4,7 @@
|
||||
import type { AbsolutePathBuf } from "./AbsolutePathBuf";
|
||||
import type { ImageGenerationFailure } from "./ImageGenerationFailure";
|
||||
import type { ImageGenerationInputImage } from "./ImageGenerationInputImage";
|
||||
import type { JsonValue } from "./serde_json/JsonValue";
|
||||
|
||||
export type ImageGenerationItem = { id: string, status: string, revisedPrompt: string | null, transparentBackground?: boolean, failure: ImageGenerationFailure | null, savedPath?: AbsolutePathBuf,
|
||||
/**
|
||||
@@ -13,4 +14,8 @@ inputImages?: Array<ImageGenerationInputImage>,
|
||||
/**
|
||||
* Image generation identifier for the generated image, when provided by the image backend.
|
||||
*/
|
||||
generationId: string | null, } & ({ fileId: string, } | { result: string, });
|
||||
generationId: string | null,
|
||||
/**
|
||||
* Per-image metadata selected by the backend for the receiving surface.
|
||||
*/
|
||||
imageMetadata?: { [key in string]?: JsonValue }, } & ({ fileId: string, } | { result: string, });
|
||||
|
||||
@@ -1102,6 +1102,7 @@ impl ThreadHistoryBuilder {
|
||||
input_images: Vec::new(),
|
||||
imagegen_request_id: None,
|
||||
generation_id: None,
|
||||
image_metadata: Default::default(),
|
||||
});
|
||||
self.upsert_item_in_current_turn(item);
|
||||
}
|
||||
@@ -1118,6 +1119,7 @@ impl ThreadHistoryBuilder {
|
||||
input_images: payload.input_images.clone(),
|
||||
imagegen_request_id: None,
|
||||
generation_id: payload.generation_id.clone(),
|
||||
image_metadata: payload.image_metadata.clone(),
|
||||
});
|
||||
self.upsert_item_in_current_turn(item);
|
||||
}
|
||||
@@ -2751,6 +2753,7 @@ mod tests {
|
||||
input_images: input_images.clone(),
|
||||
imagegen_request_id: None,
|
||||
generation_id: None,
|
||||
image_metadata: Default::default(),
|
||||
},
|
||||
)),
|
||||
started_at_ms: Some(0),
|
||||
@@ -2793,6 +2796,7 @@ mod tests {
|
||||
input_images,
|
||||
imagegen_request_id: None,
|
||||
generation_id: None,
|
||||
image_metadata: Default::default(),
|
||||
})]
|
||||
);
|
||||
}
|
||||
@@ -3058,6 +3062,16 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn replays_file_backed_image_generation_end_events_into_turn_history() {
|
||||
let image_metadata = serde_json::Map::from_iter([
|
||||
(
|
||||
"entries".to_string(),
|
||||
serde_json::json!([{"name": "first", "value": 1.5}]),
|
||||
),
|
||||
(
|
||||
"futureKey".to_string(),
|
||||
serde_json::json!({"nestedKey": [0, false, null]}),
|
||||
),
|
||||
]);
|
||||
let items = vec![
|
||||
RolloutItem::EventMsg(EventMsg::TurnStarted(TurnStartedEvent {
|
||||
turn_attribution: None,
|
||||
@@ -3096,6 +3110,7 @@ mod tests {
|
||||
sha256: "ab".repeat(32),
|
||||
}],
|
||||
generation_id: None,
|
||||
image_metadata: image_metadata.clone(),
|
||||
})),
|
||||
RolloutItem::EventMsg(EventMsg::TurnComplete(TurnCompleteEvent {
|
||||
root_turn_id: None,
|
||||
@@ -3152,6 +3167,7 @@ mod tests {
|
||||
}],
|
||||
imagegen_request_id: None,
|
||||
generation_id: None,
|
||||
image_metadata,
|
||||
})),
|
||||
],
|
||||
}
|
||||
|
||||
@@ -1105,6 +1105,7 @@ impl From<CoreTurnItem> for ThreadItemPayload {
|
||||
input_images: Vec::new(),
|
||||
imagegen_request_id: None,
|
||||
generation_id: None,
|
||||
image_metadata: Default::default(),
|
||||
}),
|
||||
CoreTurnItem::EnteredReviewMode(review) => Self::EnteredReviewMode {
|
||||
id: review.id,
|
||||
|
||||
Reference in New Issue
Block a user