Skip to content

fix(utils): honor loop repeat thresholds above ten - #290

Merged
Zongwei9888 merged 2 commits into
HKUDS:mainfrom
xyi74976-del:fix/configured-loop-repeat-window
Nov 16, 2026
Merged

Zongwei9888 merged 2 commits into
HKUDS:mainfrom
xyi74976-del:fix/configured-loop-repeat-window

Conversation

@xyi74976-del

@xyi74976-del xyi74976-del commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Description

Explicitly configuring LoopDetector(max_repeats=12) never detects a repeated tool call: history is capped at ten entries, so the requested window cannot be reached. Retain at least the configured window while keeping history bounded and preserving the ten-entry floor. The workflow's default threshold is unchanged.

Related Issues

No linked issue. This is separate from the empty status-probe history pollution fixed in #177.

Changes Made

  • Honor explicitly configured repeat thresholds above ten.
  • Test thresholds 5, 10, 12 and 20, status probes, and sequences interrupted by another tool.
  • Add English and Chinese changelog entries.

Validation

Python 3.12 with the official CI lock and editable package:

  • Focused tests: 10 passed; the same tests against the original source: 4 failed, 6 passed.
  • Full suite: 3139 passed, 12 skipped, 1 failed. Remaining failure: tests/test_tui_input_safety.py::test_ctrl_c_clears_a_draft_before_it_interrupts. It also fails after restoring all four changed files to the clean upstream baseline.
  • Added alternating-call histories to verify bounded history and the latest-five summary at default and larger thresholds. A deliberate test-only clipping-removal mutation causes both new cases to fail; the published implementation passes them.
  • Native pre-commit run --all-files --show-diff-on-failure: all six automatic hooks passed; a Go module mirror was needed to install actionlint.
  • uv pip check: installed dependencies compatible.
  • Desktop on Node 24.21.0: 435 tests passed, ESLint, TypeScript, protocol check and Web build passed. An initial Node 26 run failed on undefined localStorage; no frontend changes were made.

Windows/native Desktop and browser end-to-end checks were not run. No live model calls were needed.

Checklist

  • Changes tested locally (full-suite baseline failure disclosed above)
  • Code reviewed (independent read-only AI review)
  • Documentation updated
  • Unit tests added

Additional Notes

Implementation and tests are AI-assisted. The independent review found no blocking code issues; it does not represent human review or upstream CI approval.

@Zongwei9888

Copy link
Copy Markdown
Contributor

Merged on 2026-11-16 as 5673252 ("Merge PR #290"). Thanks for catching this!

You're right that a max_repeats above ten could never trigger, because the history was capped at ten calls, and your parametrized tests show it clearly (the 12 and 20 cases fail on main).

#299 changed the same lines to also compare tool arguments, so we added two commits on top of yours:

We left out the changelog line, since no caller sets a limit above ten yet, so users won't see a change. Both of your commits are kept as you wrote them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants