reef README

项目的 README,来自 github.com/Human-Agent-Society/reef。合并为一个 markdown 文件:README.md。

Reef

Infrastructure for continually self‑improving agents

CI PyPI package: reef-infra Python License

Human-Agent-Society%2Freef | Trendshift

English | 中文

Reef is the first open-source infrastructure for continual self-improving agents. It connects agent inference, feedback, learning, and versioned delivery. Use it to train model weights with Slime and SGLang, or improve an agent's harness, including its prompts, rules, and skills.

🚀 Get started | 🗺️ Roadmap | 🗓️ Office Hours | 📣 Launch post | 💬 Join Discord | 📱 Join WeChat Group

📰 News

🎯 When to use Reef

Use Reef when you want your agent to keep improving simply by learning from how you interact with your agent.

Your goal Learning path What you need
Keep getting stronger model designed for you Model weight training A trainable model, a supported GPU stack, and feedback your recipe can use
Get your harness to self-improve Harness optimization A model endpoint, representative tasks, and an evaluator; no local training GPUs
Scientific discoveries Test-time training An execution environment, a correctness checker, and a measurable objective

🧩 How Reef fits your stack

Ability Inference engine (vLLM, SGLang, …) RL training framework (Slime, veRL, AReaL, …) Reef
Serves live traffic ✅ ❌ ✅
Trains weights ❌ ✅ ✅
Version management ❌ ❌ ✅
Stays live through updates ❌ ❌ ✅
Evolves beyond weights (skills, harness) ❌ ❌ ✅

🔄 How it works

The loop of Reef: inference serves requests and records them with their feedback; sample turns reports into training samples; train makes new weights or a new harness; evaluate decides whether the new version serves.

Reef processes each learning cycle in four steps. The table also shows which modules implement each step.

Step What happens Where it lives
1 · Inference Serve agent requests and record each call and its feedback. api/ — agent requests and interaction records
inference/ — inference and artifact updates
2 · Sample Turn reports and the calls they reference into training samples. storage/scenario/records.py — stored interactions and feedback
samples/ — feedback matching, eligibility, and samples
3 · Train Train new weights or a new harness from the samples. recipe/ — recipe integration
train/ — the training pipeline, job data, and training jobs
4 · Evaluate Decide whether the new version serves, and keep every version. evaluation/ — candidate evaluation
artifact/ — version history and snapshot components

📦 Installation

💡 Note

Reef's artifact and checkpoint functionality requires the git-lfs system package. Reef initializes Git LFS locally for its artifact repositories.

We recommend uv for managing packages, and the commands below use it.

From PyPI

uv venv && source .venv/bin/activate
uv pip install reef-infra
python3 -c "import reef; print(reef.__version__)"

From source

git lfs install
git clone https://github.com/Human-Agent-Society/reef.git
cd reef
uv venv && source .venv/bin/activate
uv pip install -e .
python3 -c "import reef; print(reef.__version__)"

Use the source checkout for development and for the training examples below.

🔧 Using Reef

Reef supports two learning surfaces: model weights and agent harnesses. The deployment's recipe determines which surface its scenarios update.

As a minimal example, start Reef as a pure inference server. This needs SGLang and GPU-enabled PyTorch in the environment:

reef serve --inference.model-path Qwen/Qwen2.5-1.5B-Instruct

Weight-training deployment

Start the deployment

The following example starts the SAO (arXiv:2607.07508) example deployment. Run it from a Reef checkout in an environment that satisfies the GPU requirements in Evolve your model.

uv pip install -e ".[slime]" && uv pip install --no-deps --group runtime

export MODEL_PATH="Qwen/Qwen2.5-1.5B-Instruct"
export REEF_TOKEN="reef-local"

reef serve -c recipes/sao/examples/imo_answerbench/serve.yaml \
  --inference.model-path "$MODEL_PATH" \
  --reef.port "8900"

curl -f http://127.0.0.1:8900/healthz          # the Reef server is up

Send an inference request and report feedback

Send inference requests through Reef and report a score for each response. The SAO recipe uses each eligible scored rollout to run a training step.

Reef's inference endpoint is OpenAI- and Anthropic-compatible: /v1/chat/completions, /v1/responses and /v1/messages take the provider's own request body. A request includes the x-reef-scenario header. Inference requests do not create scenarios or select recipes. Create the scenario with POST /reef/scenarios; it uses the deployment's configured recipe. Then wait until GET /reef/scenarios/{scenario}/inference/status reports ready.

The response body uses the provider's OpenAI-compatible format. Reef adds the x-reef-agent-record-id response header. Its value is the receipt that a later report uses to identify this interaction. A report can contain a numeric score, textual or structured feedback, and the receipts it evaluates. This example reports both a score and a short explanation.

import os
import time

import httpx

