Repository navigation
fix: 让文本模型通过 OCR 读取工具已保存的截图 - #1221
Open
nickfast2025 wants to merge 1 commit into
Open
nickfast2025 wants to merge 1 commit into
nickfast2025 wants to merge 1 commit into
Conversation
Owner
|
[bot]: 麻烦补一条真实的测试结果:用纯文本模型调用 |
Author
|
补测了 本次 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
简介
使用文本模型的智能体调用
computer_observe后,工具已将截图保存到当前 Workdir。如果模型拒绝图片,即使配置了ocr_parse_file,智能体也会回答“没有可供 OCR 工具解析的文件路径”。同一张图片通过read_file读取时可以正常触发 OCR。这个修复让图片中间件使用工具落盘时记录的路径。模型拒图后,已启用的 OCR 工具能读到刚才的截图,智能体随后可以利用识别结果继续回答。
具体改动与影响
read_file优先使用原文件。其他工具按落盘记录匹配图片,在当前请求允许 OCR 时生成调用。实现依据与设计取舍
ToolMediaPersistMiddleware在文件写入成功后记录块位置和路径。模型输入中间件读取同一份记录,沿用当前请求的工具授权和判定图片输入被拒绝的逻辑。历史消息缺少有效记录时,继续使用既有的无路径提示。相关取舍已补入现有的《图片回退使用已启用且授权的 OCR 工具》决策记录。验证情况
将新增的六个截图用例放到原版
b5c46a2上,四个失败。同步和异步截图都缺少 OCR 调用,两种模型输入方式都会重发双图中的第一张。两个read_file对照均通过。另将两个压缩用例放到原版,常规压缩和溢出裁剪都保留了旧索引。修复后的两个用例逐张核对了文件路径和图片内容。在 Linux 断网容器中,从
backend/运行以下测试。前四个文件共 117 项通过,生产图中的授权及用量测试另有 3 项通过。已有的同步工厂测试带有模块级 asyncio 标记,pytest 报告一条警告。单独回放了 LangChain
create_agent的工具循环,使用真实媒体中间件和临时 Workdir、模拟拒图模型及 OCR 工具。原版在拒图后以无路径提示结束。修复后 OCR 工具恰好执行一次,按收到的路径读回与截图一致的 PNG 字节,识别结果进入下一次模型调用。此回放验证工具交接,未调用线上模型或运行真实 OCR 引擎。改动的 Python 文件通过 Ruff 检查和格式检查。工程契约检查、其 56 个单元测试及
git diff --check通过。此次验证覆盖后端相关路径,未运行浏览器端到端测试或全量服务。关联事项
复用 工具截图落盘 #1171 的记录,以及 OCR 工具授权修复 #1093 建立的回退行为。