agent-loop-breaker-py
Detect repeated agent steps and stop runaway loops. Pure Python, zero deps. Python port of @mukundakatta/agent-loop-breaker.
pip install agent-loop-breaker-py
from agent_loop_breaker import detect_loop, should_stop
events = [{"tool": "search"}, {"tool": "fetch"}] * 4
res = detect_loop(events, window=2, repeat_threshold=3)
# LoopDetection(looping=True, pattern="search>fetch", count=4)
if should_stop(events):
raise RuntimeError("agent stuck in a loop")
API
detect_loop(events, *, window=4, repeat_threshold=3) -> LoopDetection
Scans events for a repeating window of length window. Returns the first window seen repeat_threshold times or more.
Each event is reduced to a signature via event.get("tool") or event.get("name") or event.get("type") (or str(event) for non-dicts).
should_stop(events, *, window=4, repeat_threshold=3) -> bool
Convenience wrapper returning the looping flag.
License
MIT
Metadata
Release files for agent-loop-breaker-py 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agent_loop_breaker_py-0.1.0.tar.gz | 3.4 kB | Without provenance | Details for agent_loop_breaker_py-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agent_loop_breaker_py-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for agent_loop_breaker_py-0.1.0-py3-none-any.whl |
Total release size: 7.0 kB
Release files / agent_loop_breaker_py-0.1.0.tar.gz
| Download URL | agent_loop_breaker_py-0.1.0.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7509be27c80d3fb517398c016e17b624299eaf37ffe7e3771cc6136b163b68e0
|
|
BLAKE2b-256 checksum How to use checksums |
cb2682ee91e22b21b65edb9edb6ba62cf427c71f867bf8e95db0faebf134c91c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / agent_loop_breaker_py-0.1.0-py3-none-any.whl
| Download URL | agent_loop_breaker_py-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c00cfc1c50ef8dc293520ea8b3e9bef63c7ba36f51c1f5c8d984bd9d4e64d339
|
|
BLAKE2b-256 checksum How to use checksums |
220f605dbaea47d810804087883f2764785b05e340d3326ca7816003bb60a392
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Security for agent-loop-breaker-py 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.