fix(media-understanding): place Qwen/DashScope image prompts in user content (#92688)#92770
Conversation
…content DashScope vision models (qwen3.7-max, qwen3.7-plus) return 400 "Unexpected item type in content" when the image request sends the prompt in a system message and only image blocks in the user message. Add DashScope endpoint detection to shouldPlaceImagePromptInUserContent so the prompt text is placed in the user content alongside the image, matching how GitHub Copilot and OpenRouter routes already work. Fixes openclaw#92688
|
Codex review: needs real behavior proof before merge. Reviewed June 15, 2026, 2:01 PM ET / 18:01 UTC. Summary PR surface: Source +17, Tests +53. Total +70 across 2 files. Reproducibility: yes. at source level: current main can build a system prompt plus image-only user content for Qwen/DashScope image requests. A live DashScope 400 reproduction still needs provider credentials, but the linked logs match this payload path. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Reuse existing ModelStudio provider-family or endpoint-class metadata to cover the full Qwen/DashScope family, add alias/global-endpoint regression tests, and include redacted live DashScope or OpenClaw runtime proof when credentials are available. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main can build a system prompt plus image-only user content for Qwen/DashScope image requests. A live DashScope 400 reproduction still needs provider credentials, but the linked logs match this payload path. Is this the best way to solve the issue? No, not as written: moving the prompt into user content is the right direction, but the detector should be driven by existing ModelStudio provider metadata or explicitly cover all shipped aliases and CN/global endpoints. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a0b16f37e835. Label changesLabel justifications:
Evidence reviewedPR surface: Source +17, Tests +53. Total +70 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Closing: cannot provide live Qwen API proof, and the Deno Deploy dependency registry is currently returning 400 errors blocking CI. Issue remains open. |
|
Reopening — CI was passing, closed by mistake. |
|
Closing in favor of the merged fix in #93649. |
Fixes #92688
Summary
DashScope vision models (qwen3.7-max, qwen3.7-plus) return 400 "Unexpected item type in content" when the image tool sends the prompt in a system message and only image blocks in the user message. The fix adds DashScope/Qwen endpoint detection to
shouldPlaceImagePromptInUserContentso the prompt text is placed in the user content alongside the image.Root Cause
src/media-understanding/image.tsbuilds image context with the prompt insystemPromptby default. Only GitHub Copilot and OpenRouter routes override this to place the prompt in user content. DashScope's OpenAI-compatible endpoint rejects image-only user messages with a 400 schema error.Changes
src/media-understanding/image.ts: AddedisDashScopeEndpoint()helper detectingqwen,qwen-dashscope,dashscopeproviders anddashscope.aliyuncs.combase URLs. Added early return inshouldPlaceImagePromptInUserContent()for DashScope endpoints.src/media-understanding/image.test.ts: Added test verifying DashScope/Qwen image prompts are placed in user content with systemPrompt undefined.Real behavior proof
Behavior or issue addressed: Qwen vision models fail with 400 "Unexpected item type in content" on DashScope when using the image tool.
Real environment tested: Linux 6.6.114.1-microsoft-standard-WSL2 (x64), Node.js v24.16.0, commit 97281d8 on branch fix/qwen-dashscope-vision-prompt-in-user-content.
Exact steps or command run after this patch:
Evidence after fix:
Observed result after fix: The
isDashScopeEndpointfunction correctly identifies qwen, qwen-dashscope, and dashscope.aliyuncs.com URLs.shouldPlaceImagePromptInUserContentnow returns true for these endpoints, causing the prompt to be placed in user content alongside the image blocks instead of in a system message. The test validates that systemPrompt is undefined and user content contains both text and image parts.What was not tested: Live DashScope API call with credentials (requires DashScope account). Only source-level logic verification was performed. The fix follows the same pattern as the existing GitHub Copilot and OpenRouter detections which are well-tested.
Proof limitations: No live provider 400 reproduction — the fix is based on source analysis of the payload shape and the reporter's error logs. The DashScope endpoint detection covers common provider/URL patterns but may miss exotic custom configurations.