Skip to content

Handle inline image request caps gracefully#15569

Open
fjord-oai wants to merge 1 commit intofjord/original_image_size_warn-sync---4i5oof0m2upvfefrom
fjord/original_image_size_warn
Open

Handle inline image request caps gracefully#15569
fjord-oai wants to merge 1 commit intofjord/original_image_size_warn-sync---4i5oof0m2upvfefrom
fjord/original_image_size_warn

Conversation

@fjord-oai
Copy link
Copy Markdown
Contributor

@fjord-oai fjord-oai commented Mar 23, 2026

Summary

Handle inline image request caps gracefully.

Codex now enforces two Responses API request limits using model capability data:

  • total inline image bytes, defaulting to 512 MiB
  • total image count, defaulting to 1,500

If the current turn’s tool output would push a request over either limit, Codex replaces the tool-emitted images with a textual recovery message before persisting history, while preserving any existing text output from the tool. That lets the model continue in the same turn and keeps resumed/forked threads aligned with the context the model actually saw.

Changes

  • Added inline_image_request_limit_bytes and inline_image_request_limit_image_count to ModelInfo.
  • Added local preflight logic for request-wide inline image bytes and image count.
  • Defaulted those limits to 512 MiB and 1,500 when the model does not specify overrides.
  • Sanitized over-limit tool image output before history/rollout persistence.
  • Preserved non-image tool text when sanitizing mixed tool output.
  • Added targeted tests for:
    • request byte counting
    • request image counting
    • model capability propagation
    • pre-persistence sanitization
    • preserving text while stripping image output
  • Moved inline_image_request_limit unit tests into a sibling inline_image_request_limit_tests.rs file.

git stack

@fjord-oai
Copy link
Copy Markdown
Contributor Author

@codex review

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: 9aef5c791e

ℹ️ 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".

@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch from 9aef5c7 to 39898e5 Compare March 23, 2026 22:36
@fjord-oai
Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ 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".

