Skip to content

fix(core): bound Bedrock inline image history - #1

Open
cncoder wants to merge 1 commit into
mainfrom
fix/bedrock-inline-image-budget-46247
Open

cncoder wants to merge 1 commit into
mainfrom
fix/bedrock-inline-image-budget-46247

Conversation

@cncoder

@cncoder cncoder commented Sep 17, 2026

Copy link
Copy Markdown
Owner

Addresses openai#46247.

This is a review PR in cncoder/codex. Creating the corresponding upstream PR was rejected by GitHub (cncoder does not have the correct permissions to execute CreatePullRequest), and the upstream contribution policy does not accept external PRs. This PR has not been accepted or merged upstream.

Bedrock Runtime can reject image-heavy histories by encoded request size before token-based compaction is triggered. Successful compaction can also retain enough inline images to keep subsequent requests oversized.

This change adds a separate inline-image byte budget at the existing pre-turn and post-sampling compaction boundaries. Newly submitted user images reach the model before retention is reduced. After successful compaction, recent inline images are retained within a smaller byte budget while text, file references, message metadata, and positional classifications remain consistent.

Large PNGs are losslessly re-encoded when that produces a smaller representation with identical pixels, preserving ICC and EXIF metadata. The same normalization applies to the request copy when compacting legacy histories. Original rollout files and encrypted reasoning are not rewritten.

The 8 MB trigger and 4 MB retention budget are conservative operational margins for Bedrock Runtime, not claims about an official service quota. Other providers retain their existing behavior; file-image references do not consume the inline-payload budget.

Validation:

  • Built the CLI and code-mode host and assembled a complete Linux GNU package using the repository's checksum-verified V8 artifact resolver.
  • All 8 new unit tests and both new integration tests pass. Coverage includes legacy metadata, partial classifications, idempotence, file references, image bytes versus vision tokens, preservation of newly submitted images, and unchanged behavior on another provider.
  • Selected image/compaction suites: 87 tests selected; nextest reports 86 passed and one failure. view_image_tool_applies_local_sandbox_read_denies fails identically on unchanged baseline fcf05456bb27e6c3d5677550f54011db6a2a0817 on this host: the mock expects two requests and receives none. The remote-environment routing case requires a configured remote executor, so this run does not establish remote-platform coverage.
  • Real Bedrock Runtime test in an isolated Codex data directory: one batch of 23 images followed by 32 more images, six automatic compactions, one manual compaction, and a client restart/recall check all succeeded. The token threshold was 200,000, so the image-byte budget triggered independently.
  • Same-format synthetic PNG control: 32 identical 64×64 images with different amounts of inert EXIF padding produce HTTP 400 at 34,143,253 request bytes and HTTP 200 at 25,609,877 bytes. The successful request uses only 324 input tokens.

The full workspace and other operating systems were not tested. No private screenshots, credentials, or conversation contents are included.

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