Repository navigation
fix(utils): stop should_abort() from polluting LoopDetector history - #177
Merged
Merged
Conversation
should_abort() probed the detector with check_tool_call(''), which
unconditionally appended the empty name to tool_history despite the
'Check without adding to history' comment. The implementation workflow
calls should_abort() once per iteration, so five consecutive iterations
left the history as five identical '' entries and the repeat check fired
a bogus abort:
Loop detected: called 5 times consecutively
killing healthy runs — precisely during the tool-less iterations the
workflow's no-tool-call guidance is meant to recover from. The stray ''
entries could also break up runs of identical real tool names, weakening
genuine loop detection via the same path.
Skip the history append for empty probe names, report the actual
repeated tool in the loop message, and add regression tests covering
both the false abort and genuine loop detection.
Zongwei9888
approved these changes
Aug 12, 2026
Zongwei9888
left a comment
Contributor
There was a problem hiding this comment.
Thank you for the focused loop-detector fix and regression coverage. I reproduced both the false-positive history pollution and the masking of genuine repeated tool calls, reviewed the probe behavior, and verified the updated branch with the complete remote CI matrix. All checks are green.
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
LoopDetector.should_abort()probes the detector without intending to record anything:but
check_tool_callunconditionally appends the tool name — so every probe appends""totool_history, contradicting the comment. The implementation workflow callsshould_abort()once per iteration (workflows/code_implementation_workflow.py:860), so after 5 consecutive iterations the lastmax_repeatshistory entries are all""and the repeat check fires:This aborts healthy runs — precisely during the tool-less iterations the workflow's "no tool calls detected" guidance is designed to recover from. Conversely, the stray
""entries interleaved into the history can also break up runs of identical real tool names, so genuine loop detection via the abort path is weakened too (verified:should_abort()returnsFalseright after 5 identical real calls).Fix
Skip the history append for empty probe names, and report the actually-repeated tool (
recent_tools[0]) in the loop message instead of the probe argument:Tests
Added
tests/test_loop_detector.py:should_abort()no longer mutates history or false-triggers after repeated probes (fails on old code)