Loop.js is a TypeScript framework for running agentic loops that iterate toward a goal, with a separate judge agent for verification, crash-safe state on disk, and built-in scheduling.

Stars

145

7-day growth

No data

Forks

2

Open issues

20

License

Apache-2.0

Last updated

2026-07-10

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It introduces a rigorous 'loop engineering' pattern where the agent never judges its own work, uses fresh context each round, and can be scheduled on local schedulers or Modal cloud with typed guards and exit codes.

Who it is for

  • Developers building autonomous agents that need reliable iteration and verification
  • Engineers automating software development tasks until completion
  • DevOps teams running scheduled maintenance or monitoring loops
  • Anyone deploying agent loops with cost and timeout controls

Use cases

  • Building a playable game until tests pass and it boots correctly
  • Scheduled daily generation of stock market briefs or trade audits
  • Keeping dependencies up-to-date, changelogs populated, or test coverage high
  • One-off tasks like summarizing git logs into a document

Strengths

  • Separate verify agent prevents self-deception; only its verdict settles a loop
  • Fresh context each round with memory from disk avoids bloat and drift
  • Built-in budget guards (USD, rounds, timeout) with typed exits and process exit codes
  • Idempotent run, crash-safe resume via disk state and Lock mechanism

Considerations

  • Beta v0.2; pre-1.0 API may change
  • Requires an Anthropic API key and currently only supports Claude Agent SDK executor
  • Network-access tasks (e.g., trading) need to run inside a user‑managed container

README quick start

loop.js

Loop.js is the framework for loop engineering.

You state a goal and what "done" means. The engine runs an agent at it, Round after Round — fresh context every Round, memory read back from disk — until a separate, skeptical judge rules the bar met. Run it from a terminal, schedule it — on your machine or deployed to Modal's cloud — or embed it in a product: same engine, same guarantees.

import { Loop } from "@loop.js/core"

const loop = Loop.define({
  goal: "Build a playable 2D platformer",
  verify: "It builds clean, `bun test` passes, and the game boots to a controllable character",
  limits: { rounds: 20, usd: 10 },
})

const exit = await loop.run().done()
// { settled: true, verdict: { ok: true, reason: "…" } } — the judge said done, not the worker

Loop engineering is designing the system that prompts an agent instead of prompting it turn by turn: a goal, a way to work, a way to verify, a stop discipline — the loop does the iterating. loop.js is that system as a framework: what is loop engineering →

Why loops need a framework

Running an agent in while (true) is one line. Whether that loop ever converges is everything around it — and that is the part loop.js owns:

The painThe machinery
The agent says "done" when it isn'tA separate Verify agent — own session, own (cheaper, if you like) model, read-only by default — judges every Round. Only its verdict settles the Loop; the worker never grades its own homework.
Long sessions bloat and driftEvery Round starts with fresh context and reads its memory back from disk — the worker's own handoff notes. Round 40 starts as fresh as Round 1.
Retries that don't convergeA "not yet" verdict carries a mandatory reason, fed to the next Round. A goal that can never pass settles as an explicit give-up instead of burning the budget.
Money runs awayDeclared guards: total usd (step-granular ledger), rounds, per-Round timeout — and they default tight ($1, 3 Rounds, 5m). Every ending is a typed Exit with its own process exit code.
Crashes, restarts, double triggersAll state lives on disk; loop run is idempotent and resumes from the cursor. The Lock (co

Description

A loop engineering framework — state a Goal; Rounds run until a skeptical, read-only Verify agent settles it.

Related repositories

Similar projects matched by category, topics, and programming language.

S40911120
Featured
S40911120 GitHub avatar

recensa

Recensa is a self-hosted web viewer that indexes Claude Code session transcripts into a local SQLite database, enabling full-text search, replay, and audit of all past agent conversations without uploading data anywhere.

AI & Machine LearningLarge Language Models
67
0xwilliamortiz
Featured
0xwilliamortiz GitHub avatar

openclaude-improved

OpenClaude is an open-source CLI coding agent that runs on any platform and supports a wide range of LLM providers, offering the same tools and workflows as Claude Code.

AI & Machine LearningLarge Language Models
577
7-e1even
Featured
7-e1even GitHub avatar

learn-agent

A collection of notes on building coding agents, derived from the production development of the desktop agent Reina, with each mechanism simplified into a zero-dependency, single-file Node.js demo.

AI & Machine LearningLarge Language Models
218