mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Account for file images in context budgets and Guardian reviews (#46072)
## Why File images contributed zero to history and compaction token estimates and were dropped from Guardian context. This undercounted context usage and omitted image evidence from reviews. ## What changed - Estimate file images using the fixed resized-image cost, or 10,000 patch tokens for `original` detail because file references do not expose dimensions. - Charge file images against remote compaction and Guardian request budgets. - Preserve file images from user messages and tool outputs through Guardian selection and delivery, and deduplicate review images by file ID. - Apply transcript image count and byte limits to both reference types, counting file ID bytes rather than referenced file contents. ## Testing Add coverage for file-image estimates, selection limits, delivery, and compaction retention. Extend Guardian tests to verify file-image evidence reaches reviews and uploaded original-detail images trigger reviewer-history compaction. GitOrigin-RevId: ee024204dcbe16e277fea9347c6a4d7fc120e18d
This commit is contained in:
1 parent
ce03f22af6
commit
b974893c90
18 files changed
+481
-199
No files matched your search
@@ -1677,6 +1677,8 @@ async fn contributor_includes_transcript_images_by_default() -> Result<()> {
|
||||
|
||||
let user_image = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGPgEpEDAABoAD1UCKP3AAAAAElFTkSuQmCC";
|
||||
let tool_image = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGOQE+ECAACQAD304kFaAAAAAElFTkSuQmCC";
|
||||
let user_file_id = "file_user";
|
||||
let tool_file_id = "file_tool";
|
||||
let history = vec![
|
||||
ResponseItem::Message {
|
||||
id: None,
|
||||
@@ -1691,6 +1693,12 @@ async fn contributor_includes_transcript_images_by_default() -> Result<()> {
|
||||
},
|
||||
detail: Some(ImageDetail::High),
|
||||
},
|
||||
ContentItem::InputImage {
|
||||
image: ImageReference::File {
|
||||
file_id: user_file_id.to_owned(),
|
||||
},
|
||||
detail: Some(ImageDetail::High),
|
||||
},
|
||||
],
|
||||
phase: None,
|
||||
internal_chat_message_metadata_passthrough: None,
|
||||
@@ -1719,6 +1727,12 @@ async fn contributor_includes_transcript_images_by_default() -> Result<()> {
|
||||
},
|
||||
detail: Some(ImageDetail::High),
|
||||
},
|
||||
FunctionCallOutputContentItem::InputImage {
|
||||
image: ImageReference::File {
|
||||
file_id: tool_file_id.to_owned(),
|
||||
},
|
||||
detail: Some(ImageDetail::High),
|
||||
},
|
||||
]),
|
||||
internal_chat_message_metadata_passthrough: None,
|
||||
},
|
||||
@@ -1740,16 +1754,24 @@ enabled = true
|
||||
.expect("Luna user content should be an array");
|
||||
|
||||
assert_eq!(
|
||||
content[content.len() - 2..],
|
||||
content[content.len() - 4..],
|
||||
[
|
||||
json!({
|
||||
"type": "input_image",
|
||||
"image_url": user_image,
|
||||
}),
|
||||
json!({
|
||||
"type": "input_image",
|
||||
"file_id": user_file_id,
|
||||
}),
|
||||
json!({
|
||||
"type": "input_image",
|
||||
"image_url": tool_image,
|
||||
}),
|
||||
json!({
|
||||
"type": "input_image",
|
||||
"file_id": tool_file_id,
|
||||
}),
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user