Repository navigation
Fix image edits generating at on-page size and OpenRouter 400s - #1358
Conversation
Images were generating at their scaled on-page dimension rather than their native pixel size, which failed standard provider resolution constraints (e.g. Gemini Flash Lite requiring 1K). - Added `get_selected_image_pixel_size` to read native image dimensions. - Updated `ImageGenerate` to generate using the native dimensions but preserve document layout footprint on replace. - Handled OpenRouter parameter rejection errors by parsing accepted values and retrying exactly once with adjusted parameters.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Images were generating at their scaled on-page dimension rather than their native pixel size, which failed standard provider resolution constraints (e.g. Gemini Flash Lite requiring 1K). - Added `get_selected_image_pixel_size` to read native image dimensions. - Updated `ImageGenerate` to generate using the native dimensions but preserve document layout footprint on replace. - Handled OpenRouter parameter rejection errors by parsing accepted values and retrying exactly once with adjusted parameters.
Fixes an issue where image generation via
/api/v1/imageson OpenRouter was failing because edits were sized using on-page scaled dimensions instead of native pixel sizes, triggering 400 Bad Request responses (e.g., from Gemini models that enforce strict resolution tiers like "1K").The solution introduces a native pixel size getter for selected images in
image_tools.pyand uses it as the source dimensions while preserving the document's scaled size during replacement. It also adds a retry handler inllm_client.pybacked byadjust_image_body_for_rejectioninbase_provider_shim.pythat catches OpenRouter "not supported" responses, safely falls back to common accepted parameter values (such as resolution or aspect ratio hints), and retries the request exactly once. All unit tests coveringimage_completionretries and sizing logic are included.PR created automatically by Jules for task 11606523006561966997 started by @KeithCu