Commit 4ea6b3d
fix(llm): invert reasoning default — unknown models skip think/final tags (nearai#1952)
* fix(llm): invert reasoning default — unknown models skip <think>/<final> injection
When NEAR AI model="auto" resolves server-side to Qwen 3.5, the system
prompt injected <think>/<final> tags because "auto" didn't match any
known native-thinking pattern. This caused empty responses:
1. Qwen 3.5's native thinking puts reasoning in a `reasoning` field
(not `reasoning_content`) — silently dropped due to field name mismatch
2. Content contained only <think> tags or <tool_call> XML, which
clean_response() stripped to empty → "I'm not sure how to respond"
Three fixes:
- Invert the default: new requires_think_final_tags() with empty allowlist
means unknown/alias models get the safe direct-answer prompt
- Add #[serde(alias = "reasoning")] so vLLM's field name is accepted
- Update active_model from API response.model so capability checks
use the resolved model name after the first call
Confirmed via direct API testing against NEAR AI staging with
Qwen/Qwen3.5-122B-A10B.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* remove model alias resolution from nearai_chat
auto should stay as the active model name — no reason to overwrite it
with the resolved model since requires_think_final_tags() returns false
for both "auto" and the resolved name.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix wording: remove native-thinking assumption from direct-answer prompt
The direct-answer prompt is now the default for all models, not just
native-thinking ones. Remove misleading "handled natively" language.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
(cherry picked from commit 0588dd1)1 parent 10fe3e6 commit 4ea6b3d
3 files changed
+229
-85
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1044 | 1044 | | |
1045 | 1045 | | |
1046 | 1046 | | |
1047 | | - | |
1048 | | - | |
1049 | | - | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
1050 | 1051 | | |
1051 | 1052 | | |
1052 | 1053 | | |
| |||
1535 | 1536 | | |
1536 | 1537 | | |
1537 | 1538 | | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
1538 | 1626 | | |
1539 | 1627 | | |
1540 | 1628 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
984 | 984 | | |
985 | 985 | | |
986 | 986 | | |
987 | | - | |
988 | | - | |
989 | | - | |
990 | | - | |
991 | | - | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
992 | 992 | | |
993 | 993 | | |
994 | | - | |
| 994 | + | |
995 | 995 | | |
996 | | - | |
997 | | - | |
998 | | - | |
999 | | - | |
1000 | | - | |
1001 | | - | |
| 996 | + | |
1002 | 997 | | |
1003 | 998 | | |
1004 | 999 | | |
| |||
1010 | 1005 | | |
1011 | 1006 | | |
1012 | 1007 | | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
1013 | 1012 | | |
1014 | 1013 | | |
1015 | 1014 | | |
| |||
3007 | 3006 | | |
3008 | 3007 | | |
3009 | 3008 | | |
3010 | | - | |
| 3009 | + | |
3011 | 3010 | | |
3012 | 3011 | | |
3013 | 3012 | | |
3014 | 3013 | | |
3015 | 3014 | | |
3016 | 3015 | | |
3017 | | - | |
| 3016 | + | |
3018 | 3017 | | |
3019 | 3018 | | |
3020 | 3019 | | |
3021 | | - | |
| 3020 | + | |
| 3021 | + | |
3022 | 3022 | | |
3023 | 3023 | | |
3024 | | - | |
3025 | | - | |
| 3024 | + | |
| 3025 | + | |
| 3026 | + | |
3026 | 3027 | | |
3027 | 3028 | | |
3028 | 3029 | | |
3029 | | - | |
| 3030 | + | |
3030 | 3031 | | |
3031 | 3032 | | |
3032 | 3033 | | |
3033 | | - | |
3034 | | - | |
| 3034 | + | |
| 3035 | + | |
| 3036 | + | |
| 3037 | + | |
3035 | 3038 | | |
3036 | 3039 | | |
3037 | 3040 | | |
3038 | | - | |
| 3041 | + | |
3039 | 3042 | | |
3040 | 3043 | | |
3041 | 3044 | | |
3042 | 3045 | | |
3043 | 3046 | | |
3044 | 3047 | | |
| 3048 | + | |
| 3049 | + | |
| 3050 | + | |
| 3051 | + | |
| 3052 | + | |
| 3053 | + | |
| 3054 | + | |
| 3055 | + | |
| 3056 | + | |
| 3057 | + | |
| 3058 | + | |
| 3059 | + | |
| 3060 | + | |
| 3061 | + | |
| 3062 | + | |
| 3063 | + | |
3045 | 3064 | | |
3046 | 3065 | | |
3047 | 3066 | | |
| |||
3332 | 3351 | | |
3333 | 3352 | | |
3334 | 3353 | | |
3335 | | - | |
| 3354 | + | |
| 3355 | + | |
3336 | 3356 | | |
3337 | 3357 | | |
3338 | 3358 | | |
3339 | | - | |
3340 | | - | |
| 3359 | + | |
| 3360 | + | |
3341 | 3361 | | |
| 3362 | + | |
3342 | 3363 | | |
3343 | 3364 | | |
3344 | 3365 | | |
| |||
0 commit comments