Commit fec2975
runtime: re-init RKLLM on rc=-1 + restore FULL EXAMPLE w/ anti-mimicry framing
Two model-quality fixes for failures observed in lab transcripts:
1. RKLLM rc=-1 recovery
The native rkllm_run returns -1 when the runtime is in a stuck
state — most commonly after an aborted prior generation leaves
the KV cache in a half-state. Lab 2026-05-28: clicking "Try
again with the same question" reliably hit
`[RKLLM_GENERATE_FAILED] rkllm_run returned -1` at T+0s,
killing the session.
The bridge now catches the rc=-1 case specifically (substring
match on "returned -1" in the error message so other
RKLLMLoadError shapes — timeouts, callback errors, init failures
— bubble unchanged), destroys + re-inits the runtime, and
retries the same generate() call ONCE with keep_history=0
(cache was wiped). If the retry also fails, the bridge emits
the error event AND a synthetic insufficient_data verdict in
the same stream so the app's Try-Again CTA surfaces (raw error
events have no Try-Again gate; only synthetic-verdict
root_causes trigger it).
2. FULL EXAMPLE restored with anti-mimicry framing
Earlier today (c919a1d) the FULL EXAMPLE three-turn flow was
deleted from the system prompt on advisor input — the model was
pattern-copying entire example structures, not just numbers.
Lab transcripts since then show the model producing
unanchored prose (e.g. "# Onboarding\n\nThe Blox app asks you
to name the symptom...") that has zero relation to the user's
request. Net effect of the deletion: the model has even less
format anchoring than before.
Restored a SHAPE-only example that uses uppercase placeholders
(<TOOL_NAME>, <ONE_SENTENCE_FROM_YOUR_DATA>, etc.) and an
explicit "mimic the STRUCTURE, not the words. Do NOT mention
any of the placeholder labels in your output" framing.
Counters the pattern-copy risk by removing memorable content
to copy. Added "Do NOT use markdown headings" to the
FIRST ACTION section since lab transcripts showed the model
emitting `# Onboarding`-style headers despite the existing
"no markdown" rule elsewhere — the closer the rule is to the
first-token directive, the more reliably small models honor it.
Two new unit tests:
- rc=-1 → destroy + re-init + retry succeeds → verdict came
through
- rc=-1 → re-init retry ALSO fails → error event + synthetic
insufficient_data verdict emitted, recoverable=true, Try-Again
button reachable
All 258 existing tests still pass.
Bigger-picture concern (out of scope for this commit, surfaced
to user): Qwen3-1.7B fine-tuned on 174 examples appears to be
overfitting to specific training phrases and falling back to
those phrases on novel inputs. The longer-term fix is either
(a) audit + clean the training set, (b) move to Qwen2.5-3B as
the original plan specified, or (c) drop the fine-tune entirely
and use a more directive system prompt with the stock model.
The user picked this "quick win" path; deeper options remain on
the table.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 8898b0c commit fec2975
2 files changed
Lines changed: 207 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
625 | 625 | | |
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 | + | |
629 | 649 | | |
630 | 650 | | |
631 | 651 | | |
| |||
1183 | 1203 | | |
1184 | 1204 | | |
1185 | 1205 | | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
1190 | | - | |
1191 | | - | |
1192 | | - | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
1193 | 1289 | | |
1194 | 1290 | | |
1195 | 1291 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
586 | 586 | | |
587 | 587 | | |
588 | 588 | | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 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 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
589 | 692 | | |
590 | 693 | | |
591 | 694 | | |
| |||
0 commit comments