Budget retained images during remote compaction (#40280)

## Why

Remote compaction's retained-message budget counted text but not images, so
image-heavy history could retain more context than the budget represented.

## What changed

- Add the opt-in `compaction_image_budget` feature to charge retained images
  using the existing image size estimate.
- Keep images and their adjacent labels atomic when truncating a boundary
  message, while preserving existing text, audio, metadata, and
  client-authored developer-message behavior.
- Stop backfilling older messages when an image at the truncation boundary
  does not fit.

## Testing

- Add unit coverage for image boundaries, annotations, audio, text-only
  messages, and client-authored developer messages.
- Add an integration test covering repeated remote compaction with the feature
  enabled, disabled, and left at its default.

GitOrigin-RevId: 88868bbd09d2858939dbae3f8402e1f497b4e3c6
This commit is contained in:
ashwinnathan-openai authored and copyberry committed 2026-08-23 21:29:11 +00:00
1 parent aec653daa9
commit 6677fd827d
10 files changed
+507 -28

No files matched your search

+6
View File
@@ -640,6 +640,9 @@
"collaboration_modes": {
"type": "boolean"
},
"compaction_image_budget": {
"type": "boolean"
},
"computer_use": {
"type": "boolean"
},
@@ -5610,6 +5613,9 @@
"collaboration_modes": {
"type": "boolean"
},
"compaction_image_budget": {
"type": "boolean"
},
"computer_use": {
"type": "boolean"
},