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:
+10
-2
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user