← Back to PRs

#23655: fix(model): map developer role to system for Aliyun/Dashscope/Qianfan providers

by SleuthCo open 2026-02-22 15:11 View on GitHub →
agents size: S
## Summary Aliyun/Dashscope, Qwen Portal, and Qianfan (Baidu) implement OpenAI-compatible APIs but reject the newer "developer" role, returning `InvalidParameter` errors. This extends `normalizeModelCompat()` to detect these providers and set `supportsDeveloperRole: false`. Supersedes #13779 (rebased against current HEAD after upstream changes to model-compat.ts). Fixes #13633 ## Changes - **model-compat.ts**: Expand provider detection from Z.AI-only to include Dashscope, Qwen Portal, and Qianfan (by provider name or base URL pattern). Support both `openai-completions` and `openai-responses` API types. - **pi-embedded-runner/model.ts**: Propagate user-configured model properties (`reasoning`, `input`, `cost`, `compat`) from matched provider config entry instead of hardcoding defaults in the fallback model construction. - **model-compat.test.ts**: 5 new test cases covering all affected providers + Anthropic passthrough. ## Test plan - [ ] All 8 model-compat tests pass (`npx vitest run src/agents/model-compat.test.ts`) - [ ] Qwen model via Dashscope URL → `supportsDeveloperRole: false` applied - [ ] Provider with `compat` flags in config → flags propagated to fallback model 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> <!-- greptile_comment --> <h3>Greptile Summary</h3> Extends `normalizeModelCompat()` to disable the OpenAI "developer" role for Aliyun/Dashscope, Qwen Portal, and Qianfan providers that reject it with `InvalidParameter` errors. **Key changes:** - Generalizes provider detection to support both `openai-completions` and `openai-responses` APIs - Adds URL pattern matching for dashscope.aliyuncs.com, portal.qwen.ai, and qianfan.baidubce.com - Propagates user-configured model properties (`reasoning`, `input`, `cost`, `compat`) in pi-embedded-runner fallback model construction - Adds comprehensive test coverage for all affected providers **Issue found:** - Missing `"aliyun"` provider name check in `isDeveloperRoleUnsupportedProvider()` - test uses `provider: "aliyun"` but function only checks URL patterns for Aliyun, not the provider name itself <h3>Confidence Score: 3/5</h3> - PR has a logical error that will cause test failure for Aliyun provider detection - The implementation is mostly solid with good test coverage and proper handling of provider detection patterns. However, there's a critical bug: the test expects `provider: "aliyun"` to be detected, but the provider name check only includes `"zai"`, `"qwen-portal"`, and `"qianfan"` - missing `"aliyun"`. The URL pattern will catch dashscope.aliyuncs.com, but direct provider name matching won't work. This will cause the test on line 49-60 to fail. - `src/agents/model-compat.ts` needs the missing `"aliyun"` provider check added <sub>Last reviewed commit: 379e0a4</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs