Skip to content

Handle inline image request caps gracefully#15569

Open
fjord-oai wants to merge 1 commit intomainfrom
fjord/original_image_size_warn
Open

Handle inline image request caps gracefully#15569
fjord-oai wants to merge 1 commit intomainfrom
fjord/original_image_size_warn

Conversation

@fjord-oai
Copy link
Contributor

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.

@fjord-oai
Copy link
Contributor Author

@codex review

Copy link
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
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
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 from 39898e5 to d5f31c2 Compare March 23, 2026 23:02
@fjord-oai fjord-oai force-pushed the fjord/original_image_size_warn branch from d5f31c2 to 1d1bbb6 Compare March 23, 2026 23:50
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