Expose image generation usage-limit failures (#38024)

## What changed

- Add structured `usageLimitExceeded` metadata to failed image-generation
  items, including the image limit ID and optional reset timestamp.
- Preserve the failure metadata in completion events, app-server thread
  history, thread reads and resumes, and migrated legacy rollouts.
- Export the new failure type in the generated JSON and TypeScript schemas.

## Testing

- Cover usage-limit responses through item completion, persistence, and thread
  resume.
- Verify legacy rollout migration retains image-generation failure metadata.

GitOrigin-RevId: 91c31a2a47456b6b916ee03002ff314b05946dd4
This commit is contained in:
arun eswara authored and copyberry committed 2026-08-11 15:40:52 +00:00
1 parent 4c5fc230a9
commit edcec13372
41 files changed
+1104 -18

No files matched your search

@@ -8,6 +8,8 @@
//! It intentionally stays separate from live thread-history reduction because migration needs a
//! frozen adapter for historical rollout payloads.
use codex_extension_items::ExtensionItem;
use codex_extension_items::image_generation::ImageGenerationItem;
use codex_protocol::items::AgentMessageContent;
use codex_protocol::items::AgentMessageItem;
use codex_protocol::items::CommandExecutionItem;
@@ -17,7 +19,6 @@ use codex_protocol::items::DynamicToolCallStatus;
use codex_protocol::items::EnteredReviewModeItem;
use codex_protocol::items::ExitedReviewModeItem;
use codex_protocol::items::FileChangeItem;
use codex_protocol::items::ImageGenerationItem;
use codex_protocol::items::McpToolCallError;
use codex_protocol::items::McpToolCallItem;
use codex_protocol::items::McpToolCallStatus;
@@ -156,13 +157,15 @@ pub(super) fn completed_item(
None,
)),
EventMsg::ImageGenerationEnd(event) => Some((
TurnItem::ImageGeneration(ImageGenerationItem {
TurnItem::Extension(ExtensionItem::ImageGeneration(ImageGenerationItem {
id: event.call_id.clone(),
status: event.status.clone(),
revised_prompt: event.revised_prompt.clone(),
result: event.result.clone(),
transparent_background: event.transparent_background,
failure: event.failure.clone(),
saved_path: event.saved_path.clone(),
}),
})),
None,
)),
EventMsg::ContextCompacted(_) => Some((