Commit b7ab2c8
authored
Fixes #183.
## Problem
Custom providers on OpenAI-compatible gateways (Qwen/DashScope,
DeepSeek, GLM/BigModel, Moonshot, any `openai-chat` wire pointing to a
non-OpenAI baseUrl) returned:
```
400 developer is not one of ['system', 'assistant', 'user', 'tool', 'function']
```
## Root cause
`packages/providers/src/index.ts::synthesizeWireModel` hard-coded
`reasoning: true` on every synthetic `PiModel`. pi-ai's openai-chat /
openai-responses adapters treat `model.reasoning === true` as "this
endpoint supports the Responses API `developer` role" and rewrite the
system prompt role accordingly. `developer` is OpenAI-Responses-only
(GPT-5 / o-family); no third-party OpenAI-compat gateway accepts it.
## Fix
New `inferReasoning(wire, modelId, baseUrl)`:
- `anthropic` -> `true`
- `openai-responses` / `openai-codex-responses` -> `true` (preserves
#134)
- `openai-chat` -> `true` only when baseUrl is `api.openai.com` AND
modelId matches `^(o[134]|gpt-5)` (OpenAI reasoning families)
- otherwise -> `false`
## Coverage
Unblocks every OpenAI-compatible Chinese gateway and any generic
OpenAI-compat endpoint:
- Qwen / DashScope (`dashscope.aliyuncs.com`)
- DeepSeek (`api.deepseek.com`)
- GLM / Zhipu BigModel (`open.bigmodel.cn`)
- Moonshot / Kimi
- Any user-configured LiteLLM / Azure / self-hosted openai-chat gateway
## Tests
`packages/providers/src/index.test.ts` — 9 new `inferReasoning` cases +
1 integration case asserting Qwen DashScope gets `reasoning: false`
through `complete()`.
## Four-principle check (PRINCIPLES §5b)
- Compatibility: green — #134 (openai-responses) + #175 unchanged;
Anthropic unchanged
- Upgradeability: green — central helper; adding new reasoning model
families is a regex edit
- No bloat: green — single helper function, no new file, no new dep
- Elegance: green — intent-revealing name; replaces a hard-coded `true`
with a predicate
## Out of scope
Didn't touch retry / errors / Settings / agent.ts.
Signed-off-by: hqhq1025 <1506751656@qq.com>
1 parent 011b25d commit b7ab2c8
3 files changed
Lines changed: 127 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
283 | 319 | | |
284 | 320 | | |
285 | 321 | | |
| |||
472 | 508 | | |
473 | 509 | | |
474 | 510 | | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
174 | 210 | | |
175 | 211 | | |
176 | 212 | | |
| |||
196 | 232 | | |
197 | 233 | | |
198 | 234 | | |
199 | | - | |
| 235 | + | |
200 | 236 | | |
201 | 237 | | |
202 | 238 | | |
| |||
0 commit comments