展示 HN:20+ 个 Claude 代码代理协同处理实际工作(开源)
Show HN: 20+ Claude Code agents coordinating on real work (open source)

原始链接: https://github.com/mutable-state-inc/lean-collab

## Lean 4 与 Ensue 的协同定理证明 本文档概述了如何使用 Lean 4、Ensue 网络和专用 CLI 工具设置一个用于协同定理证明的多智能体系统。该过程利用 Claude 来协调并行工作以证明定理的智能体。 **设置:** 需要安装带有 Mathlib 的 Lean 4(使用 `elan` 和 `lake`),Rust,并从 [ensue.dev](https://ensue.dev/) 获取 API 密钥。`lean-collab-plugin` 被克隆并构建,以提供 CLI (`./bin/lc`)。配置通过 `.lean-collab.json` 文件完成,该文件指定项目详细信息、API URL 和智能体参数。为了提高性能,一个“预热服务器”(`./bin/lc warm`)至关重要,它可以将 Mathlib 预加载到内存中。 **工作流程:** 该过程从初始化证明会话 (`./bin/lc init`) 和定义定理开始。Claude 使用 `/lean-collab` 技能,然后管理智能体来分解目标、建议策略、验证它们,并最终组合一个完整的证明 (`./bin/lc compose`)。命令如 `./bin/lc claim`、`./bin/lc verify` 和 `./bin/lc decompose` 允许进行交互和控制。 **重要注意事项:** 由于并行智能体,Token 使用量可能很高;建议使用更高费率的 Ensue 帐户。建议监控进度并在智能体循环时手动干预。从较少的智能体开始,并仔细制定定理,可以帮助管理成本并提高效率。

## Claude 代码代理编排 - 摘要 Austinbaggio 开源了一个多代理编排器,用于处理复杂的、长期运行的任务,使用 LLM。它解决了单代理系统经常停滞或产生不正确结果(例如无法编译的代码)的局限性。该系统利用一个编排代理来分解任务,并行子代理来执行,以及一个订阅系统来实时共享进度和发现。 目前构建为 Claude 代码技能,该编排器已在具有挑战性的数学问题(普特南级别)上成功测试,并且适用于代码重构和研究等任务。核心思想是利用“集体智慧”,代理从过去的尝试中学习,在有限的上下文窗口内提高效率。 该项目设计为易于修改,开发者正在寻求关于潜在工作负载的反馈。目前它需要 Ensue 的 API 密钥来管理共享任务状态和订阅,但提供免费层级用于实验。一个关键的讨论点是代理如何处理冲突的目标,以及由于 Claude 代码的限制,系统依赖于轮询来获取更新。
相关文章

原文

Multi-agent collaborative theorem proving with Lean 4 and Ensue Memory Network.

Read the blog post

Install elan (Lean version manager):

curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh

Restart your terminal or source the environment:

Verify installation:

lean --version
lake --version

Lean Project with Mathlib

Your Lean project needs Mathlib. For a new project:

lake new my-project math
cd my-project

Install Mathlib from cache (recommended - saves hours of build time):

Then build:

For existing projects, add to your lakefile.lean:

require mathlib from git "https://github.com/leanprover-community/mathlib4"

Then run:

lake update
lake exe cache get
lake build

Install Rust:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Get an API key from ensue.dev.

1. Clone and Build the CLI

git clone https://github.com/anthropics/lean-collab-plugin
cd lean-collab-plugin
make install

This compiles the Rust CLI and creates ./bin/lc.

2. Configure Ensue Authentication

echo "your-ensue-api-key" > .ensue-key
chmod 600 .ensue-key

3. Configure Local Settings

Create .lean-collab.json in the plugin directory:

{
  "theorem_id": "my-theorem",
  "ensue_api_url": "https://api.ensue-network.ai",
  "max_parallel_agents": 7,
  "max_depth": 12,
  "claim_ttl_seconds": 300,
  "lean_project_root": "/absolute/path/to/your/lean/project"
}
Field Description Default
theorem_id Unique identifier for your proof session Required
ensue_api_url Ensue API endpoint https://api.ensue-network.ai
max_parallel_agents Maximum concurrent worker agents 12
max_depth Maximum proof tree depth 12
claim_ttl_seconds Goal claim timeout in seconds 300
lean_project_root Absolute path to your Lean 4 project Required

