Why Training an AI Agent Is Mostly Plumbing: Lessons From Mercor's 397B RL Run

6 min read

Why Training an AI Agent Is Mostly Plumbing: Lessons From Mercor's 397B RL Run

The problem

Reinforcement learning (RL) is how you teach an AI agent to finish long, multi-step jobs: give it a task, let it try, score the result, and nudge the model toward whatever scored well. On paper that's simple. In practice, a run on a big model eats a lot of expensive GPU time, and if something small is broken, like a tool that silently returns nothing, you only find out after you've paid for it.

In September 2026, Mercor published a detailed guide to how it post-trained two open models with RL on realistic office work (consulting, banking and legal tasks), using the open-source SkyRL framework. The headline result is good. The more useful part is how much of the work happened before any serious compute was spent.

The results

  • Qwen3.5-397B-A17B (a 397-billion-parameter mixture-of-experts model): Pass@1 on the held-out APEX-Agents benchmark of 480 tasks went from 16.11% to 27.29%, a 70% relative gain.
  • Qwen3.6-35B-A3B, a much smaller model, was post-trained with RL until, by Mercor's report, it surpassed Opus 4.5 on the same benchmark.
  • Training used 1,928 expert-created tasks, separate from the 480 test tasks.
  • They checked two general reasoning benchmarks, HLE and GPQA, and report that all differences fell inside the error bars. In other words, no measurable loss of general ability.

Six steps, and the first three are cheap

The guide is organised in six steps. Mercor's rule is that steps 1 to 3 are de-risking: you don't spend significant compute until step 4.

Animation: Mercor's six steps. Steps 1 to 3 de-risk cheaply; real compute starts at step 4.

Step 1: fix the environment before you train

An agent learns from whatever its environment shows it. If the environment is broken, the model learns to work around the bug, or learns nothing. Mercor had coding agents read through traces of the model's attempts and look at per-tool failure rates. That turned up problems like these:

  • Some Python packages were missing from the sandbox, so the agent wasted turns figuring out what was installed.
  • A PowerPoint tool returned None on every call, even when it worked.
  • The PDF reader flattened multi-column tables into garbled text, so they pointed the model to a better PDF library instead.

They also added a nudge telling the model to wrap up when it was nearly out of context. The result of these fixes: the base 35B model's mean reward went from 22.74% to 28.69% with zero training. Mercor estimates that is roughly what one full epoch of training would have bought on the broken setup.

Step 1 also covers exact token accounting, which they call token-in-token-out. Re-tokenising the model's text output before feeding it to the trainer can quietly misalign what the model generated with what the trainer thinks it generated.

Step 2: tune the training system

This is engineering, not research. A few concrete details from the guide:

  • They tuned the training backend's parallelism and batch settings in one overnight session with a coding agent.
  • They split the cluster between generating attempts and training on them: a 12:4 node ratio for the 35B and 12:8 for the 397B.
  • They capped how many attempts run at once. Their staleness limit allowed (3 + 1) × 16 × 16 = 1024, but the real limit was hardware: they used 550 for the 35B and 300 for the 397B.
  • They compared the probabilities that the trainer and the inference engine assign to the same tokens. A mean difference below 0.03, they say, is usually healthy. This check caught a real correctness bug.

Step 3: overfit a small set first

Before the big run, train on just 32 tasks (batch size 32, 8 attempts per task) and check the reward climbs within a few steps. If a model can't even memorise 32 tasks, something is broken, and it is far cheaper to learn that now.

Animation: The overfitting check. If reward climbs on 32 tasks, scale up. If not, go back and fix the setup.

This caught a real problem. Tasks that required editing files weren't being learned, and the cause turned out to be the grading code, not the model. Switching to a third-party file-diffing tool made the tasks learnable.

Step 4: which knobs mattered

Only now did they spend compute on experiments, all on the 35B and each averaged over three evaluation passes:

  • prompt_mean loss averaging: +3.9 points. Their attempts ranged from 2k to 128k tokens. The default averaging lets the longest attempts dominate the training signal. Averaging per task removes that bias.
  • A "wrap up" nudge at 20% context remaining, during training only: +3.0 points.
  • Two loss functions designed for asynchronous training (DPPO and the GLM-5 loss) scored about the same, but DPPO produced longer runs with more, shorter turns.
  • Overlong filtering, an adaptive length penalty and resetting the KV cache didn't significantly help.

Animation: The 397B went from 16.11% to 27.29%. The best single knob was worth +3.9 points.

Does it work outside the training setup?

A common worry is that RL gains only hold inside the exact harness used for training. Mercor swapped their tool-based harness for OpenCode, a code-only agent setup, and evaluated on the same 480 tasks. The gains carried over, more strongly for the 35B, which leaned more on running code. The post-trained models also improved on Terminal-Bench 2.1, a different agent benchmark.

The lesson they draw

Mercor's own summary: algorithm choices mattered less than the data. The best of five knobs gave +3.9 points, while post-training as a whole moved both models 10 to 12 points.

My take

I think step 1 is the part most teams skip and shouldn't. Six points from fixing tools, with no training at all, is a reminder that an agent's score measures the model and its environment. If you're building agents, read your traces before you tune your loss. Also keep in mind the source: Mercor sells expert-created training tasks, so "data matters most" is also its business case. The released recipe means others can check.

They released the code as the ApexAgents-SkyRL-Recipe on GitHub, with models on Hugging Face. For background on terms, see our AI agent glossary and LoRA and QLoRA fine-tuning on a single GPU.

Sources

  • Mercor, "Training frontier knowledge-work agents: a 397B RL training guide with SkyRL", mercor.com blog, September 2026
  • Mercor-Intelligence, ApexAgents-SkyRL-Recipe, GitHub
  • Mercor, apexagents-skyrl-recipe collection, Hugging Face