STACX
STand Alone CompleX — a modular framework for agentic training, evaluation, and reinforcement learning.
Train
GRPO, SFT, DAgger, or on-policy distillation — five SWE recipes plus the installed-scaffold and diffusion lanes.
Evaluate
Run an agent on a Harbor-style benchmark — six built-in benches through one shared eval path.
Integrate
Add a new benchmark environment — Harbor task format in, a runnable STACX example out.
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:
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 — 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.
| Recipe | What it does | Script (4B) |
|---|---|---|
| DAgger | per-turn β-mixture rollin, mixed CE/K3 loss | scripts/train/swe/online_dagger/dagger_4b.sh |
| AggreVaTe | student prefix + forced teacher tail, mixed CE/K3 | scripts/train/swe/online_dagger/aggrevate_4b.sh |
| iter-SFT | offline distillation on saved teacher trajectories | scripts/train/swe/sft/sft_4b.sh |
| GRPO | on-policy RL, reward-only | scripts/train/swe/grpo/grpo_4b.sh |
| OPD | pure reverse-KL vs. the frozen teacher | scripts/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>:
| BENCH | Example dir | BENCH | Example dir |
|---|---|---|---|
swebench | rl_engine/examples/swebench/ | kernel_bench | rl_engine/examples/kernel_bench/ |
terminal_bench | rl_engine/examples/terminal_bench/ | seta | rl_engine/examples/seta/ |
algotune | rl_engine/examples/algotune/ | skyrl | rl_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:
- Convert to Harbor task format — one directory per task, each with
instruction.md,task.toml,environment/Dockerfile, andtests/test.sh. The verifier writes a bare float reward to/logs/verifier/reward.txt. - Add the STACX example — create
rl_engine/examples/<bench>/(anevaluator_config.py+config/+README.md) so the benchmark runs throughshared/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
- Getting StartedInstallation, dependencies, and project structure.
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.