fix: convert OpenAI tool result images for Claude#6261
Draft
Maoyitt wants to merge 1 commit into
Draft
Conversation
Contributor
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
xcrong
added a commit
to WebAgentLoop/nextrouter
that referenced
this pull request
Jul 17, 2026
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.
Important
Note
This change was AI-assisted. The scope, root cause, generated payload, and test results were reviewed during preparation; the PR remains a draft for final human review.
📝 变更描述 / Description
OpenAI Chat Completions 的普通消息在转换到 Claude Messages 时,会将
image_url解析为 Claude 原生的image/source。但role: tool分支此前直接把message.Content写入tool_result.content,导致工具返回的图片仍以 OpenAIimage_url结构发送给 Claude 兼容上游并触发参数校验错误。本修改仅转换工具结果内容中的
image_url:沿用现有媒体解析逻辑读取 URL 或 Base64 数据,并输出 Claudeimage(PDF 输出为document)内容块。文本、已经是 Claude 格式的图片块及未知内容保持原样。🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
新增回归测试验证:
tool_result.content中的 OpenAIimage_url会序列化为 Claudeimage/source,最终请求不再包含image_url。Summary by CodeRabbit
New Features
Bug Fixes