Commit aeab9b0
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>1 parent 8fd4f17 commit aeab9b0
3 files changed
Lines changed: 229 additions & 85 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1040 | 1040 | | |
1041 | 1041 | | |
1042 | 1042 | | |
1043 | | - | |
1044 | | - | |
1045 | | - | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
1046 | 1047 | | |
1047 | 1048 | | |
1048 | 1049 | | |
| |||
1531 | 1532 | | |
1532 | 1533 | | |
1533 | 1534 | | |
| 1535 | + | |
| 1536 | + | |
| 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 | + | |
1534 | 1622 | | |
1535 | 1623 | | |
1536 | 1624 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1003 | 1003 | | |
1004 | 1004 | | |
1005 | 1005 | | |
1006 | | - | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
1011 | 1011 | | |
1012 | 1012 | | |
1013 | | - | |
| 1013 | + | |
1014 | 1014 | | |
1015 | | - | |
1016 | | - | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
| 1015 | + | |
1021 | 1016 | | |
1022 | 1017 | | |
1023 | 1018 | | |
| |||
1029 | 1024 | | |
1030 | 1025 | | |
1031 | 1026 | | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
1032 | 1031 | | |
1033 | 1032 | | |
1034 | 1033 | | |
| |||
3048 | 3047 | | |
3049 | 3048 | | |
3050 | 3049 | | |
3051 | | - | |
| 3050 | + | |
3052 | 3051 | | |
3053 | 3052 | | |
3054 | 3053 | | |
3055 | 3054 | | |
3056 | 3055 | | |
3057 | 3056 | | |
3058 | | - | |
| 3057 | + | |
3059 | 3058 | | |
3060 | 3059 | | |
3061 | 3060 | | |
3062 | | - | |
| 3061 | + | |
| 3062 | + | |
3063 | 3063 | | |
3064 | 3064 | | |
3065 | | - | |
3066 | | - | |
| 3065 | + | |
| 3066 | + | |
| 3067 | + | |
3067 | 3068 | | |
3068 | 3069 | | |
3069 | 3070 | | |
3070 | | - | |
| 3071 | + | |
3071 | 3072 | | |
3072 | 3073 | | |
3073 | 3074 | | |
3074 | | - | |
3075 | | - | |
| 3075 | + | |
| 3076 | + | |
| 3077 | + | |
| 3078 | + | |
3076 | 3079 | | |
3077 | 3080 | | |
3078 | 3081 | | |
3079 | | - | |
| 3082 | + | |
3080 | 3083 | | |
3081 | 3084 | | |
3082 | 3085 | | |
3083 | 3086 | | |
3084 | 3087 | | |
3085 | 3088 | | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
| 3095 | + | |
| 3096 | + | |
| 3097 | + | |
| 3098 | + | |
| 3099 | + | |
| 3100 | + | |
| 3101 | + | |
| 3102 | + | |
| 3103 | + | |
| 3104 | + | |
3086 | 3105 | | |
3087 | 3106 | | |
3088 | 3107 | | |
| |||
3373 | 3392 | | |
3374 | 3393 | | |
3375 | 3394 | | |
3376 | | - | |
| 3395 | + | |
| 3396 | + | |
3377 | 3397 | | |
3378 | 3398 | | |
3379 | 3399 | | |
3380 | | - | |
3381 | | - | |
| 3400 | + | |
| 3401 | + | |
3382 | 3402 | | |
| 3403 | + | |
3383 | 3404 | | |
3384 | 3405 | | |
3385 | 3406 | | |
| |||
0 commit comments