← 开源
Human-Agent-Society

reef (在 GitHub 打开)

Infrastructure for continually self‑improving agents

InfrastructureDeploy & ServeOrchestrationPython
增长势头
+124 小时新增 Star+0.0%
7.56k
Star
732
Fork
+-23
本周
50
贡献者
创建于 2026-08-31 · 更新于 2026-12-06 · 今日第 4865 名
主要开发者
README

Infrastructure for continually self‑improving agents

English | 中文

Reef sits between your agent and its model. It records each model call and the feedback on it, such as a test result, a grader score or a user rating.

From that feedback it trains a new version of the model weights or of the agent's harness (its prompts, rules and skills), and serves the version you choose while the agent keeps running.

Who it is for: people who build or study agents and want them to improve from their own use. Train weights on your GPUs with Slime and SGLang or on Tinker, or evolve a harness with only a model API.

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

⚡ See it work in five minutes

You need uv (it downloads Python 3.12 if needed), git-lfs (brew install git-lfs or apt install git-lfs), and an OpenAI API key or Ollama (--model ollama/<model>, no key). No GPU. Start Reef in front of the model:

git lfs install
git clone https://github.com/Human-Agent-Society/reef.git && cd reef
uv venv --python 3.12 && source .venv/bin/activate && uv pip install -e .
export REEF_TOKEN=reef-local REEF_UPSTREAM_API_KEY=sk-...   # your OpenAI key
reef serve --model openai/gpt-4o-mini

In a second terminal, with the same REEF_TOKEN, create a scenario and wait until it serves:

H="Authorization: Bearer $REEF_TOKEN"
curl http://127.0.0.1:8900/reef/scenarios -H "$H" -H "content-type: application/json" -d '{"name": "hello"}'
until curl -fsS http://127.0.0.1:8900/reef/scenarios/hello/inference/status -H "$H" | grep -q '"state": "ready"'
do sleep 1; done

If the wait does not end, run the status request alone: with "state": "failed", error says why.

Call the model through Reef. The command shows the response and keeps its header x-reef-agent-record-id, the receipt of the call, in RECEIPT:

RECEIPT=$(curl -sS -i http://127.0.0.1:8900/v1/chat/completions -H "$H" -H "x-reef-scenario: hello" \
  -H "content-type: application/json" -d '{"model": "active", "messages": [{"role": "user", "content": "Hi"}]}' \
  | tee /dev/stderr | awk 'tolower($1) == "x-reef-agent-record-id:" {print $2}' | tr -d '\r')

Report on the call with its receipt, and read what Reef recorded:

curl http://127.0.0.1:8900/reef/report -H "$H" -H "x-reef-scenario: hello" \
  -H "content-type: application/json" -d "{\"score\": 1.0, \"references\": [\"$RECEIPT\"]}"
curl http://127.0.0.1:8900/reef/scenarios/hello/records -H "$H"

You see two records: the call, and your report linked to it by the receipt. The scenario mounts no recipe, so Reef trains nothing yet. Quickstart explains each step; to train, continue with Use Reef.

📰 News

  • 2026-11: We are refactoring Reef to a control plane + workers architecture. Some recipes and examples can fail on main until the refactor is complete. If a recipe fails, please open an issue.
  • 2026-11: A scenario can split its traffic across its served artifacts #1227, also through Semantic Router #859. The new python harness adapter evolves a Python program #1242.
  • 2026-10: Tinker runs as a training component #901. Episodes and agents can run in Modal Sandboxes #942. The artifact repository can live on Hugging Face #1003. New recipe: OPD #683.
  • 2026-09: reef-infra v0.1.0 is on PyPI. New recipes: GEPA, SDFT, SDPO and Meta-Harness. Reef serves the OpenAI Responses API at /v1/responses #528.
  • 2026-08: Reef is open source. Read the launch post.

🎯 When to use Reef

Use Reef when you want your agent to keep improving from the way people use it.

Your goal Learning path What you need
A model that keeps getting better at your work Model weight training A trainable model, a supported GPU stack or Tinker, and feedback your recipe can use
A harness that improves itself Harness optimization A model endpoint, representative tasks and an evaluator; no training GPUs
Scientific discovery 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

Each learning cycle has four steps:

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 artifacts and checkpoints need the git-lfs system package. Reef initializes Git LFS for its artifact repositories.

We recommend uv. The commands below use it.

From source

Install Reef from a checkout. The docs and the examples below run the recipes of the checkout. uv downloads Python 3.12 if the host does not have it.

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

Activate the environment (source .venv/bin/activate) in each new terminal that runs reef or python. To train weights with Slime, use the Reef GPU image.

From PyPI

The PyPI release predates these docs, and has no recipes or examples.

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

🔧 Using Reef

To train, Reef reads two more files. The deployment file (serve.yaml) says what Reef runs: the model, the training backend and the storage. The recipe file (recipe.yaml) says how one scenario learns, and you mount it on a scenario while Reef runs. How Reef works explains these ideas in five minutes.

The smallest example is the minimal recipe, in recipes/minimal/examples/slime/serve.yaml and recipe.yaml. On two GPUs, in the Reef GPU image, start the deployment. REEF_MINIMAL_STATE_DIR is the directory of its state, logs and checkpoints:

export REEF_TOKEN=reef-local
export REEF_MINIMAL_STATE_DIR="$PWD/work/minimal"
reef serve -c recipes/minimal/examples/slime/serve.yaml

In a second terminal, when /healthz answers, mount the recipe on the scenario demo:

export REEF_TOKEN=reef-local
curl -f http://127.0.0.1:8900/healthz          # the Reef server is up
reef scenario mount demo recipes/minimal/examples/slime/recipe.yaml

Use Reef runs this example through the whole loop, on two GPUs or with a Tinker key: start Reef, mount the recipe, call the model, report on each run, and see a new version serve.

Evolve a harness instead

To improve a coding agent's skills and rules with a model API and no GPU, use a harness recipe. It keeps the harness as a tree of text files.

Each step edits a copy of the tree from the step's runs, and runs the real agent on tasks to evaluate the candidate. A candidate that wins becomes a version that any client can pull.

Evolve a harness explains the GEPA recipe. Its example evolves the system prompt of a pi agent on AIME problems, and 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 for the deployment's adapter. The files hold no endpoint, key or model: a client writes them where the agent reads them, and points the agent's model at Reef (Connect an agent).

Write the tree outside the agent's project: 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 evolves: model weights or the agent harness. Weight recipes need the GPU training stack. Harness recipes need only a model endpoint.

  • SFT ships with reef-infra. It trains on demonstrations or imported examples, for every task type.
  • The other recipes are in the recipes/ cookbook of this repository, and do not ship in the wheel. The recipe catalog gives the code and example of each.
  • To write your own, start from recipes/minimal/ and read Write a recipe.
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, outside the catalog. Each results page gives its task, evaluation setup, measurements and limits.

📐 Architecture

📖 Learn more

Read How Reef works first. Then 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 continually self-improving agents?

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

🙏 Acknowledgements

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

  • SGLang — high-performance inference
  • slime — model weight training
排名相邻
同类项目

AI Rank iPhone 版

随时追踪 AI 模型榜单

在 App Store 下载