#11297: fix: add thinkingFormat 'qwen' compat for bailian/dashscope providers
agents
stale
Cluster:
DashScope/Qwen Role Management
## Summary
- Add `thinkingFormat: "qwen"` to model compat for `bailian` provider and `dashscope.aliyuncs.com` base URLs
- DashScope models (e.g. kimi-k2.5) require `enable_thinking: true` instead of OpenAI-style `reasoning_effort` for thinking/reasoning mode
## Problem
When `reasoning: true` is set for a model using the bailian/dashscope provider, the system sends `reasoning_effort` (OpenAI style) which dashscope doesn't support. This causes API errors that are caught by the role-ordering error handler, resulting in a confusing "Message ordering conflict" error message to the user.
## Fix
In `normalizeModelCompat()`, detect bailian/dashscope providers (by provider name or base URL) and automatically set `thinkingFormat: "qwen"` in the model compat config. This ensures `pi-ai` sends `enable_thinking: true` instead of `reasoning_effort` for these providers, matching the existing pattern for Z.ai compat handling.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This change extends `normalizeModelCompat()` (`src/agents/model-compat.ts`) to treat `bailian`/`dashscope.aliyuncs.com` like Z.ai models for compat normalization, and additionally attempts to set `thinkingFormat: "qwen"` so DashScope models use Qwen-style thinking (`enable_thinking`) instead of OpenAI-style `reasoning_effort`.
The intent fits the existing pattern where provider/baseUrl-specific compat is centralized in `normalizeModelCompat()`, but the current implementation introduces a schema/type mismatch for `thinkingFormat` and an early-return path that can prevent the bailian-specific compat from being applied when users set `supportsDeveloperRole: false` explicitly.
<h3>Confidence Score: 2/5</h3>
- This PR is not safe to merge as-is due to a compat schema/type mismatch and a logic path that can bypass the bailian fix.
- `thinkingFormat` is written into `model.compat` but is not part of `ModelCompatConfig` or the strict Zod `ModelCompatSchema`, which will cause validation failures where schema validation is applied. Additionally, the early return when `supportsDeveloperRole` is explicitly false prevents bailian models from receiving the intended `thinkingFormat` normalization in that configuration.
- src/agents/model-compat.ts; also update src/config/types.models.ts and src/config/zod-schema.core.ts if `thinkingFormat` is intended to be a supported compat key.
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#23711: fix: disable developer role for DashScope/Qwen models (#23575)
by echoVic · 2026-02-22
81.8%
#22741: fix(models): add DashScope/Qwen to normalizeModelCompat developer r...
by lailoo · 2026-02-21
81.0%
#9451: feat(qwen): enable DashScope/Qwen enable_thinking for /think
by sm-yjr · 2026-02-05
78.8%
#23655: fix(model): map developer role to system for Aliyun/Dashscope/Qianf...
by SleuthCo · 2026-02-22
78.2%
#14187: fix: add Moonshot AI to non-standard provider detection
by shad0wca7 · 2026-02-11
74.4%
#13119: fix: add forward-compat for google-antigravity claude-opus-4-6 models
by sdb001 · 2026-02-10
74.1%
#6683: feat(config): add supportsStrictMode compat option for model defini...
by long-pham · 2026-02-01
74.1%
#19384: Auto-reply: allow xhigh for OpenAI-compatible provider aliases
by 0x4007 · 2026-02-17
73.2%
#19020: bugfix(gateway): Handle invalid model provider API config gracefully\…
by funkyjonx · 2026-02-17
72.7%
#10097: fix: add empty thinking blocks to tool call messages when thinking is…
by cyxer000 · 2026-02-06
72.7%