GLM-5: from Vibe Coding to Agentic Engineering
TL;DR. GLM-5 is Zhipu’s successor to GLM-4.5. It is a 744B-total / 40B-active MoE with 256 experts and 80 layers. Its sparse attention is DeepSeek-V3.2’s DSA, added through continued training on only 20B adaptation tokens after a 1000-step indexer warm-up. Post-training runs in this order:
- SFT with a 202,752-token context and interleaved thinking;
- Reasoning RL;
- Agentic RL;
- General RL;
- On-policy cross-stage distillation at the end, to recover skills that earlier stages lost.
The agentic RL is fully asynchronous and runs on slime. It relies on a token-in-token-out (TITO) gateway and a simple double-sided importance-sampling mask. All numbers are vendor-reported.
Key idea
Section titled “Key idea”Asynchronous agentic RL without π_old. Rollout and training run on separate GPUs, and weights are pushed to the inference engine every K updates. The optimizer is reset after each push. Three mechanisms keep this stable:
- TITO gateway. It records the exact token IDs the inference engine produced, so the trainer never re-tokenizes text and gets a mismatched action sequence.
- Direct double-sided IS. The ratio uses the stored rollout log-probs. Tokens outside are masked. This is simpler than IcePop because it drops .
- Sample hygiene. A trajectory is dropped if its oldest policy version is staler than τ. Environment-crash failures are removed and their groups padded.
Cross-stage OPD. The final checkpoints of earlier stages act as teachers. The GRPO advantage is replaced with
with group size 1 and batch 1024. A group is unnecessary because the teacher supplies the baseline.
Results and discussion. Table 7, vendor-reported:
| Benchmark | GLM-5 | GLM-4.7 | DeepSeek-V3.2 | Kimi K2.5 | Claude Opus 4.5 | GPT-5.2 (xhigh) |
|---|---|---|---|---|---|---|
| SWE-bench Verified | 77.8 | 73.8 | 73.1 | 76.8 | 80.9 | 80.0 |
| Terminal-Bench 2.0 (Terminus-2) | 56.2 | 41.0 | 39.3 | 50.8 | 59.3 | 54.0 |
| BrowseComp with context management | 75.9 | 67.5 | 67.6 | 74.9 | 57.8 | 65.8 |
| τ²-Bench | 89.7 | 87.4 | 85.3 | 80.2 | 91.6 | 85.5 |
| MCP-Atlas | 67.8 | 52.0 | 62.2 | 63.8 | 65.2 | 68.0 |
Baseline columns are as reported in GLM-5’s table, under its own settings; they can differ from a model’s own report. For example, DeepSeek-V3.2’s τ²-Bench is 85.3 here but 80.3 in DeepSeek-V3.2’s report. Compare scores only within one source and harness.
On a verified Terminal-Bench 2.0 that fixes ambiguous instructions, GLM-5 scores 60.7. GLM-5 still trails Claude Opus 4.5 on SWE-bench. The report also evaluates long-horizon tasks: Vending-Bench 2 and CC-Bench-V2.
Post-training & agentic RL recipe
Section titled “Post-training & agentic RL recipe”- SWE environments. Issue–PR pairs are filtered by rules and LLMs and labeled as bug fix, feature, refactor and so on. A RepoLaunch-based pipeline builds executable environments, and an LLM writes language-aware log parsers that extract F2P and P2P tests. The result is more than 10K verifiable environments across thousands of repositories in 9 languages.
- Terminal environments. Built two ways, both in Harbor format:
- from seed tasks: draft → construction agent → iterative optimization;
- from a web corpus: a coding agent turns a code page into a task and must pass the Harbor validation script itself before the task is admitted.
- Search data. A web knowledge graph is built from more than 2M high-information pages that an early search agent visited. Questions come from multi-hop subgraphs around low- to mid-frequency entities. Three-stage filtering removes:
- questions a tool-free model answers in any of 8 tries;
- questions a basic early agent solves in a few steps;
- questions whose answers are not unique or are inconsistent, found by a bidirectional verification agent.
- Rewards. General RL mixes rule-based rewards, ORMs and GRMs. ORMs are low-variance but hackable; GRMs are more robust but higher-variance. Slides use a 3-level reward (static markup, runtime rendering, visual), plus rejection sampling and masking of defective pages.
- Asynchronous RL. The TITO gateway, double-sided IS without π_old, optimizer reset per weight sync, staleness threshold τ, crash-aware group padding, and more than 1K concurrent rollouts.
- Distillation. On-policy cross-stage distillation as the final stage, rather than one merged RL stage as in DeepSeek-V3.2. This is the same per-token reverse-KL signal as on-policy distillation.
Connections
Section titled “Connections”- GLM-4.5, the predecessor, which introduced slime and expert iteration.
- DeepSeek-V3.2, for DSA and context management, and Muon.
- On-policy distillation and MOPD, comparing GLM-5’s cross-stage teachers with MiMo’s domain teachers.
- Asynchronous RLHF, AReaL and missing old logits, for staleness and behavior-policy choices.
- Context folding, for learned context management versus GLM-5’s fixed rules.
- Tech reports for agent builders.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Derive / compute
GLM-5's agentic RL uses r_t = π_θ/π_rollout, computed from the log-probs saved at rollout time, and masks any token whose ratio leaves [1−ε_l, 1+ε_h]. Take ε_l = ε_h = 0.2 for illustration. For five tokens with ratios 0.75, 0.95, 1.10, 1.25 and 1.6, which get a gradient, and how does this differ from PPO clipping? Then apply the staleness rule: a trajectory spans policy versions (w_0, …, w_k), the trainer is at version w′ = 12, and τ = 3. Which of these are kept: (8, 9), (9, 10, 11), (10, 12)?
What a strong answer covers
- Kept interval [0.8, 1.2]: tokens with 0.95 and 1.10 get gradients; 0.75, 1.25 and 1.6 are masked entirely (zero gradient).
- PPO clipping is sign-dependent: with A > 0, a ratio of 1.25 is clipped (no gradient), but a ratio of 0.75 still gets a gradient through the unclipped branch of the min. Double-sided masking drops both tails regardless of the advantage sign.
- No π_old forward pass is needed, because the rollout log-probs act as the behavior policy. The report accepts this "controlled degree of off-policy bias" for simplicity and stability.
- Staleness uses the oldest version: 12 − 8 = 4 > 3, so (8, 9) is dropped. 12 − 9 = 3 and 12 − 10 = 2, so the other two are kept.
- Samples that failed because the environment crashed are removed. If more than half the group survives, valid samples are repeated to pad it; otherwise the whole group is dropped.
- What if…
GLM-5's BrowseComp numbers move a lot with test-time context management. Explain the three settings (none, keep-recent-k, hierarchical) and their reported scores, and say what this means for comparing search agents.
What a strong answer covers
- Without context management: 55.3%. Keep-recent-5 (only the 5 most recent tool-call rounds stay in context): 62.0%.
- Hierarchical: keep-recent-k plus Discard-all whenever the context exceeds T = 32K, after which the agent restarts with fresh history. It reaches 75.9, versus 67.6 for DeepSeek-V3.2 with context management.
- Motivation: accuracy degrades badly beyond about 100K tokens, so less context can mean better reasoning, not only more steps.
- A comparison must therefore fix the context-management policy and the step or token budget. Otherwise a score of 55 vs 76 measures the scaffold, not the model.
- Critique
In slides RL, the policy learned layout hacks that fooled static HTML checks (Fig. 9). Describe the three-level reward GLM-5 used, why runtime rendering resists these hacks, and what remains unverified in the reported 40% → 92% improvement.
What a strong answer covers
- Level 1 checks static markup attributes such as positioning, spacing, colour and typography. Level 2 checks runtime rendering properties such as DOM element sizes and bounding boxes, measured by a distributed rendering service. Level 3 checks visual perceptual features, such as abnormal whitespace.
- Static rules can be satisfied by declarations that do not reflect what is actually displayed. Rendering gives grounded geometry, so hidden overflow or a fake aspect ratio is caught.
- Reported: pages strictly 16:9 rose from 40% to 92%, and human win rates against GLM-4.5 were 60% for content quality, 57.5% for layout rationality and 65% for visual aesthetics (67.5% overall).
- Still open: the human evaluation is internal; rejection sampling reuses the same reward as the RL, so it can amplify that reward's blind spots; and no held-out aesthetic judge is reported.