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:
Sidharth Lakshmanan
2026-11-21 00:23:59 +00:00
committed by copyberry
parent e346540867
commit 0bfb8467da
47 changed files with 341 additions and 22 deletions
+5
View File
@@ -3225,6 +3225,7 @@ pub struct ImageGenerationBeginEvent {
pub call_id: String,
}
#[serde_as]
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema, TS)]
pub struct ImageGenerationEndEvent {
pub call_id: String,
@@ -3249,6 +3250,10 @@ pub struct ImageGenerationEndEvent {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub generation_id: Option<String>,
#[serde_as(deserialize_as = "serde_with::DefaultOnError")]
#[serde(default, skip_serializing_if = "Map::is_empty")]
#[ts(as = "Option<_>", optional)]
pub image_metadata: Map<String, Value>,
}
// Conversation kept for backward compatibility.