Environment variables override config values:

export LEAN_COLLAB_MAX_PARALLEL_AGENTS=6
export LEAN_COLLAB_MAX_DEPTH=8
export LEAN_COLLAB_CLAIM_TTL=600

The CLI uses lake env lean to verify tactics against your Lean project. This requires:

  1. A valid lean_project_root pointing to a Lean 4 project
  2. The project must build successfully with lake build
  3. Mathlib must be installed (use lake exe cache get for speed)
# Initialize and create root goal
./bin/lc init --create-root \
  --theorem "∀ x ∈ [0,π], sin(x) ≥ (2/π)x" \
  --hypotheses "x : ℝ;;hx : x ∈ Set.Icc 0 Real.pi"

# Check proof progress
./bin/lc status                    # Overview of all goals
./bin/lc status <goal_id>          # Details for specific goal

# Stream real-time events
./bin/lc listen --prefix proofs/

# Build final proof when ready
./bin/lc compose
./bin/lc claim <goal_id>                    # Claim a goal for work
./bin/lc unclaim <goal_id>                  # Release a goal
./bin/lc verify --goal <id> --tactic "..."  # Verify a tactic
./bin/lc verify --goal <id> --tactic "..." --skeleton  # Check types only (allows sorry)
./bin/lc decompose <id> --children X,Y --strategy S
./bin/lc backtrack <id>                     # Undo decomposition
./bin/lc abandon <id>                       # Give up on goal
./bin/lc axiomatize <id> --reason "..."     # Accept as axiom (last resort)
./bin/lc search "query" --prefix tactics/   # Search collective intelligence
./bin/lc explore --goal <id> --tactic "..." # Test tactic interactively
./bin/lc suggest --goal <id>                # Get tactic suggestions

Before running Claude, start the warm server in a separate terminal:

cd /path/to/lean-collab-plugin
./bin/lc warm

Keep this terminal open. The warm server:

  • Loads Mathlib into memory once (~20s initial load)
  • Dramatically speeds up tactic verification (~2-5s vs ~20s per verification)
  • Listens on /tmp/lean-warm.sock

Without the warm server, each verification cold-starts Lean and reloads Mathlib, which is very slow.

From the plugin directory (in a new terminal):

claude \
    --plugin-dir /path/to/lean-collab-plugin \
    --allowedTools "Bash,Read,Write,Edit,Task,Glob,Grep" \
    --dangerously-skip-permissions

Once Claude is running, start the collaborative proving process:

Prove that <your theorem statement>.
Use /lean-collab to orchestrate.

Example:

Prove that for all x in [0, pi], sin(x) >= (2/pi)x.
Use /lean-collab to orchestrate.

Claude will:

  1. Initialize the proof session with ./bin/lc init
  2. Spawn parallel worker agents (provers and decomposers)
  3. Coordinate via Ensue until the proof is complete
  4. Compose the final verified Lean proof with ./bin/lc compose

Token Usage Warning: This tool spawns multiple parallel agents and can consume significant API tokens, especially for complex proofs or when running many workers.

Recommendations:

  • Use a Max 20x account - The parallel agent spawning and iterative proving process burns through tokens quickly. A higher rate limit account is strongly recommended.

  • Monitor in a separate window - Although lean-collab has been used to solve several problems autonomously, it helps to have another Claude Code window open with the /lean-collab skill loaded to monitor progress. This lets you intervene if the solving process becomes tedious or gets stuck in unproductive loops.

  • Start with fewer workers - Begin with max_parallel_agents: 3-5 until you're comfortable with token consumption, then scale up.

  • Watch for loops - If agents are repeatedly backtracking on the same goals, consider manually intervening or adjusting your theorem formulation.

Sai Vegasena [email protected]

联系我们 contact @ memedata.com