Commit 58d2eae
runtime: thinking-off on force-verdict retry (frees token budget)
When the model emits a prose-only first turn (no XML blocks), the
backend injects FORCE_VERDICT_DIRECTIVE as the next user message
and re-rolls. Until now, both turns ran with enable_thinking=self
._enable_thinking (True for Qwen 3). On RK3588 with Qwen3-1.7B at
max_new_tokens=1500, the retry burns its entire budget inside
<think>...</think> just like the first turn — never reaches the
structured tail. The bridge then emits the synthetic
"Model did not produce a structured verdict" fallback and the
user sees a yellow non-answer.
Lab evidence (anonymized transcript from a 'cannot-join-pool'
session): two `thought` events ("You're running diag/summary..." +
"Analyzing diagnostics...") followed by the synthetic verdict at
T+41s — no tool_call, no real verdict.
Fix: track a per-turn `next_thinking` flag. Default to the
backend-level enable_thinking. When we set
`next_content = FORCE_VERDICT_DIRECTIVE` (both the MAX_TURNS-1
preemptive branch AND the prose-only mid-loop branch), also set
`next_thinking = False`. The retry then runs without thinking, so
all 1500 tokens are available for the ~80-token <verdict> block —
diagnostic context is already in KV cache from prior turns so the
model doesn't need to re-reason, just format the conclusion.
Also gates `output_for_parsing = _strip_think(...)` and the
"Analyzing diagnostics..." marker on `next_thinking` instead of
`self._enable_thinking` so the strip + marker correctly skip when
the retry ran without `<think>` blocks.
New test verifies turn 0 runs thinking ON, turn 1 (force-verdict
retry) runs thinking OFF. All 56 existing tests still pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent aa8799f commit 58d2eae
2 files changed
Lines changed: 77 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1140 | 1140 | | |
1141 | 1141 | | |
1142 | 1142 | | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
1143 | 1153 | | |
1144 | 1154 | | |
1145 | 1155 | | |
| |||
1154 | 1164 | | |
1155 | 1165 | | |
1156 | 1166 | | |
| 1167 | + | |
1157 | 1168 | | |
1158 | 1169 | | |
1159 | 1170 | | |
| |||
1162 | 1173 | | |
1163 | 1174 | | |
1164 | 1175 | | |
1165 | | - | |
| 1176 | + | |
1166 | 1177 | | |
1167 | 1178 | | |
1168 | 1179 | | |
1169 | | - | |
| 1180 | + | |
1170 | 1181 | | |
1171 | 1182 | | |
1172 | 1183 | | |
| |||
1200 | 1211 | | |
1201 | 1212 | | |
1202 | 1213 | | |
1203 | | - | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
1204 | 1217 | | |
1205 | | - | |
| 1218 | + | |
1206 | 1219 | | |
1207 | 1220 | | |
1208 | 1221 | | |
| |||
1223 | 1236 | | |
1224 | 1237 | | |
1225 | 1238 | | |
1226 | | - | |
| 1239 | + | |
1227 | 1240 | | |
1228 | 1241 | | |
1229 | 1242 | | |
| |||
1349 | 1362 | | |
1350 | 1363 | | |
1351 | 1364 | | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
1352 | 1371 | | |
1353 | 1372 | | |
1354 | 1373 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
626 | 626 | | |
627 | 627 | | |
628 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
629 | 682 | | |
630 | 683 | | |
631 | 684 | | |
| |||
0 commit comments