Skip to content

Store image save hints on image generation calls#22372

Open
won-openai wants to merge 2 commits into
mainfrom
remove_img_developer
Open

Store image save hints on image generation calls#22372
won-openai wants to merge 2 commits into
mainfrom
remove_img_developer

Conversation

@won-openai
Copy link
Copy Markdown
Collaborator

Why

Completed image generation calls need to carry their saved-image location into follow-up model turns without injecting a separate developer message into history. Keeping that hint on the image_generation_call itself preserves the intended next-request shape and avoids adding extra synthetic context items.

What changed

  • Added optional output_hint support to ResponseItem::ImageGenerationCall and regenerated the app-server protocol artifacts.
  • Kept local image saving and UI saved_path behavior unchanged.
  • Replaced the old developer-message history write with an output_hint attached to the completed image generation call before it is recorded.
  • Localized the history rewrite to completed-item handling while leaving handle_non_tool_response_item focused on TurnItem emission.
  • Updated history and model-switching coverage so replay preserves output_hint, text-only models still strip image bytes, and no separate developer saved-path note is emitted.

Validation

  • just fmt
  • cargo test -p codex-core image_save
  • cargo test -p codex-core generated_image

@won-openai won-openai requested a review from a team as a code owner May 12, 2026 20:20
@won-openai won-openai marked this pull request as draft May 12, 2026 20:20
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f11d249215

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +446 to +449
*output_hint = Some(
ImageGenerationInstructions::new(image_output_dir.display(), saved_path.display())
.body(),
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Do not replay output_hint to the Responses API

When an image generation succeeds, this embeds the local save note into the ResponseItem that is recorded in history. On the next turn, history is sent unchanged through History::for_promptPrompt::get_formatted_inputResponsesApiRequest.input, so any conversation that generated an image will replay an image_generation_call with this synthetic output_hint field. The Responses API input schema for image_generation_call only accepts the tool-call fields such as id, result, status, and type (I also checked the official generated SDK/docs and found no output_hint field), so this can turn the following model request into a 400 instead of simply giving the model the save hint. Keep the hint in a Codex-only wrapper or strip it before building the API request.

Useful? React with 👍 / 👎.

@won-openai
Copy link
Copy Markdown
Collaborator Author

name of the variable is tentative

@won-openai won-openai marked this pull request as ready for review May 12, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant