STACX

STand Alone CompleX — a modular framework for agentic training, evaluation, and reinforcement learning.

What is STACX

STACX (STand Alone CompleX) is a modular framework for agentic training, evaluation, and reinforcement learning. Three engines under one Ray job: roll out an agent, score it in a real sandbox, and train on the scored traces.

Every run — training or eval — follows the same path:

STACX run pipeline A closed loop: a dataset config feeds the rollout scheduler, which dispatches an agent inside a sandbox; a verifier scores the trace into a reward, and the trainer syncs refreshed weights back to the scheduler. Dataset config task jsonl Rollout scheduler TaskScheduler Agent + sandbox rollout + exec Verifier reward score trace Trainer Megatron / FSDP tasks prompt trace reward weight sync → refreshed policy

The rollout loop — tasks fan out to the scheduler, an agent acts inside a sandbox, a verifier turns the trace into a reward, and the trainer syncs refreshed weights back for the next iteration.

Those stages map onto five long-lived components spread across the GPU arrays:

STACX overall framework A continuous loop connecting Data Buffer, Customized Rollout Logic, Environment Engine, Training Backend, and Model Inference Server across GPU arrays. Trainer Pretrain + SFT + RL Rollout + Environment Generation & evaluation Data Buffer Replay & batching Customized Rollout Logic Environment Engine GPU GPU GPU GPU Training Backend Megatron / FSDP Model Inference Server SGLang inference send sample send request send exec result training data send request update weights GPU GPU GPU GPU GPU GPU GPU GPU

STACX overall framework — the Trainer owns pretrain / SFT / RL; the Rollout manager drives generation and evaluation against the Environment engine, with weights synced back over the loop.

The three engines

In practice you set up two things: the sandbox engine (a ROCK service that owns Docker/Podman containers and exposes the rock admin CLI) and the train/eval runtime (the pinned lichangh20/slime-rl:stable Docker image the train and eval drivers run in). Together they carry three responsibilities.

Trainer

rl_engine/trainer/

Declarative algorithm recipes over Megatron-LM (TP/PP/DP/CP) and PyTorch FSDP v2, behind one TrainBackend interface (backends/base.py). Pluggable specializations each define their own compute_loss().

Rollout

rl_engine/rollout/

A task scheduler (rollout/scheduler/) dispatches agents/scaffolds across a resource pool, routes each trace to its verifier/reward, and serves generation through SGLang with in-place weight sync.

Environment

env_engine/

The ROCK sandbox admin (default 127.0.0.1:8080) starts a per-task Docker/Podman container, runs commands and the verifier inside it, and tears it down — all through a sandbox REST API.

Train an agent

The launch scripts under scripts/ encode the model, data, Docker, Ray, SGLang, sandbox, checkpoint, and W&B settings for each recipe — start from one of these rather than calling rl_engine.train directly. Every script auto-detects the repo root and auto-resumes from resume_state.json when re-run with the same config.

In-house SWE agent — five recipes × 4B/8B

The in-house SWE agent (rl_engine/examples/swe_agent/) trains a small student against a frozen Qwen3-Coder-30B teacher on SWE-Gym tasks — training sees every token natively. Five recipes share the same student and eval; each has a _4b and a _8b variant.

RecipeWhat it doesScript (4B)
DAggerper-turn β-mixture rollin, mixed CE/K3 lossscripts/train/swe/online_dagger/dagger_4b.sh
AggreVaTestudent prefix + forced teacher tail, mixed CE/K3scripts/train/swe/online_dagger/aggrevate_4b.sh
iter-SFToffline distillation on saved teacher trajectoriesscripts/train/swe/sft/sft_4b.sh
GRPOon-policy RL, reward-onlyscripts/train/swe/grpo/grpo_4b.sh
OPDpure reverse-KL vs. the frozen teacherscripts/train/swe/opd/opd_4b.sh
export WANDB_KEY=<your-key>
bash scripts/train/swe/grpo/grpo_4b.sh          # swap in dagger / aggrevate / sft / opd; _8b for 8B

Deep dive: scripts/train/swe/QUICKSTART_OPD.md and the repo AGENTS.md runbook; every knob is catalogued in scripts/train/swe/ENV_REFERENCE.md.

Installed-scaffold training

A second lane trains black-box installed scaffolds (OpenHands, Terminus-2) inside Harbor task containers, capturing tokens through a recording proxy. One Ray job rolls out on the train bench, applies an SFT/GRPO update, syncs weights, and periodically evals on the eval bench.

# SFT on SkyRL, eval on SWE-bench (the defaults)
BENCH=skyrl EVAL_BENCH=swebench SCAFFOLD=openhands ALGO=sft \
  bash rl_engine/examples/shared/docker_run_train.sh
# axes: SCAFFOLD=openhands|terminus2   ALGO=sft|grpo

Prerequisite: both benches need their prepare_jsonl + build_images artifacts first (see Evaluate below).

Other training lanes

Retool — tool-calling math GRPO

A multi-turn agent solves DAPO-math problems by emitting Python tool calls executed in a ROCK sandbox, trained with GRPO. rl_engine/examples/retool/

Diffusion RL experimental

Reward-weighted RL for diffusion transformers (DiT, Flux, MMDiT) — SGLang inference, GenEval/CLIP rewards, Megatron backend. Diffusion Recipes → rl_engine/examples/diffusion/

Evaluate a benchmark

Evaluation is four commands: download the Harbor task tree, convert it to a tasks.jsonl, build the per-task Docker images, then run the shared eval script. The eval driver runs inside the runtime image via shared/docker_run_eval.sh and connects to a running SGLang server rather than launching one.

# 1. download the Harbor task tree (public registry; --task-names-file for a subset)
python rl_engine/examples/shared/download_tasks.py swebench-verified@1.0 \
  -o external/harbor-datasets/swebench-verified_1.0
# 2. Harbor task dirs -> tasks.jsonl
python rl_engine/examples/shared/prepare_jsonl.py \
  --tasks-dir external/harbor-datasets/swebench-verified_1.0 \
  --output rl_engine/examples/swebench/config/tasks.jsonl --registry swebench
# 3. build the per-task images
bash rl_engine/examples/shared/build_images.sh rl_engine/examples/swebench/config/tasks.jsonl
# 4. run eval (SCAFFOLD=openhands|terminus2)
BENCH=swebench SCAFFOLD=openhands SGLANG_ROUTER_PORT=9001 \
  bash rl_engine/examples/shared/docker_run_eval.sh

Six benchmarks ship with STACX and run through shared/docker_run_eval.sh with BENCH=<name>:

BENCHExample dirBENCHExample dir
swebenchrl_engine/examples/swebench/kernel_benchrl_engine/examples/kernel_bench/
terminal_benchrl_engine/examples/terminal_bench/setarl_engine/examples/seta/
algotunerl_engine/examples/algotune/skyrlrl_engine/examples/skyrl/

The in-house agents evaluate through the eval-only path of rl_engine.train instead, each with a standalone per-example scripts/eval.sh: the in-house SWE agent (SWE-bench Verified), MLE-Dojo (Kaggle competitions, eval-only), and ReTool (AIME) — rl_engine/examples/{swe_agent,mle_dojo,retool}/. These runs serve the model in-process, so no external SGLang server is needed. See the Rollout Engine and Environment Engine pages for how rollout and sandboxes cooperate during eval.

Integrate a new benchmark

Two steps take a benchmark from raw source to a runnable STACX example:

  1. Convert to Harbor task format — one directory per task, each with instruction.md, task.toml, environment/Dockerfile, and tests/test.sh. The verifier writes a bare float reward to /logs/verifier/reward.txt.
  2. Add the STACX example — create rl_engine/examples/<bench>/ (an evaluator_config.py + config/ + README.md) so the benchmark runs through shared/docker_run_eval.sh. The layout and profile knobs are documented in rl_engine/examples/SKILL.md.

Key invariant: BenchmarkProfile.evaluator_id must equal task_type in config/eval_datasets.yaml. For the sandbox and container plumbing this touches, see Sandbox Management.

Documentation map

Where to go next — grouped the way the sidebar is laid out on every other page.

Overview

Trainer

  • ArchitectureThree layers: orchestration, GPU coordination, model-specific logic.
  • BackendsMegatron-LM and FSDP v2 behind one TrainBackend interface; process groups, weight sync, checkpointing.
  • Algorithm RecipesDeclarative RL/supervised configs — incl. diffusion (DiT/Flux/SD3) training.

Rollout

  • ArchitectureTask-scheduler inference, multi-turn agent rollout, evaluation.
  • Task SchedulerBatch orchestration, scheduling strategies, resource-aware dispatch.
  • Inference BackendSGLang integration, weight sync, evaluator pipeline, GPU memory.

Environment

  • ArchitectureROCK sandbox environments, resource scheduling, sandbox REST API.
  • Sandbox ManagementContainer lifecycle, tool integration, GPU-backed execution.