#23711: fix: disable developer role for DashScope/Qwen models (#23575)
agents
size: S
trusted-contributor
Cluster:
DashScope/Qwen Role Management
## Summary
Fixes #23575 — DashScope (Aliyun/Bailian) API returns HTTP 400 when `reasoning: true` because it doesn't support the `developer` role.
## Root Cause
When `reasoning: true`, OpenClaw converts the `system` role to `developer` (following OpenAI's convention). DashScope's OpenAI-compatible API only accepts `system/user/assistant/tool`, so it rejects the request with:
```
HTTP 400: developer is not one of ['system', 'assistant', 'user', 'tool', 'function']
```
## Fix
Extend `normalizeModelCompat` to detect DashScope/Bailian providers and Qwen models, automatically setting `supportsDeveloperRole: false` so the `system` role is preserved.
Detection covers:
- `provider='bailian'` or `'dashscope'`
- `baseUrl` containing `dashscope.aliyuncs.com`
- `modelId` containing `qwen` (via any provider)
Refactored the existing zai-only check into a general `needsDeveloperRoleDisabled` function for cleaner extensibility.
Users can still manually override via `compat.supportsDeveloperRole: true` in their model config if needed.
## Testing
- `model-compat.test.ts` — 5/5 ✅ (added 2 new test cases for DashScope and Qwen)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Extends DashScope/Qwen compatibility detection to prevent HTTP 400 errors when `reasoning: true` by automatically disabling the `developer` role conversion. The fix refactors the existing z.ai-only check into a general `needsDeveloperRoleDisabled()` function that now detects:
- `provider='bailian'` or `'dashscope'`
- `baseUrl` containing `dashscope.aliyuncs.com`
- `modelId` containing `qwen` (via any provider)
The implementation follows the existing pattern established for z.ai models and is well-tested with 2 new test cases covering DashScope providers and Qwen models via custom providers.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with no identified issues
- The implementation is clean, follows existing patterns, has comprehensive test coverage (5/5 tests passing), and addresses the reported issue correctly. The refactoring improves code organization and maintainability while preserving backward compatibility.
- No files require special attention
<sub>Last reviewed commit: 029694e</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#22741: fix(models): add DashScope/Qwen to normalizeModelCompat developer r...
by lailoo · 2026-02-21
91.3%
#23655: fix(model): map developer role to system for Aliyun/Dashscope/Qianf...
by SleuthCo · 2026-02-22
82.6%
#11297: fix: add thinkingFormat 'qwen' compat for bailian/dashscope providers
by AdJIa · 2026-02-07
81.8%
#9451: feat(qwen): enable DashScope/Qwen enable_thinking for /think
by sm-yjr · 2026-02-05
79.3%
#14187: fix: add Moonshot AI to non-standard provider detection
by shad0wca7 · 2026-02-11
75.5%
#22194: fix(agent) Moonshot/Kimi kimi-k2.5 returns ROLE_UNSPECIFIED
by ShengFuC · 2026-02-20
74.3%
#19281: fix: set supportsDeveloperRole false as default for moonshot provider
by MisterGuy420 · 2026-02-17
74.1%
#14013: feat: Add Qwen DashScope API Key authentication support
by pkycy · 2026-02-11
73.8%
#23256: fix(providers): disable developer role for zhipu provider and bigmo...
by SidQin-cyber · 2026-02-22
73.3%
#5920: fix: DeepSeek API compatibility - convert developer role to system ...
by coupclawbot · 2026-02-01
71.7%