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.1

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.1
File Size Uploaded Provenance
agentbelt_loop-0.1.1.tar.gz 10.6 kB With provenance Details

Built distribution (wheel)

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

Total release size: 22.0 kB

Release files / agentbelt_loop-0.1.1.tar.gz

Download URL agentbelt_loop-0.1.1.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
44b36df9ab64900eb2a79e8ac3cde5079bb94337a3410c4b79a7acf07c848af0
BLAKE2b-256 checksum
How to use checksums
8449550a2493cfeb62085eb56114872ab3d691317738e6a17e6280b2950f4a5a
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.1-py3-none-any.whl

Download URL agentbelt_loop-0.1.1-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0478dd8231282ce53a7290feda97eb57ec8c26f1f2fc642ec0ed67da3f462986
BLAKE2b-256 checksum
How to use checksums
37f3ba7b27accf61b23d401152317897acef1a239ee715a73cfc83e67a6eb0dd
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.1

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.1.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.1 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