Reinforcement learning (RL) has emerged as a critical phase in the post-training pipeline of large language models (LLMs). As the frontier of LLM capabilities shifts from static reasoning to agentic tasks--characterized by external tool invocation, multi-turn interactions, and long-horizon decision-making--existing mainstream RL frameworks have grown increasingly unwieldy, raising the overhead of adoption, usage, and debugging. To address these challenges, we present LoongSage, an agent-native, fully asynchronous RL framework with a lightweight core of roughly 14K lines of code. Built upon Megatron for distributed training and SGLang for high-throughput inference, LoongSage centralizes orchestration within a single controller process and encapsulates all GPU-resident components as Ray actors. It introduces AgentFlow, a unified execution paradigm that orchestrates both white-box and black-box agents. For asynchronous execution, it integrates sliding-window strategies that bound trajectory staleness, and employs TransferMesh, a topology-aware synchronization mechanism that routes weights after each step over the fastest transport available to each receiver. Beyond agentic RL, LoongSage incorporates a memory-efficient Teacher Manager that decouples the scaling of teacher models from GPU memory constraints, natively supporting Multi-Teacher On-Policy Distillation. Extensive evaluations across four complete training runs, spanning complex reinforcement learning and multi-teacher distillation, demonstrate that task rewards improve steadily while the train-inference gap is kept under continuous control, and the fully asynchronous pipeline removes synchronous idle bubbles, sustaining hardware utilization.
Figures & tables
Figure 1: Positioning of LoongSage relative to closely related systems. Each entry is compiled from the publicly available documentation of the corresponding project at the time of writing. A dash indicates a capability that is not documented, rather than one that cannot be realized within the system.
Figure 2: Overall system architecture of LoongSage.
Figure 3: The two orthogonal configuration axes behind LoongSage’s operational modes, their trade-offs, and the combination that the framework does not support.
Figure 4: The AgentFlow request path. The Router intercepts each Chat Completions request, tokenizes the turn, dispatches it to SGLang’s /generate , and records the returned tokens per turn in the TrajectoryStore .
Figure 5: Data representation under TITO: a single flattened token array with its position-aligned response-space arrays, referenced by Segment and Triplet indices rather than copied.
Figure 6: AgentFlow stores a black-box trajectory as a tree of segments: trainable mainline segments ( origin=root or compact ) own the flat token arrays, while a collab_spawn request forks a non-trainable subagent placeholder ( origin=subagent ).
Figure 7: The protocol adapter normalizes each agent’s wire format into one internal request: OpenCode over Chat Completions, Codex over OpenAI Responses, and Claude Code over Anthropic Messages. A single parser, tokenizer, and SGLang path then serve all of them.
Figure 8: The fully asynchronous pipeline’s control points reduce to two gates—a dispatch gate and a collection gate. Table 1 lists the mathematical bounds each registered policy places on them.
Bound at the control point
Resulting guarantee
Strategy
Dispatch
Collection
Staleness
Training order
no-window
F+Q≤W
unconstrained
unbounded
unconstrained
window-gated
s≤smin+W
unconstrained
≤S steps
unconstrained
windowed-fifo
F+Q≤W
s−smin<B
indirect
FIFO within B
Table 1: The bounds imposed by each sliding-window strategy at the two control points of the asynchronous runtime, and the guarantees they provide. window-gated inherits the capacity bound of no-window in addition to the sequence-number bound listed here.
Figure 9: The three registered sliding-window policies (a) no-window , (b) window-gated , and (c) windowed-fifo on a shared timeline of dispatched groups (bounds in Table 1 , consequences discussed above).
Figure 10: TransferMesh packs the named tensor stream into one contiguous memory bucket described by a single metadata frame, then dynamically selects a transport protocol per receiver based on device topology: utilizing a zero-copy CUDA IPC handle for colocated engines and an NCCL broadcast for remote receivers.
Figure 11: The Teacher Manager schedules teacher groups that share a GPU-memory slot, offloading inactive teacher weights to host memory and swapping them back on demand.
Figure 12: Full-vocabulary distillation via micro-batch logit reconstruction: within each micro-batch the teacher logits are rebuilt from hidden states, consumed by the loss, and released before the next micro-batch begins.
Figure 13: Train–inference consistency is handled in three groups: source alignment guarantees the trained sequence mathematically matches the sampled sequence, long-context and precision settings anchor numerical stability, and residual corrections continuously bound the remaining gap.
Registry
Configuration field
Scope
agent
data_source.agent.name
Agent loop
reward
data_source.reward.name
Reward computation
sandbox
data_source.sandbox.type
Execution environment
advantage
algorithm.advantage_estimator
Advantage estimation
policy_loss
algorithm.policy_loss
Policy loss
kl_policy
opd.{pg,gkd}_kl_method
KL constraint and estimator
Table 2: The core registries exposed by LoongSage. Each is invoked via a @register_<name> decorator at the definition site and bound to the corresponding configuration field. Fields lacking a top-level section ( agent , reward , dataset.* ) are resolved relative to the specific data_source . The kl_policy row abbreviates opd.pg_kl_method and opd.gkd_kl_method .
Setting
Model
Hardware
Focus
Training runs, one complete run each
SWE
DeepSeek-V4-Flash
8 H20 nodes
Long-horizon software tasks
DAPO
DeepSeek-V4-Flash
6 H20 nodes
Verifiable mathematical reasoning
OpenCode
Qwen3-Coder-30B-A3B
4 H20 nodes
Black-box coding agent
MOPD
Qwen3-30B-A3B
1 H20 node
Multi-teacher distillation
Controlled comparisons between configurations
Table 3: The runs reported in this paper.
Figure 14: Training curves for DeepSeek-V4-Flash on SWE tasks.
Figure 15: Training curves for DeepSeek-V4-Flash on DAPO mathematical reasoning.
Figure 16: Training curves for full-vocabulary multi-teacher MOPD on Qwen3-30B-A3B.
Figure 17: Training curves for Qwen3-Coder-30B-A3B with the OpenCode black-box agent.
all 100 steps
excluding step 0
Configuration
Split
avg (s)
speedup
avg (s)
speedup
Colocated
16
580.79
1.00 ×
578.63
1.00 ×
Colocated + partial rollout
16
489.63
1.19 ×
486.34
1.19 ×
Async, no-window , S=1.0
8:8
454.50
1.28 ×
451.74
1.28 ×
Async, windowed-fifo , S=1.0
8:8
434.76
1.34 ×
424.30
1.36 ×
Async, windowed-fifo , S=2.0
8:8
428.76
1.35 ×
414.58
1.40 ×
Table 4: Average step time under colocated and fully asynchronous execution. Speedups are relative to the colocated baseline in the same column.