scenario = "hello-reef"
reef = httpx.Client(
    base_url="http://127.0.0.1:8900",
    headers={"Authorization": f"Bearer {os.environ['REEF_TOKEN']}", "x-reef-scenario": scenario},
    timeout=300,
)

# Create the scenario; a repeated request returns the existing scenario
reef.post("/reef/scenarios", json={"name": scenario}).raise_for_status()

# Wait until inference is ready for the scenario
deadline = time.monotonic() + 1800
while True:
    startup = reef.get(f"/reef/scenarios/{scenario}/inference/status")
    startup.raise_for_status()
    status = startup.json()
    if status["state"] == "ready":
        break
    if status["state"] == "failed":
        raise RuntimeError(f"Inference startup failed: {status['error']}")
    if time.monotonic() > deadline:
        raise TimeoutError(f"Inference is still {status['state']} after 30 minutes; read the Reef logs")
    time.sleep(1)

# Send a provider-compatible inference request
response = reef.post(
    "/v1/chat/completions",
    json={
        "model": os.environ["MODEL_PATH"],
        "messages": [{"role": "user", "content": "Return exactly: reef is ready"}],
    },
)

response.raise_for_status()
receipt = response.headers["x-reef-agent-record-id"]
answer = response.json()["choices"][0]["message"]["content"]

# Sending report about the inference
matched = answer.strip() == "reef is ready"

reef.post(
    "/reef/report",
    json={"score": float(matched), "feedback": "matched" if matched else "wrong answer", "references": [receipt]},
).raise_for_status()

feedback carries the richer signal, plain text or a structured object, for recipes that read more than a scalar. The endpoint will validate the report schema (reef/core/reports/).

Watch it learn and grow

Once the recipe has enough feedback, Reef submits a training job to the training component. When a checkpoint that the job saved passes evaluation, the inference runtime loads it as the new snapshot. Later inference requests use the current version without restarting Reef.

Harness-evolving deployment

Evolve a coding agent's skills and rules from scored feedback, using a model API instead of GPUs.

A harness recipe keeps the agent's harness as a tree of text files. At each step, the recipe's method edits a copy of that tree from the step's runs, the evaluation runs the real agent on tasks with the candidate, and a candidate that wins publishes as a version that any client can pull. Evolve a harness goes through the four classes of one recipe, GEPA. Its example evolves the system prompt of a pi agent on AIME problems. It needs the pi harness and an OpenAI API key:

cd recipes/gepa/examples/aime
uv pip install -e .
REEF_PI_BINARY=/path/to/pi ./run.sh --dry-run
export OPENAI_API_KEY=...
REEF_PI_BINARY=/path/to/pi ./run.sh

The dry run checks the pi version and the pinned AIME splits, and makes no model calls. The example's README describes the run and its output.

GET /reef/harness serves the published tree, rendered for the deployment's adapter. The files carry no endpoint, key, or model: a client writes them where the agent reads them and binds the agent's model to this Reef (see Connect an agent). Write the tree outside the project the agent works in: a session can write files in its project, so a tree there could change what the next session runs.

📚 Recipes and examples

Pick a recipe by the task type of your workload and by what it should evolve, model weights or the agent harness. Weight recipes need the GPU training stack, while harness recipes need only a model endpoint. Each recipe below links to its guide and each measured benchmark links to its results page, and the recipe catalog adds the code and example for every recipe. SFT ships with reef-infra and trains on demonstrations or imported examples for every task type. The other implementations live in this repository's recipes/ cookbook, selected by dotted class reference and not shipped in the Reef wheel.

To write your own recipe, see Write a recipe. recipes/minimal/ is the smallest complete recipe to start from.

Task type Task shape Evolves the model Evolves the harness Standard benchmarks
Open-ended discovery Repeated attempts at one hard problem with a measurable objective and no known answer TTT-Discover, Guidance-TTT None yet Measured: TriMul, circle packing, Erdős minimum overlap.
Offline tasks with a known answer Independent tasks from a fixed set, each with a reference answer SAO, SDFT, SDPO, OPD GEPA, Meta-Harness Measured: IMOAnswerBench, AIME 2024, AIME 2025, SciKnowEval, ToolAlpaca, Terminal-Bench.
Online learning from usage Sessions with a user, where the interaction itself is the signal OpenClaw-RL ACE, ReasoningBank Measured: GSM8K with a simulated student user.

recipes/basic/ is the record-only starting stack and stays outside the catalog. For a small walkthrough of feedback, candidate edits, and publication, start with Evolve a harness. Each result page documents its task, evaluation setup, measurements, and limitations.

📐 Architecture

Reef architecture: your agent calls the model through Reef inference, which records each call, and reports each run. The four classes of a recipe learn from them: the report type checks each report, the samples class turns reports and calls into samples and a job, the algorithm trains the job, and the evaluation accepts the candidate as the new version or keeps the current one serving.

