Repository navigation
Commit 2ce7b0c
fix(core): harden xml tool-call recovery against borrowed closers and lexer cost
Three review findings on the recovery path:
1. A block whose parameter was never closed borrowed the close tags of a
later block. PARAMETER_PATTERN consumed them, the residual-tag guard saw
an empty string, and the truncated call was dispatched with the next
call's raw markup as a parameter value while the real call never ran and
remainingText came back empty. Count the parameter open tags a block body
contains against the ones the accepted matches closed, and reject on
mismatch. A rejected block may have swallowed an intact later block, so
rescan from just after its open tag; that block is then recovered on its
own merits (still skipped when it sits in a fence or an example).
2. The markdown lexer ran over the whole response for every recovery
candidate even when the text contained no example tag at all, and it is
super-linear on unterminated link/emphasis runs: 4 KB of repeated link
openers cost ~3.0 s of synchronous work before the intent-ratio guard.
Skip the lexer when no example tag can produce a range, and catch a lexer
throw so it degrades to "no example ranges" instead of aborting the turn.
3. Parameter spans were recorded only for accepted blocks, so a rejected
block's parameter data was never masked out of the prose the example scan
reads; a literal example opener in it swallowed a later valid call.
Derive the spans from the raw parameter matches over the whole text.
Co-authored-by: Qwen-Coder <[email protected]>
Patrol-Run: qwen-pr-closeout/jmuv5xnpc3q1 parent 2a064ee commit 2ce7b0c
2 files changed
Lines changed: 221 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
706 | 707 | | |
707 | 708 | | |
708 | 709 | | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | 710 | | |
713 | 711 | | |
714 | 712 | | |
| |||
720 | 718 | | |
721 | 719 | | |
722 | 720 | | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
723 | 759 | | |
724 | 760 | | |
725 | 761 | | |
| |||
744 | 780 | | |
745 | 781 | | |
746 | 782 | | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
127 | 131 | | |
128 | 132 | | |
129 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
130 | 141 | | |
131 | 142 | | |
132 | 143 | | |
| |||
152 | 163 | | |
153 | 164 | | |
154 | 165 | | |
155 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
156 | 173 | | |
157 | 174 | | |
158 | 175 | | |
| |||
192 | 209 | | |
193 | 210 | | |
194 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
195 | 217 | | |
196 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
197 | 226 | | |
| 227 | + | |
198 | 228 | | |
199 | 229 | | |
200 | 230 | | |
201 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
202 | 235 | | |
203 | 236 | | |
| 237 | + | |
204 | 238 | | |
205 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
206 | 242 | | |
207 | 243 | | |
208 | | - | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
209 | 248 | | |
| 249 | + | |
210 | 250 | | |
211 | 251 | | |
212 | 252 | | |
| |||
215 | 255 | | |
216 | 256 | | |
217 | 257 | | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | 258 | | |
226 | 259 | | |
227 | 260 | | |
228 | 261 | | |
229 | 262 | | |
230 | 263 | | |
231 | 264 | | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | 265 | | |
237 | 266 | | |
238 | 267 | | |
| |||
242 | 271 | | |
243 | 272 | | |
244 | 273 | | |
245 | | - | |
246 | 274 | | |
247 | 275 | | |
248 | 276 | | |
| |||
0 commit comments