One function

LoopDetector in AgentBudget/agentbudget

The author described this change as fix: correct off-by-one in loop detection threshold. It counts as a record because the check below fails on the code as it stood at 6c29cd949 and passes on 144a2b83e, with nothing else changed between the two runs.

Fix saved2026-03-25
Sharing licenceApache-2.0 · LICENSE
Change size+1 1

What the code was meant to do, written into the code itself as a docstring

Detects when the same tool/model is called repeatedly in a short window.

The change

1616 ]
1717 self._call_log[key].append(now)
1818
19- return len(self._call_log[key]) > self._config.max_repeated_calls
19+ return len(self._call_log[key]) >= self._config.max_repeated_calls
2020
2121 def reset(self) -> None:
2222 """Clear all recorded calls."""

The check that tells the two apart

failpass·tests/test_circuit_breaker.py::test_loop_detector_detects_loop

Check file tests/test_circuit_breaker.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it6c29cd9495ea354cf29dc0332aad3dd94ec98370
Broken version dated2026-03-15
Moduleagentbudget.circuit_breaker
Units changedLoopDetector
Fingerprint97099d96993bd0a3
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in AgentBudget/agentbudget