@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch 4 times, most recently from 7e91a9f to ab34bd3 Compare March 26, 2026 17:22
@fjord-oai fjord-oai changed the base branch from main to fjord/original_image_size_warn-sync---4i5oof0m2upvfe March 26, 2026 17:22
@fjord-oai fjord-oai changed the base branch from fjord/original_image_size_warn-sync---4i5oof0m2upvfe to main March 26, 2026 17:36
@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch from ab34bd3 to c6f27b7 Compare March 26, 2026 17:36
@fjord-oai fjord-oai changed the base branch from main to fjord/original_image_size_warn-sync---4i5oof0m2upvfe March 26, 2026 17:36
@fjord-oai fjord-oai changed the base branch from fjord/original_image_size_warn-sync---4i5oof0m2upvfe to main March 26, 2026 19:06
@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch from c6f27b7 to 730ac7f Compare March 26, 2026 19:06
@fjord-oai fjord-oai changed the base branch from main to fjord/original_image_size_warn-sync---4i5oof0m2upvfe March 26, 2026 19:06
@fjord-oai fjord-oai changed the base branch from fjord/original_image_size_warn-sync---4i5oof0m2upvfe to main March 26, 2026 19:41
@fjord-oai fjord-oai changed the base branch from main to fjord/original_image_size_warn-sync---4i5oof0m2upvfe March 26, 2026 19:41
@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch from 730ac7f to d6a6102 Compare March 26, 2026 19:41
@fjord-oai fjord-oai changed the base branch from fjord/original_image_size_warn-sync---4i5oof0m2upvfe to main March 26, 2026 20:00
@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch from d6a6102 to ee465e0 Compare March 26, 2026 20:00
@fjord-oai fjord-oai changed the base branch from main to fjord/original_image_size_warn-sync---4i5oof0m2upvfe March 26, 2026 20:00
@fjord-oai fjord-oai changed the base branch from fjord/original_image_size_warn-sync---4i5oof0m2upvfe to main March 26, 2026 20:21
@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch from ee465e0 to da891c8 Compare March 26, 2026 20:21
@fjord-oai fjord-oai changed the base branch from main to fjord/original_image_size_warn-sync---4i5oof0m2upvfe March 26, 2026 20:21
@fjord-oai fjord-oai changed the base branch from fjord/original_image_size_warn-sync---4i5oof0m2upvfe to main March 28, 2026 18:54
@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch from da891c8 to 804f662 Compare March 28, 2026 18:54
@fjord-oai fjord-oai changed the base branch from main to fjord/original_image_size_warn-sync---4i5oof0m2upvfe March 28, 2026 18:54
@fjord-oai fjord-oai changed the base branch from fjord/original_image_size_warn-sync---4i5oof0m2upvfe to main March 30, 2026 19:16
@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch from 804f662 to 1ba14ca Compare March 30, 2026 19:16
@fjord-oai fjord-oai changed the base branch from main to fjord/original_image_size_warn-sync---4i5oof0m2upvfe March 30, 2026 19:16
@fjord-oai fjord-oai changed the base branch from fjord/original_image_size_warn-sync---4i5oof0m2upvfe to main March 30, 2026 19:29
@fjord-oai fjord-oai changed the base branch from main to fjord/original_image_size_warn-sync---4i5oof0m2upvfe March 30, 2026 19:29
@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch from 1ba14ca to 1705565 Compare March 30, 2026 19:29
@fjord-oai fjord-oai changed the base branch from fjord/original_image_size_warn-sync---4i5oof0m2upvfe to main March 30, 2026 19:49
@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch from 1705565 to f47e210 Compare March 30, 2026 19:49
@fjord-oai fjord-oai changed the base branch from main to fjord/original_image_size_warn-sync---4i5oof0m2upvfe March 30, 2026 19:49
@fjord-oai fjord-oai changed the base branch from fjord/original_image_size_warn-sync---4i5oof0m2upvfe to main March 30, 2026 20:07
@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch from f47e210 to f263955 Compare March 30, 2026 20:07
@fjord-oai fjord-oai changed the base branch from main to fjord/original_image_size_warn-sync---4i5oof0m2upvfe March 30, 2026 20:07
@fjord-oai fjord-oai changed the base branch from fjord/original_image_size_warn-sync---4i5oof0m2upvfe to main March 30, 2026 20:23
@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch from f263955 to 2fc7726 Compare March 30, 2026 20:24
@fjord-oai fjord-oai changed the base branch from main to fjord/original_image_size_warn-sync---4i5oof0m2upvfe March 30, 2026 20:24
@fjord-oai fjord-oai changed the base branch from fjord/original_image_size_warn-sync---4i5oof0m2upvfe to main March 30, 2026 21:13
@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch from 2fc7726 to a1d21e3 Compare March 30, 2026 21:13
@fjord-oai fjord-oai changed the base branch from main to fjord/original_image_size_warn-sync---4i5oof0m2upvfe March 30, 2026 21:13
@fjord-oai fjord-oai changed the base branch from fjord/original_image_size_warn-sync---4i5oof0m2upvfe to main March 30, 2026 23:26
@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch from a1d21e3 to ffe7917 Compare March 30, 2026 23:26
@fjord-oai fjord-oai changed the base branch from main to fjord/original_image_size_warn-sync---4i5oof0m2upvfe March 30, 2026 23:26
git-stack-id: fjord/original_image_size_warn
git-stack-title: Handle inline image request caps gracefully
@fjord-oai fjord-oai changed the base branch from fjord/original_image_size_warn-sync---4i5oof0m2upvfe to main March 30, 2026 23:49
@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch from ffe7917 to b05eaf3 Compare March 30, 2026 23:49
@fjord-oai fjord-oai changed the base branch from main to fjord/original_image_size_warn-sync---4i5oof0m2upvfe March 30, 2026 23:49
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