Skip to main content

agentbelt-loop

Detect repeat, cyclic, and stagnation loops in AI agent tool-call sequences — with cross-session pattern learning. Part of the agentbelt suite.

pip install agentbelt-loop

Quickstart

from agentbelt_loop import LoopDetector, LoopPolicy, LoopDetected

detector = LoopDetector(LoopPolicy(max_exact_repeats=3))

detector.record("session-1", tool="search", args={"q": "foo"}, result=result)
try:
    detector.check("session-1")
except LoopDetected as e:
    print(e.kind, e.detail)   # "repeat" | "cycle" | "stagnation" | "known_pattern"

The differentiator: cross-session pattern learning

Once a cyclic shape (e.g. search → rephrase_query → search → rephrase_query) has been confirmed a loop in enough distinct sessions, new sessions matching that shape trip early — after 2 local repeats instead of waiting out the full threshold every time.

What did this actually catch?

print(detector.impact_report())
# 3 loop(s) detected across 5 check(s) (repeat=3)

Breaks down detections by kind, and calls out known_pattern catches specifically since those are the cross-session differentiator in action — loops caught early because another session already proved the shape.

See the suite README for the full concept and how this fits with agentbelt-budget and agentbelt-sampler.

License

MIT

Metadata

Release files for agentbelt-loop 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentbelt-loop 0.1.0
File Size Uploaded Provenance
agentbelt_loop-0.1.0.tar.gz 10.6 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for agentbelt-loop 0.1.0
File Interpreter ABI Platform
agentbelt_loop-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.0 kB

Release files / agentbelt_loop-0.1.0.tar.gz

Download URL agentbelt_loop-0.1.0.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3f7e4e1b6c0a536d417c8095979b05932a9340e7ad9150d9d2462adf55411802
BLAKE2b-256 checksum
How to use checksums
a1747725bb51b24c6781bd36eea68767e4ae3fa394f4ea2b411de6dfe02aa383
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release files / agentbelt_loop-0.1.0-py3-none-any.whl

Download URL agentbelt_loop-0.1.0-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c0efef05161f188afc600b74df521aa403735fc8e53316b2076587d5fa99631
BLAKE2b-256 checksum
How to use checksums
043e6444811b64919d9a7b357c41810b1831baff2f399c65ad7b0c0b6d0b5672
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Security for agentbelt-loop 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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for agentbelt_loop-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page