Files
Won Park 123cf62a48 Route image edits through referenced file paths (#26486)
## Why

Image edits should use the exact images selected by the model instead of
inferring edit inputs from conversation history.

## What changed

- Replaced the image tool's `action` argument with optional
`referenced_image_paths`.
- Treats omitted or empty references as generation and populated
references as editing.
- Reads referenced absolute image paths and packages them as image data
URLs for the edit request.
- Removed the previous history-selection and image-count heuristics.
- Updated direct and code-mode tool instructions and calls.
- Added an app-server integration test covering an attached image routed
to the image edit endpoint.

## Validation
- Tested end-to-end on local `just codex` with copy pasted image,
attached image, etc.
- `just test -p codex-image-generation-extension`
- `just test -p codex-app-server
standalone_image_edit_uses_attached_model_visible_image`
- `just fix -p codex-image-generation-extension`
- `just bazel-lock-check`
2026-06-08 14:23:55 -07:00

1.7 KiB

The image_gen.imagegen tool enables image generation from descriptions and editing of existing images based on specific instructions. Use it when:

  • The user requests an image based on a scene description, such as a diagram, portrait, comic, meme, or any other visual.
  • The user wants to modify an attached or previously generated image with specific changes, including adding or removing elements, altering colors, improving quality/resolution, or transforming the style (e.g., cartoon, oil painting).

Guidelines:

  • In code mode, pass the result to generatedImage(result).
  • Omit both referenced_image_paths and num_last_images_to_include when generating a brand new image.
  • For edits, use referenced_image_paths when every target image has a local file path.
  • If you have not seen a local image yet, use view_image to inspect it before editing.
  • Use num_last_images_to_include only when at least one target image has no local file path.
  • Set num_last_images_to_include to the smallest number of recent conversation images that includes every target image, up to 5.
  • Never provide both referenced_image_paths and num_last_images_to_include.
  • If neither mechanism can include every target image, ask the user to attach the missing images again.
  • Directly generate the image without reconfirmation or clarification unless required images must be attached again.
  • After each image generation, do not mention anything related to download. Do not summarize the image. Do not ask followup question. Do not say ANYTHING after you generate an image.
  • Always use this tool for image editing unless the user explicitly requests otherwise. Do not use the python tool for image editing unless specifically instructed.