Loop.js 是一个 TypeScript 框架,用于运行代理循环,迭代达成目标,并由独立的验证代理进行裁判,支持磁盘状态下的崩溃安全恢复和内置调度。

Stars

145

7 天增长

暂无数据

Fork 数

2

开放 Issue

20

开源协议

Apache-2.0

最近更新

2026-07-10

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

它引入了严格的“循环工程”模式:代理从不评判自己的工作,每轮使用全新上下文,可通过本地调度器或 Modal 云调度,并带有类型化守卫和退出码。

适合谁使用

  • 构建需要可靠迭代与验证的自主代理的开发者
  • 自动化软件开发任务直到完成的工程师
  • 运行定期维护或监控循环的 DevOps 团队
  • 部署带有成本和超时控制的代理循环的用户

典型使用场景

  • 构建可玩的游戏直到测试通过且正常启动
  • 每日定期生成股票简报或交易审计
  • 保持依赖项更新、更新日志完善或测试覆盖率达标
  • 一次性任务如将 Git 日志总结为文档

项目优势

  • 独立的验证代理防止自我欺骗;只有其判决才能结束循环
  • 每轮使用全新上下文,从磁盘读取记忆,避免膨胀和漂移
  • 内置预算守卫(美元、轮次、超时)以及类型化退出和进程退出码
  • 幂等运行,通过磁盘状态和锁机制实现崩溃安全恢复

使用前须知

  • Beta v0.2,API 在 1.0 前可能变动
  • 需要 Anthropic API 密钥,当前仅支持 Claude Agent SDK 执行器
  • 需要网络访问的任务(如交易)需在用户管理的容器中运行

README 快速开始

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

项目描述

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

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

S40911120
精选
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 与机器学习大语言模型
67
0xwilliamortiz
精选
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 与机器学习大语言模型
577
7-e1even
精选
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 与机器学习大语言模型
218