feat(loop-context): stateful memory manager with pruner + circuit breaker#4
Merged
Merged
Conversation
…aker Adds tools/loop-context — a deterministic, dependency-free manager that sits between an agent loop and its durable memory to prevent the two classic long-run failures: context overflow/rot and stagnant/no-progress loops. Before each iteration it can: - summarize what has been tried (factual rollup, no LLM needed), - prune verbose stack traces, collapse repeated errors, and keep only a recent window of attempts, - inject a compact context block into the next prompt. The circuit breaker escalates to a human on stagnation (same error N× in a row), no-progress (N consecutive failures), token budget, or iteration cap — instead of burning tokens in a hopeless loop. Errors are normalized to a stable signature so "the same error" is recognized across volatile details (line numbers, ports, addresses, temp paths). Ships a CLI (--check/--prune/--inject/--summary/--status, stdin or --ledger) with escalate=exit 2, a library API, 18 tests, and CI gate + build wiring. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Loop Readiness AuditScore: 100/100 (L3) Strong loop readiness — good candidate for L3 with explicit gates. Top suggestions
Posted by |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds tools/loop-context — a deterministic, dependency-free manager that sits between an agent loop and its durable memory to prevent the two classic long-run failures: context overflow/rot and stagnant/no-progress loops.
Before each iteration it can:
The circuit breaker escalates to a human on stagnation (same error N× in a row), no-progress (N consecutive failures), token budget, or iteration cap — instead of burning tokens in a hopeless loop. Errors are normalized to a stable signature so "the same error" is recognized across volatile details (line numbers, ports, addresses, temp paths).
Ships a CLI (--check/--prune/--inject/--summary/--status, stdin or --ledger) with escalate=exit 2, a library API, 18 tests, and CI gate + build wiring.
Summary
Changes
templates/pattern-template.md+ updatedregistry.yaml)Checklist (from CONTRIBUTING)
STATE.md*examples use.examplesuffixdocs/safety.mdnode tools/loop-audit/dist/cli.js .(or on the starter) and addressed findingsTesting / Dogfood
loop-auditpasses on affected starters or this repoScreenshots / Examples (if UI or command output)
This template enforces the high bar this reference is known for.