Commit c2b99f5
committed
fix(openrouter): add JSON recovery for kimi-k2 truncation (#367)
- Add attemptJSONParse() function with recovery strategies for truncated JSON
- Attempts to parse as-is, then trims whitespace, then closes incomplete structures
- Handles truncated newline boundaries gracefully
- Remove redundant error-like fallback path (handleResponse already returns {state} for errors)
- Improve logging for schema validation failures
- Fixes issue where kimi-k2 model breaks due to JSON chunk truncation1 parent a15bfeb commit c2b99f5
1 file changed
+6
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | 19 | | |
22 | 20 | | |
23 | | - | |
24 | 21 | | |
| 22 | + | |
| 23 | + | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| |||
545 | 544 | | |
546 | 545 | | |
547 | 546 | | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
| 547 | + | |
| 548 | + | |
564 | 549 | | |
565 | 550 | | |
566 | 551 | | |
| |||
725 | 710 | | |
726 | 711 | | |
727 | 712 | | |
728 | | - | |
| 713 | + | |
729 | 714 | | |
730 | 715 | | |
731 | 716 | | |
| |||
0 commit comments