How Coding LLMs Are Built: Mid-Training, SFT, RFT and Agentic RL in AI Coding Assistants
Coding LLMs are the foundation of the AI coding assistants now common on developers' desktops. This article looks at the AI coding assistant landscape and breaks down the post-training stages behind capable coding models: mid-training, supervised fine-tuning (SFT), rejection sampling fine-tuning (RFT) and reinforcement learning (RL) scaled for agentic tasks. It also offers a multi-dimensional framework for evaluating coding models beyond benchmark scores and a hands-on walkthrough of building an interactive web app, so you can judge which assistant truly fits your engineering workflow.
Why Everyone Is Building Coding Assistants
In just over a year, AI coding assistants have gone from niche tools to standard fixtures on the developer’s desktop. Both IDE plugins that complete code inline and conversational, agent-style tools that can read and write files and run commands on their own are iterating fast.
The field looks crowded for a reason. Coding tasks have several natural advantages:
- They are a high-frequency, everyday need.
- Their correctness can be verified automatically through compilation and testing.
- There is a large body of public code that can be turned into structured training data.
Together, these traits make improving a model’s coding ability a research direction with a high return on investment and results that are easy to measure.
Crowded, however, does not mean interchangeable. Products differ markedly in their base models, training strategies, how they organize context, and their tool-calling abilities. For developers, the more useful question is not which tool to pick, but how to judge coding model capability. A clear framework is the better place to start.
Where Coding Model Capability Comes From
A coding model built for real-world engineering is rarely ready to use straight out of pretraining. On top of a general-purpose base model, it typically goes through several post-training stages tailored to agentic scenarios. The stages below are common approaches in the industry.
Mid-training: From writing code to getting work done
Traditional code completion only cares about what the next line should be. Modern coding assistants, by contrast, must handle multi-step tasks: understanding a request, finding relevant files, calling tools, executing commands, and adjusting their approach based on feedback.
Much of the gap between these two kinds of models comes from the mid-training stage.
Mid-training aims to build several capabilities into the model:
- Instruction following
- Tool use
- Multi-turn interaction
- Domain-specific code knowledge
- Version-control workflows, such as writing commit messages and organizing pull requests
It sits between general pretraining and final fine-tuning. With a relatively larger dataset that closely reflects real-world interactions, it teaches the model the feedback loop of task → tool → result → next decision. Preserving general understanding and reasoning is also important. Otherwise, the model can regress on basic tasks outside of coding.
SFT and RFT: From sometimes right to reliably right
During supervised fine-tuning (SFT), high-quality training examples are usually built around frequent user tasks and common coding scenarios. This teaches the model conventional output formats and interaction habits.
Rejection sampling fine-tuning (RFT) takes the process closer to the real data distribution:
- The model samples multiple candidate trajectories in response to the same problem.
- A correct answer that can be judged automatically filters out the trajectories that pass.
- Those trajectories are then used for training.
Its value lies in what it introduces. Instead of a single standard answer, training sees multiple distinct paths that are each correct, which significantly improves sample effectiveness.
In agentic settings, this step often has a further benefit. It raises the sampling efficiency of the later RL stage, making training more stable and faster to converge.
Scaling RL for agents: Spend compute where it counts
When a model has to complete long, multi-step agentic tasks, the sampling cost of RL climbs sharply. Every complete trajectory can require many model calls and environment interactions. Scaling up training under such costs is one of the core engineering challenges of coding model development.
A common class of solutions can be summed up as prioritizing high-value trajectories:
- Organizing the large volume of sampled trajectories into a prefix tree and merging shared prefixes
- Ranking nodes by information entropy and visit probability
- Expanding only the branches with high information content and high exploration value, within a limited compute budget
- Decoupling the training pipeline from the agent logic, so the cluster runs at full capacity as much as possible with minimal idle time
The goal is straightforward: concentrate precious compute on the samples with the most learning value, without sacrificing quality.
How to Tell Whether a Coding Model Delivers
With new models appearing constantly, marketing metrics alone tell you little. The more reliable approach is to cross-check across several dimensions.
- Benchmarks: Software engineering benchmarks built around resolving real repository issues (there are several public benchmarks of this kind) reveal how well a model locates and fixes problems with real codebase context. They come far closer to engineering reality than standalone algorithm puzzles. But watch out for leaderboard-chasing: a benchmark score should be corroborated by the other dimensions below.
- Real tasks: Test the model on an actual requirement from your own project rather than a generic sample.
- Tools and interaction: Check whether it asks clarifying questions in multi-turn conversations, uses tools correctly, and can diagnose and fix failures from error output.
- Context handling: On larger codebases, check whether it retrieves and cites the right context accurately and whether it overlooks key files.
Hands-on: Building an Interactive App From Scratch
In practice, trying it beats any amount of theory. The example below shows how a coding assistant performs on a concrete development task: a browser-based interactive page implementing a classic cognitive psychology task.
The requirements are roughly as follows:
- An image flashes on the page at intervals of about one second.
- For each image, the user judges whether it is the same as the one shown N steps earlier, choosing “Yes” if it matches and “No” if it does not.
- The images are a set of common Chinese characters.
- Before each run starts, the user can choose the value of N (for example, 2, 3, or 4).
Tasks like this look simple but hide a fair amount of engineering detail:
- Timing control: Switching images at precise intervals requires correct timer handling to avoid UI freezes or timing drift.
- Ring buffer: Deciding whether the current image matches the one N steps back calls for a fixed-length history window, which is usually implemented as a ring buffer.
- State management: Transitions between states such as idle, in progress, and finished must be handled correctly, along with user input during the gaps between answers.
- Data logging: Every stimulus presentation, user response, and correct-or-incorrect outcome needs to be recorded for later analysis.
- Interaction experience: Key-press responsiveness, visual feedback, and protection against accidental clicks all determine whether the app is actually usable.
A mature coding assistant can usually generate a largely complete frontend implementation in one pass. It can then iterate as you add requirements, such as scoring, reaction-time statistics, color scheme adjustments, or data export.
What really sets tools apart is not whether they can produce the code, but how they handle:
- Vague requirements: whether they ask proactive follow-up questions
- Generated code: whether it is maintainable
- Runtime errors: whether they can find and fix them on their own
These qualities are also what determine whether a coding assistant is a good fit for long-term collaboration.
Why a Crowded Field Is Good for Developers
So, are there too many AI coding assistants? By product count, yes. From the developer’s side, however, more competition means faster iteration and better value for each unit of capability.
What you need is an evaluation method that does not rely on any single marketing claim:
- Define your scenario: Code completion, refactoring, test generation, and end-to-end tasks each call for different strengths.
- Validate with real tasks: Stress-testing with real problems from your own codebase is far more convincing than running generic examples.
- Look at the engineering pipeline: Whether a model fits into your toolchain, calls tools correctly, and can recover from errors usually matters more than a single benchmark score.
If you want to build controllable, compliant AI development capabilities in your own environment, a mature cloud platform such as Baidu AI Cloud is a practical option. It offers general-purpose compute, model services, and a development toolchain. The final choice, however, should come back to the scenario-based evaluation framework above. Make the decision with data, not impressions.
Conclusion
On the surface, the coding model race looks like a contest over who writes better code. Beneath it lies a deeper question: who better understands real-world engineering?
- Mid-training rebuilds an agent’s overall capabilities.
- Rejection sampling fine-tuning improves the effectiveness of training data.
- Agentic reinforcement learning concentrates compute on high-value samples.
It is the combination of these technical stages that enables a coding assistant to handle real collaboration. For developers, the better move is not to chase leaderboards, but to put candidates to the test with your own real tasks. The right assistant is the one that fits your workflow and can truly get work done alongside you.
