From 9bbefd5f45328fa206129345eb43ba85176214c4 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 19 Nov 2026 11:09:41 +0800 Subject: [PATCH] fix(agent): remove binary format from view_image schema (#7475) --- app/agent/tools/impl/view_image.py | 6 +++--- tests/test_llm_tool_schema.py | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/agent/tools/impl/view_image.py b/app/agent/tools/impl/view_image.py index 44839096d..12ebcb0fe 100644 --- a/app/agent/tools/impl/view_image.py +++ b/app/agent/tools/impl/view_image.py @@ -64,9 +64,9 @@ class ViewImageInput(BaseModel): None, description="本地图片路径;非管理员仅可读取 Agent 配置目录内文件", ) - image_data: Optional[Union[str, bytes]] = Field( + image_data: Optional[str] = Field( None, - description="Base64 图片内容、data:image/...;base64,... 或原始图片字节;只能选择一种图片来源", + description="Base64 图片内容或 data:image/...;base64,...;只能选择一种图片来源", ) detail: Literal['auto', 'low', 'high'] = Field( "auto", @@ -104,7 +104,7 @@ class ViewImageTool(MoviePilotTool): default=( "将图片的实际像素提供给多模态模型查看。" "url、file_path 和 image_data 必须且只能提供一项。" - "支持公网 HTTP(S) 图片地址、data:image/...;base64,... 地址、Base64 或原始图片内容以及本地路径。" + "支持公网 HTTP(S) 图片地址、data:image/...;base64,... 地址、Base64 图片内容以及本地路径。" "本地读取遵守 Agent 文件权限边界,禁止私网 URL。" "需要视觉检查时使用;" "只有工具返回图片观察结果后才能声称已查看图片。" diff --git a/tests/test_llm_tool_schema.py b/tests/test_llm_tool_schema.py index ef35d3392..51a0b1e57 100644 --- a/tests/test_llm_tool_schema.py +++ b/tests/test_llm_tool_schema.py @@ -139,6 +139,9 @@ def test_non_gemini_requests_preserve_nullable_tool_parameters( assert skill["properties"]["file"]["anyOf"] == [{"type": "string"}, {"type": "null"}] assert skill["required"] == (["name", "file"] if bind_kwargs.get("strict") else ["name"]) + image_data = _parameters(tools, "view_image")["properties"]["image_data"] + assert image_data["anyOf"] == [{"type": "string"}, {"type": "null"}] + def test_optional_fields_collapse_to_single_type_for_gemini_models() -> None: """