Skip to content

fix: 粘贴图片改经 put_task 传递,不再 monkey-patch backend.ask - #827

Open
ZexinLiang wants to merge 1 commit into
lsdefine:mainfrom
ZexinLiang:fix/mixin-image-attachment
Open

ZexinLiang wants to merge 1 commit into
lsdefine:mainfrom
ZexinLiang:fix/mixin-image-attachment

Conversation

@ZexinLiang

Copy link
Copy Markdown

问题

Fixes #824 —— 桌面端粘贴图片后,当模型后端为 MixinSession 时抛出 AttributeError(其 .ask 是节点相关的只读属性,不能被运行时替换)。

修改

  • frontends/desktop_bridge.py:删除 _patch_chat_for_images(monkey-patch 方案,-41 行),图片改为 put_task(prompt, images=...) 随任务传递。
  • agentmain.py:新增 build_image_content,在首轮用户消息中构造多模态内容;限制单图 10MB、总量 20MB、最多 8 张,超限图片不读入内存,回退为文件路径文本,附件不丢失。
  • llmcore.py:NativeToolClient.chat 过滤空白文本块时保留图片等非文本块。
  • frontends/tests/test_bridge_submit.py:新增图片编码、超限回退与防回归(禁止恢复 monkey-patch)测试。

测试

  • 274 passed, 3 deselected(frontends/tests 全套)
  • 手工验证:Mixin 后端粘贴图片不再报错;纯文本任务与非 native 客户端行为不变。

….ask

Patching backend.ask raised AttributeError on MixinSession (read-only .ask).
Images now travel as task data: put_task(images=...) -> build_image_content ->
agent_runner_loop(initial_user_content=...), with size/count caps so oversized
files fall back to path references. Also keep non-text blocks (images) when
filtering whitespace-only content in NativeToolClient.chat.

Closes lsdefine#824
Copilot AI balanced review requested due to automatic review settings October 4, 2026 02:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(desktop):粘贴图片时尝试修改只读的 MixinSession.ask 导致报错

2 participants