Recipes

OpenClaw-RL

OpenClaw-RL (arXiv:2603.10165) trains an agent from its use. A judge reads the user's next message as feedback on the agent's last reply.

What it trains#

The served model's weights, while the model serves. The agent uses Reef as its inference endpoint and sends no report. The samples class rebuilds sessions from the recorded traffic. A judge model (the PRM) scores each turn by its next state: a follow-up that moves on is acceptance, a complaint is rejection. The judge also writes hindsight hints. The openclawrl objective combines the rewards with distillation toward the frozen base model that reads an accepted hint.

When to use it#

  • Users' reactions show what they want, and no task checks each attempt.

When a task scores each attempt, use SAO.

Requirements#

  • The Slime GPU environment of Train model weights, as the image docker build -f docker/Dockerfile.reef -t reef-openclawrl ..
  • A judge model on an SGLang server. Reef does not start it; the example's docker-compose.yaml does.
  • Docker and uv on the host.
  • Seven GPUs for the example: four train, and one each for the policy, the judge and the simulated student.

Run the example#

Shell
hf download Qwen/Qwen3-4B-Thinking-2507 --local-dir ~/models/Qwen3-4B-Thinking-2507
hf download Qwen/Qwen3-32B --local-dir ~/models/Qwen3-32B
OPENCLAWRL_USER_LLM_URL=http://<host-ip>:30001 \
OPENCLAWRL_USER_LLM_MODEL=qwen3-32b-user-llm \
bash recipes/openclawrl/examples/openclawrl/run.sh

OpenClaw-RL on Reef runs 72 GSM8K homework sessions of a Hermes agent with a simulated student. Each session's result is in ~/reef-run/lab/trials/gsm8k-sNNN__*/verifier/final.json.

Configuration#

  • The x-reef-tag-session request header: the agent sends one value for each conversation, unique in the scenario. Without it, the stage matches transcripts; identical histories or compaction can break the match.
  • recipe.samples.prm-url and prm-tokenizer-path: the judge. With an empty prm-url the stage rebuilds sessions and trains nothing.
  • recipe.samples: the judge's limits and session-ttl-s (OpenClawRLJudgingSettings).
  • recipe.jobs.job-samples: set it to Slime's global-batch-size.
  • recipe.jobs.prm-record-file: a JSON line of the judged turns for each job.
  • recipe.algorithm: the options of slime/algorithm.py, each the Slime flag openclawrl-<name>. Serving and training use one chat template.

A turn trains when the judge scores it +1 or -1 or accepts a hint. The settings reference describes the other keys.

Results#

  • GSM8K homework stream: one recorded run with Qwen3-4B-Thinking-2507 as the policy and the judge. The agent passed three sessions in a row, the paper's criterion, at session 14, and the rates of bold text and lists fell over the run.

Files#

Text
openclawrl/
  __init__.py            exports the recipe, its stages and settings
  recipe.py              OpenClawRLRecipe: the class of each service
  samples.py             samples: sessions from recorded traffic, the judging of turns, judged turns into samples
  sessions.py            how a session is recognized from the records
  turns.py               what the judging of one turn gets and answers
  prm.py                 one call of the PRM judge
  jobs.py                samples, the data of a job: OpenClawRLJobData (the judged turns of a job, and the PRM record file)
  slime/
    algorithm.py         training service: the openclawrl algorithm and its --openclawrl-* flags
    worker.py            GPU workers: the four worker functions that the class names, the loss as steps
    teacher.py           the frozen Megatron teacher
    selection.py         the selection of the teacher's top-K tensors
    distillation.py      the distillation term: the top-K surrogate, ported from upstream
    vocab_parallel.py    the student's log-probabilities at chosen ids under tensor parallelism
  examples/
    openclawrl/          the GSM8K homework stream with a simulated student

The tests are in tests/recipes/openclawrl/.