← Back to PRs

#11297: fix: add thinkingFormat 'qwen' compat for bailian/dashscope providers

by AdJIa open 2026-02-07 17:24 View on GitHub →
agents stale
## 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