fix(relay): preserve multimodal tool outputs in Responses-to-Chat conversion - #7227
fix(relay): preserve multimodal tool outputs in Responses-to-Chat conversion#7227zvv1999 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughResponses input conversion now handles multimodal ChangesResponses tool media conversion
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Responses tool outputs containing supported images or files now retain their multimodal structure during Chat conversion, while unsupported references fail explicitly. Covered ordering, payload, compatibility, and immutability behavior leaves no concrete merge-blocking risk. Sequence Diagram(s)sequenceDiagram
participant ResponsesInput
participant Converter
participant ChatRequest
ResponsesInput->>Converter: provide function_call_output items
Converter->>ChatRequest: append ordered tool messages
Converter->>ChatRequest: append supported media as user messages
Converter-->>ResponsesInput: return converted request or validation error
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
Agent
Links
User request
Out of scope — refuse
function_call_output;不是 Codex 渠道、第三方托管故障或透传请求修复。Kind
Issue facts
以下事实来自本次针对 upstream
49ec4696682530781a036eab1ac195f0b04706c0的离线复现,不将其他项目的生产事故当成本仓库证据。responseToolOutputToChatContent对非字符串 output 整体 Marshal 成字符串。合法的input_image数组因此成为 tool 文本中的 Base64,input_file同样失去结构。openai_responses_to_openai_chat_completions请求转换。数据库、部署、UI、定价逻辑不涉及。未运行 HTTP 服务或调用外部模型。Change
仅识别由
input_text、input_image、input_file组成的非空工具结果数组。纯文本数组转换为工具文本;含媒体的数组保持内容顺序,转换为带原始 call_id 说明的后续 user 多模态消息,tool 回复保留 call_id 和占位说明。所有连续工具回复完成后才追加媒体,避免打断并行调用配对。图片 URL/data URI、detail、文件数据和引用保持原值,不下载、重编码、压缩或施加字节限制。Chat 无法直接表达的 image file_id 和 file_url 明确报错。普通对象、字符串、空数组及未知类型数组保留原有行为。
Research
Duplicate / prior art
repo:QuantumNous/new-api is:pr multimodal;repo:QuantumNous/new-api "function_call_output" "image"。Docs and code
relaykit/relayconvert/internal/oai_responses/to_oai_chat_req.go的responsesRequestMessagesToChat与responseToolOutputToChatContent;原实现将媒体结果写成字符串。Alternatives considered
Files
Behavior
Verification
GOWORK=off go -C relaykit test ./relayconvert/internal/oai_responses -run TestResponsesTool -count=1,退出 1,可复现媒体被字符串化。GOWORK=off go -C relaykit test ./...通过。GOWORK=off go -C relaykit build ./...通过。GOWORK=off go -C relaykit vet ./...通过。git diff --check通过。Risks
Scope check
Summary by CodeRabbit
New Features
Bug Fixes