fix: agent mode missing file cards for BINARY_LINK and FILE type tool outputs (#36746)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
cheatofrom 2026-06-10 09:41:37 +08:00 committed by GitHub
parent a823649934
commit 3fb1d3055e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View File

@ -283,7 +283,11 @@ class ToolEngine:
Extract tool response binary
"""
for response in tool_response:
if response.type in {ToolInvokeMessage.MessageType.IMAGE_LINK, ToolInvokeMessage.MessageType.IMAGE}:
if response.type in {
ToolInvokeMessage.MessageType.IMAGE_LINK,
ToolInvokeMessage.MessageType.IMAGE,
ToolInvokeMessage.MessageType.BINARY_LINK,
}:
mimetype = None
if not response.meta:
raise ValueError("missing meta data")
@ -298,7 +302,11 @@ class ToolEngine:
mimetype = guess_type_result
if not mimetype:
mimetype = "image/jpeg"
mimetype = (
"image/jpeg"
if response.type != ToolInvokeMessage.MessageType.BINARY_LINK
else "application/octet-stream"
)
yield ToolInvokeMessageBinary(
mimetype=response.meta.get("mime_type", mimetype),

View File

@ -172,6 +172,8 @@ class ToolFileMessageTransformer:
meta=tool_file_meta,
)
else:
if file.mime_type and "mime_type" not in tool_file_meta:
tool_file_meta["mime_type"] = file.mime_type
yield ToolInvokeMessage(
type=ToolInvokeMessage.MessageType.LINK,
message=ToolInvokeMessage.TextMessage(text=url),