-
-
Notifications
You must be signed in to change notification settings - Fork 34
Bounded Loops
Bounded loops give an agent a durable, gate-verified iteration primitive backed by SLM memory. The core invariant: an independent gate decides when the loop is done, never the agent's own claim of completion.
Every lap is persisted to the SLM data root with tag loop:<name>, visible
via slm recall, slm loop history, and the dashboard. Loop history survives
process restarts in the same database as all other SLM memories.
Bounded loops ship on three surfaces:
| Surface | Entry point | Gate mechanism |
|---|---|---|
| CLI | slm loop demo | history | show |
Deterministic (demo only) |
| Plugin command |
/slm-loop (Claude plugin + Codex skill + agent) |
Configurable via command |
| MCP tools |
slm_loop_run / slm_loop_history / slm_loop_show
|
SLM recall query (gate_query) |
The MCP tools are available in the code, full, power, and whole
profiles. See MCP Tools for the full profile reference.
Run one bounded, gate-verified loop to a terminal outcome. Blocks (polling the gate) until the gate passes or a bound is exhausted. Every lap is persisted to SLM memory.
The gate checks whether a memory matching gate_query is retrievable with
confidence >= gate_min_score — making this a safe multi-agent coordination
primitive: one agent waits, under strict bounds, for a memory another agent
will write into shared SLM.
| Parameter | Type | Default | Description |
|---|---|---|---|
name |
str | required | Loop identifier; used as the ledger key and loop:<name> tag |
gate_query |
str | required | SLM recall query; loop converges when a matching memory is found |
gate_min_score |
float | 0.0 |
Minimum relevance score to treat a recall result as passing |
max_iterations |
int | 20 |
Maximum laps before forcing termination (hard cap: 200) |
max_wallclock_s |
float | 15.0 |
Wall-clock budget in seconds (hard cap: 120.0) |
poll_interval_s |
float | 1.0 |
Seconds between gate polls (minimum: 0.25) |
max_tokens |
int | 0 |
Optional token budget (0 = unlimited) |
no_progress_window |
int | 0 |
Laps without change before early-stopping (0 = disabled) |
Returns a dict with ok, status, reason, laps, run_id, and
termination. On internal failure the tool returns ok: False with a
message rather than raising an exception.
List recorded runs for a loop name (read-only).
| Parameter | Type | Default | Description |
|---|---|---|---|
name |
str | required | Loop name to query |
limit |
int | 20 |
Maximum runs to return |
Returns name, runs (list of {run_id, laps, final_status, ts}).
Show every lap of one run (read-only).
| Parameter | Type | Default | Description |
|---|---|---|---|
run_id |
str | required | Run identifier returned by slm_loop_run
|
limit |
int | 200 |
Maximum laps to return |
Returns run_id, name, laps (list of {lap, ts, decision, passed, detail, budget}).
The slm loop command provides read-only inspection and a keyless convergence
demo. It is not a substitute for the MCP slm_loop_run tool; the demo uses a
hardcoded stub proposer.
# Run the convergence demo: gate fails on laps 1-2, passes on lap 3
slm loop demo
slm loop demo --iterations 10 --json
# List recorded runs for a named loop
slm loop history
slm loop history --name my-loop-name --json
# Show every lap of a specific run
slm loop show <run_id>
slm loop show <run_id> --jsonAll subcommands accept --json for agent-native structured output.
Every lap is written to SLM memory with:
-
Tag
loop:<name>— enablesslm recalland dashboard filtering -
Run ID — a stable identifier for
slm loop showandslm_loop_show -
Lap fields — lap number, gate decision (
pass/fail), detail text, token budget
Ledger writes are fail-open: a memory write error is counted and surfaced in the run result rather than aborting a running loop. The gate is the correctness guarantee; the ledger is observability.
One agent writes a memory when its work is verified. A second agent waits
for that memory using slm_loop_run:
# Agent A writes the signal
slm.remember("review complete: PR #42 is approved", tags="review,pr-42")
# Agent B waits for that signal (via MCP)
result = await slm_loop_run(
name="wait-for-pr-review",
gate_query="PR #42 approved",
gate_min_score=0.5,
max_iterations=30,
max_wallclock_s=60.0,
poll_interval_s=2.0,
)Agent B's loop converges as soon as Agent A's memory becomes retrievable with score >= 0.5. Neither agent polls a shared queue or a file; coordination flows through the SLM memory layer that both agents already use.
| Status | Meaning |
|---|---|
converged |
Gate passed; loop reached its goal |
max_iterations |
Hit the iteration limit without convergence |
max_wallclock |
Hit the wall-clock budget without convergence |
max_tokens |
Hit the token budget without convergence |
no_progress |
no_progress_window laps elapsed with no change |
Part of Qualixar | Created by Varun Pratap Bhardwaj
SuperLocalMemory V4.0.3 — Local-first memory with explicit data-path controls. Current docs: Home · Installation · CLI · MCP whole 91 (full 46) · FAQ
Part of Qualixar | Created by Varun Pratap Bhardwaj | GitHub · CHANGELOG
Platform boundary: Apple Silicon macOS · 64-bit Windows · 64-bit Linux — Intel Mac and 32-bit Windows not supported (
cryptography==50.0.0).
SuperLocalMemory V4.0.3
Getting Started
- Installation
- Quick Start Tutorial
- Getting Started
- Modes Explained
- IDE Setup
- Host Integration Upgrades
- Migration from V2
Reference
- CLI Commands
- MCP Tools — 91 whole / 58 power / 46 full / 28 code / 14 core
- Retrieval Score Contract
- Auto-Memory
- Active Memory (V3.1)
Integrations
- Framework Adapters — 9 adapters
- Bounded Loops
- Multi-Agent Memory
Architecture
- Architecture Overview — historical V3, carried into V4
- Capabilities and Operations
- Published Benchmarks — V3 LoCoMo, not a V4 rerun
- Mathematical Foundations — historical V3
-
V4 Reliability Contract — 2,200/2,200, protocol
benchmark/run_all.py --trials 200
Enterprise and Teams
V2 Documentation