Commit 3bac95e
[argus] loop_detector: edit-aware reset + raise default thresholds 5/8
Two changes that together stop the loop detector from killing legitimate
render-and-verify iteration. Observed in argus thread ff3c7aa8 (WebGL
minion task on local-qwen): hard-stop fired on the 5th invocation of an
identical render.py verifier command, even though the model had made six
distinct str_replace edits to the artifact between renders. The verifier
*has to* be re-run after each edit — that is the whole point of the
iterate loop — but the hash-based detector treated those reruns as
identical-call repetition.
1. Edit-aware reset (the principled fix). Track per-thread the set of
paths mutated by write_file / str_replace. Before counting a new tool
call's hash, check whether it references any of those mutated paths
(path arg match, or substring match against command / cmd). If it
does, clear that hash from the sliding window and consume the matched
paths from the mutated set. The signal we want to catch is "doing the
same thing in the same state" — an intervening edit means the state
changed, so a re-probe is fresh observation, not a loop. Within-
message edits don't reset their own hash (mutating paths are recorded
*after* the check), so a coupled [str_replace, bash] in one message
only resets a *future* identical bash.
2. Raise defaults: warn 3 -> 5, hard 5 -> 8. Cheap belt-and-suspenders
for cases the edit-aware reset doesn't cover (verifiers that touch
paths the model didn't explicitly edit, model-side noise, etc).
This is a local single-user setup -- token burn from a few extra
wasted iterations is preferable to killing a run one fix away from
completion.
Tests: 8 new cases in TestEditAwareReset covering the render-and-verify
pattern, unrelated-path edits not resetting, single-mutation-consumed-
once semantics, within-message coupling, per-thread isolation, and a
sanity check on the new default thresholds. All 56 loop-detection tests
pass; full backend suite is green modulo unrelated env-layout failures
(/tmp/scripts, /tmp/skills) that also fail on stock argus@743b7f21.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 743b7f2 commit 3bac95e
2 files changed
Lines changed: 245 additions & 4 deletions
File tree
- backend
- packages/harness/deerflow/agents/middlewares
- tests
Lines changed: 83 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
108 | 144 | | |
109 | 145 | | |
110 | 146 | | |
| |||
153 | 189 | | |
154 | 190 | | |
155 | 191 | | |
156 | | - | |
| 192 | + | |
157 | 193 | | |
158 | | - | |
| 194 | + | |
159 | 195 | | |
160 | 196 | | |
161 | 197 | | |
| |||
191 | 227 | | |
192 | 228 | | |
193 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
194 | 235 | | |
195 | 236 | | |
196 | 237 | | |
| |||
209 | 250 | | |
210 | 251 | | |
211 | 252 | | |
| 253 | + | |
212 | 254 | | |
213 | 255 | | |
214 | 256 | | |
| |||
220 | 262 | | |
221 | 263 | | |
222 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
223 | 270 | | |
224 | 271 | | |
225 | 272 | | |
| |||
247 | 294 | | |
248 | 295 | | |
249 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
250 | 316 | | |
251 | 317 | | |
252 | 318 | | |
253 | 319 | | |
254 | 320 | | |
255 | 321 | | |
256 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
257 | 334 | | |
258 | 335 | | |
259 | 336 | | |
| |||
393 | 470 | | |
394 | 471 | | |
395 | 472 | | |
| 473 | + | |
396 | 474 | | |
397 | 475 | | |
398 | 476 | | |
399 | 477 | | |
| 478 | + | |
400 | 479 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
684 | 684 | | |
685 | 685 | | |
686 | 686 | | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 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 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 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 | + | |
0 commit comments