📖 Learn more

Six guides cover Reef from the first call to production:

  1. Use Reef: one workload through the whole loop, from a model call to a trained version that serves.
  2. Write a recipe: define your own training method as four classes, each with a base class that says what to implement.
  3. Evolve a model: the four classes of a weight recipe, with SDFT.
  4. Evolve a harness: the four classes of a harness recipe, with GEPA.
  5. Connect an agent: any OpenAI-compatible client, the Python client, or a coding agent such as Claude Code, Codex, OpenCode or pi.
  6. Run Reef in production: PostgreSQL, your GPUs or Tinker, sandboxes on E2B or Modal, and the interfaces that you can replace.

To look something up, use the recipes, the services, the HTTP API, the configuration and the glossary.

🤝 Community & Contributing

Working on continual self-improving agent?

If Reef looks useful to you, please give it a ⭐ — it helps the community to discover and contribute to the project.

📚 Citation

If you use Reef in your research, please cite:

@misc{reef2026,
  title  = {Reef: Infrastructure for Continually Self-Improving Agents},
  author = {{Reef Contributors}},
  year   = {2026},
  url    = {https://github.com/Human-Agent-Society/reef}
}

Citation metadata is also available in CITATION.cff.

👥 The Team

Reef brings together people exploring how agents can learn from experience and improve over time. The people below help turn that idea into working infrastructure.

This list is non-exhaustive, with team members listed alphabetically by last name:

Wenhao Chai, Shuangrui Ding, Shiyi Zoe Du, Hao He, Haoze He, Chonghe Jiang, Nan Jiang, Xuan Jiang, Xiaochen Li, Paul Liang, Bo Liu, Boyuan Long, Qiuyang Mang, Zhenting Qi, Ao Qu, Mingruo Qu, Yihong Tang, Zhaokai Wang, Xuezhi Yan, Hanfei Yu, Haofei Yu, Simon Yu, Han Zheng, Kaichen Zhou, Zijian Zhou, Jiacheng Zhu, Dingyi Zhuang, Xinkai Zou.

⭐ Star History

Reef Star History Chart

🙏 Acknowledgements

We are particularly grateful to these projects which power important parts of Reef:

reef (Human-Agent-Society/reef)

正在搜索数据库…

7.8K ·GitHub
Reef 是什么?Reef 是一套开源基础设施,用于让智能体持续自我改进。它把智能体推理、反馈收集、学习和带版本的交付串联起来,让智能体随着你与它的互动不断变好。
Reef 是训练框架、服务层,还是两者兼有?两者兼有:Reef 像推理引擎一样为实时智能体流量提供服务,同时还负责训练和版本交付,而普通的推理引擎或强化学习框架单独都做不到这些。
我该怎么安装 Reef 并把部署跑起来?可以从 PyPI 安装,也可以克隆仓库获取源码(训练示例需要源码),使用 uv 管理软件包,然后基于 deployment.yaml 配置文件运行 'reef serve' 启动部署。
运行 Reef 之前需要先装什么?你需要先安装 git-lfs 系统包,用于存储制品和检查点;另外还需要二选一:支持 GPU 环境的可训练模型(用于权重训练),或模型 API 端点和密钥(用于执行框架的自我进化)。
使用 Reef 需要 GPU 吗?只有权重训练路径需要 GPU,并且必须在满足 Slime/SGLang 训练 GPU 要求的环境中运行;执行框架进化类的部署则只需要模型 API,不需要本地训练 GPU。
Reef 是我自己部署,还是托管服务?Reef 是自托管的:你在自己的基础设施上运行 'reef serve',并对外提供兼容 OpenAI 和 Anthropic 的端点('/v1/chat/completions' 和 '/v1/messages'),用于接收智能体流量。
Reef 开箱即带哪些示例方案?仓库自带 recipes/ 示例手册,包括 SAO、OpenClaw-RL、TTT-Discover、CORAL TTT、Guidance-TTT/TTTD、SkillClaw 和 GEPA,涵盖模型权重训练和执行框架技能进化两类。
这和直接运行 vLLM 或 SGLang 有什么区别?vLLM 或 SGLang 这类推理引擎只负责提供服务;Reef 在服务之上还增加了反馈匹配、训练触发、版本管理,以及在更新过程中保持持续在线。
Reef 学到新东西后,我需要重启它吗?不需要。一旦某个方案训练出新权重,或某个候选执行框架技能在评估中胜过当前版本,Reef 就会发布它,之后的请求会自动使用新版本。
我能不训练模型就改进智能体的提示词吗?可以。执行框架进化类的部署通过模型 API 端点来改进提示词、规则和技能,不需要本地训练 GPU。
大小
61 MB
星标
7.8K
时长
3个月
提交 · 90 天