fix: shrink images to reported provider dimension limit (#45979)

Parse provider-reported image pixel ceilings so many-image Anthropic requests can recover by shrinking Retina screenshots below the stricter limit instead of retrying the same rejected payload.
This commit is contained in:
brooklyn!
2026-06-14 01:07:43 -05:00
committed by GitHub
parent cdf30a7ac6
commit 4b5ba112ad
4 changed files with 128 additions and 12 deletions
+10 -2
View File
@@ -4553,10 +4553,18 @@ class AIAgent:
)
return summary
def _try_shrink_image_parts_in_messages(self, api_messages: list) -> bool:
def _try_shrink_image_parts_in_messages(
self,
api_messages: list,
*,
max_dimension: int = 8000,
) -> bool:
"""Forwarder — see ``agent.conversation_compression.try_shrink_image_parts_in_messages``."""
from agent.conversation_compression import try_shrink_image_parts_in_messages
return try_shrink_image_parts_in_messages(api_messages)
return try_shrink_image_parts_in_messages(
api_messages,
max_dimension=max_dimension,
)
def _try_strip_image_parts_from_tool_messages(self, api_messages: list) -> bool:
"""Downgrade list-type tool messages to text summaries in-place.