Programming Model Training Explained: The Three-Stage Pipeline and How to Evaluate Code Models

    This article breaks down how modern programming models are built and how to evaluate them reliably. It clarifies the capability layers of code models—from local completion to long-horizon agentic execution—then examines the three-stage training pipeline widely used across the industry: mid-training, supervised and reinforcement fine-tuning (SFT & RFT), and agentic RL scaling. It also covers the runtime engineering that sets the real ceiling for code assistants, walks through a hands-on evaluation case (an N-Back cognitive experiment page) with concrete scoring criteria, and closes with six dimensions for choosing a model that fits your engineering workflow.

    1. Introduction: A Crowded Space, and Where the Real Gaps Are

    The code assistant space has heated up noticeably over the past year. Intelligent coding tools are racing to pair with stronger models, and programming models with different specifications and openness policies have appeared one after another. A natural question follows: has this space become too crowded?

    From a hands-on perspective, capabilities like code completion, single-function generation, and code explanation are increasingly homogeneous. A model can write a structurally correct function, read unfamiliar code, and add tests for missing modules. But switch the task to “locating a defect in an unfamiliar repository, editing across multiple files, getting the tests to pass, and organizing a commit,” and the gap between tools widens quickly. In other words, the crowding is concentrated in shallow tasks. What is genuinely scarce is a different set of capabilities:

    • Reliably completing long-horizon tasks;
    • Accurately understanding private code and domain context;
    • Integrating dependably with an existing development toolchain.

    These capabilities are hard to obtain through parameter scaling alone. They require a systematic training path and supporting runtime engineering. This article first outlines how programming model capabilities are layered, then breaks down the three-stage training path common across the industry, and finally offers a directly reusable evaluation method and a set of selection criteria.

    2. Capability Layers: What Are Programming Models Actually Solving?

    Before discussing programming models, it helps to define their capability boundaries. The industry typically divides these capabilities into four layers, from shallow to deep:

    1. L1 Local completion: predicting the next segment of code from the current file’s context. Extremely sensitive to latency.
    2. L2 Single-point generation: generating a function or class from a natural-language requirement, and explaining or transforming existing code.
    3. L3 Repository-level understanding: retrieving relevant code across files, mapping out call relationships and dependencies, and making style-consistent changes in multiple places.
    4. L4 Long-horizon task execution: acting as an agent to autonomously plan steps, call tools (reading and writing files, executing commands, running tests), and refine the plan based on feedback until the task is complete.

    With each layer, the technical difficulty shifts:

    • L1–L2 depend mainly on the quality of pretraining data and the level of instruction following;
    • L3 tests long-context modeling and retrieval;
    • L4 depends on planning, tool use, error recovery, and context management all at once.

    As a result, the training objective of a programming model is no longer “predict the next token” but “complete a class of verifiable tasks inside a tool environment.” This is the fundamental reason programming model training paradigms have kept evolving over the past two years.

    3. The Three-Stage Training Path: From General Model to Programming Agent

    Most of the publicly disclosed programming model training approaches can be summarized into three stages: Mid-Training, Supervised Fine-Tuning and Reinforcement Fine-Tuning (SFT & RFT), and Agentic RL Scaling. Their goals differ and their methods complement each other; none can be omitted.

    3.1 Mid-Training: Reshaping the Capability Base

    Mid-training sits after general pretraining and before post-training. It neither learns language from scratch nor rushes to align to a specific task. Instead, it injects systematic capabilities aimed at programming and agentic scenarios into a general model. Its focus usually covers:

    • Instruction following: Code tasks often come with multiple constraints—for example, “do not change the public interface,” “new features must ship with unit tests,” or “output must remain compatible with an older runtime version.” Whether the model satisfies each constraint directly determines whether the result is usable as-is.
    • Tool use: Generating well-formed tool calls, correctly interpreting call results, and adjusting arguments to retry on failure are prerequisites for L4 capability.
    • Multi-turn interaction: Proactively asking for clarification when information is incomplete, and precisely locating the part that needs changing when the user corrects it—rather than starting over.
    • Code knowledge injection: Supplying specialized knowledge such as framework usage, language feature evolution, and common defect patterns, and bridging the semantic gap between natural-language descriptions and code implementations.
    • Code hosting workflow: Understanding the collaborative semantics of branches, commits, diffs, merge requests, and code review, so the model can produce commit messages and change descriptions that follow team conventions.
    • Preserving general and reasoning ability: Code tasks are inseparable from logical reasoning. Mid-training needs to mix in a reasonable proportion of general and reasoning data to prevent capability degradation from domain specialization.

    Engineering notes: The most easily overlooked aspects of mid-training are data mixing ratios and decontamination.

    • If the share of code and engineering data is too high, the model may produce stiff natural language and show degraded common-sense reasoning;
    • If there is too much general data, professional capability fails to stand out;
    • Public repositories on code hosting platforms must also be strictly deduplicated and screened for samples that overlap with evaluation sets.

    The mixing and cleaning strategy must be validated repeatedly against the target scenario; there is no one-size-fits-all rule.

    3.2 Supervised and Reinforcement Fine-Tuning: Raising Efficiency with Verifiable Signals

    In the supervised fine-tuning stage, you need to systematically cover the task categories users most often initiate in real use, along with several typical code scenarios. These tasks usually span understanding, generation, debugging, refactoring, and testing. Two lessons are worth borrowing in practice:

    • Balanced task coverage: Do not pile up only “generation from scratch” samples. Also include high-frequency scenarios like modifying existing code, diagnosing defects, adding documentation, and writing tests. If long-tail scenarios are missing for a long time, they will surface as weaknesses in real use.
    • Trajectories must contain real interaction: The ideal fine-tuning sample is not a static “input–output” pair but an interaction trajectory that includes tool calls, observation of results, and subsequent adjustments. Only such samples teach a model “what to do when it hits a problem.”

    In the reinforcement fine-tuning (RFT) stage, the core is using real labels to improve the quality and efficiency of the training signal. Take repair tasks as an example: for the same problem, the model generates multiple candidate patches; after test validation, only the samples that truly pass are kept for training.

    The value of RFT lies in:

    • Training data naturally carries verifiable correctness labels;
    • Rejection sampling raises the information density of each sample, reducing the exploration cost of the later reinforcement learning stage;
    • The kept samples are all “positive examples,” so the policy distribution converges to a usable region earlier, improving the stability of subsequent training.

    The prerequisite is sufficient test coverage. If the test cases are too thin, the model may learn to “game the tests” rather than actually solve the problem. And if the answer is carelessly leaked into the prompt or context, the training signal becomes distorted.

    3.3 Agentic RL Scaling: Efficiency Sets the Ceiling

    The focus of the third stage shifts to scaling. When an agent has to trial-and-error across multiple rounds of tool calls, the training paradigm faces several challenges:

    • Long sequences, high cost: A single trajectory may contain a dozen-plus rounds of interaction, and each round requires full reasoning.
    • Sparse rewards: The reward is usually given only at the end of the task—for example, “did all tests pass”—so intermediate steps lack direct feedback.
    • Expensive sampling: In on-policy training, policy updates need fresh samples, yet agent–environment interaction is constrained by steps like command execution and test running.
    • Underutilized resources: If sampling and training run serially in lockstep, part of the cluster always sits idle, forming “bubbles.”

    Two of the most representative approaches in current public solutions address these problems.

    (1) Entropy-guided trajectory tree pruning

    The core idea is to direct the compute budget toward the “most informative” branches:

    1. Prefix tree compression: Sampled trajectories that share the same prefix are merged into a single prefix tree. The common prefix is computed only once, eliminating a large amount of redundant inference.
    2. Entropy and access-probability ranking: Prediction entropy at decision points measures uncertainty—the higher the entropy, the more “unsure” the model is and the more likely it holds a valuable learning signal; this is then combined with each node’s access probability for ranking.
    3. Expand high-signal nodes within budget: Under a limited budget, high-signal nodes are expanded first and low-value branches are pruned, so the same amount of compute covers more effective exploration.

    Its essence is a fine-grained trade-off between exploration and exploitation. It is worth stressing that the optimization is holistic: if the compute saved is not converted into more effective gradients, the overall efficiency gain is discounted.

    (2) Decoupling training from agent logic

    Split “environment interaction and sampling” from “parameter updates” into two independently running services that pass trajectories and rewards over a data channel. The sampling side focuses on executing tasks and collecting results; the training side focuses on consuming data and updating parameters. Running in parallel, this significantly reduces cluster idle time and enables high-utilization scheduling.

    This design also brings two derivative benefits:

    • Changes on the environment side (such as adjusting the tool set or sandbox policy) do not directly interrupt training;
    • The sampling scale can scale elastically with available resources.

    Supporting safeguards: Both during training and in real use, a code agent needs a securely isolated sandbox to constrain filesystem and network access and prevent destructive actions from accidental execution. In addition, reward design should account for test pass rate, static check results, and the minimality of the changes—so the model does not make sweeping code changes just to pass tests.

    4. Toolchain: The Runtime Engineering That Sets a Code Assistant’s Ceiling

    Model capability is only the lower bound; what truly determines the ceiling is the runtime engineering built around the model.

    • Tool integration and parsing fault tolerance: Tool calls produced by a generative model may be malformed or even contain hallucinated parameters. The system needs strict parameter validation, clear error feedback, and a limited number of retries to turn “occasional failure” into “stable usability.”
    • Context engineering: Long tasks inevitably require compressing history. In practice, earlier rounds are usually summarized while key state is retained—the file list, modified content, and pending tasks. The latter can be carried by an external task list or memory file to avoid losing critical information during compression.
    • Long context and cache reuse: Putting the full repository structure, relevant files, and the entire dialogue into context is not always feasible or cost-effective. When the inference service supports prefix cache reuse, placing the stable system prompt and project background at the front of the context lets subsequent requests reuse the already-computed intermediate state, reducing latency and cost.
    • Routing and cost control: Completion requests are extremely latency-sensitive, while complex tasks value reasoning depth more. Routing requests to different model sizes by task type and complexity is a common way to balance experience and cost.
    • Privacy and compliance: Code assets often involve a company’s core intellectual property. Sensitive scenarios should evaluate options such as private deployment, keeping data within a controlled boundary, and encryption in transit and at rest, and should define the retention and usage boundaries of user data in advance.

    5. Evaluation Method: Testing a Model with a Cognitive Experiment Page

    Once you understand the principles, the key is how to evaluate a programming model credibly.

    5.1 Principles for Choosing a Case

    A good evaluation case should satisfy three conditions at once:

    • Close to reality: It maps to a common task form in development.
    • Verifiable results: Whether the functionality is correct can be checked by direct operation, without relying on subjective impression.
    • Decomposable difficulty: It lets you observe the interface, logic, and robustness separately.

    This article uses a case related to a cognitive neuroscience experiment. Such an experiment usually requires researchers to hand-implement stimulus presentation and response collection logic in a prototype tool, which is time-consuming. A task like this—with detailed interaction requirements, many boundary conditions, and a visual dimension to consider—is well suited to comprehensively testing both a model’s individual capabilities and its agentic capabilities.

    5.2 The Prompt

    The following is an illustrative prompt. The model needs no domain background and should be able to complete the implementation from the description alone:

    1. Implement an N-Back cognitive experiment page with the following requirements:
    2. 1. At the start of the experiment, let the user select an N value: 2, 3, or 4.
    3. 2. After the experiment starts, present one image every 1 second.
    4. 3. The image material is the following 10 common Chinese characters, appearing randomly:
    5. ["国", "火", "道", "市", "天", "家", "理", "态", "至", "心"]
    6. 4. The participant judges whether the current image is the same as the image N positions earlier:
    7. press "Yes" if it is the same, "No" if it is different.
    8. 5. At the end of a round, display the accuracy and average reaction time, and support restarting.

    5.3 Scoring Dimensions

    Dimension Key Checkpoints Typical Problems
    Stimulus sequence The first N−1 images are only shown, not judged Index out of bounds or wrong judgment when the sequence is too short
    Timing accuracy Is the interval stable at 1 second Cumulative drift from adding delay on each call
    Response judgment Does the answer correspond to the “N-th” image rather than the previous one The N value is misaligned with the judgment target
    Feedback statistics Are the definitions of accuracy and reaction time correct Non-response counted as an error; reaction time measured from stimulus onset instead of from deviant-stimulus onset
    Robustness Backgrounding the tab, losing window focus, rapid clicking, changing N midway Timing disorder, duplicate counting
    Interface Characters clear and centered, no distracting elements Layout breaks on narrow screens
    Code quality Are state management and timing logic clear Proliferation of global variables, hard-to-maintain nested timers

    It should be noted that test performance is affected by factors such as prompt quality, whether the context is sufficient, and the number of samples. A single result is only a reference and should not be used to draw universal conclusions.

    5.4 Interpreting the Results

    This project places high demands on fixed-interval timers, state management, and user response collection. Typical weak points tend to concentrate in:

    • Timing drift: If the implementation relies on recursively calling a delay function, each call stacks rendering and execution overhead, and the rhythm visibly slows over a long run. A more robust approach is to calibrate the rhythm against timestamps.
    • Lifecycle management: After the page moves to the background, timing tasks may keep accumulating or be throttled, so the rhythm needs to be realigned on recovery.
    • Reaction-time measurement: If measurement starts from the moment the stimulus is presented, a key pressed before the deviant stimulus appears will be wrongly counted as a valid response. The correct approach is to collect key presses only within the window after the deviant stimulus.

    When evaluating, you can observe a model’s multi-turn collaboration around three points: whether it can produce a runnable result in one pass, whether a follow-up prompt leads to a precise fix, and whether the fix introduces new problems.

    5.5 Making Evaluation Systematic

    Case testing is good for a quick assessment, but long-term selection requires a systematic evaluation:

    • Public benchmarks: These assess general capabilities like code completion and defect fixing, but be wary of inflated scores caused by training-data contamination.
    • Private task sets: Extract tasks from the real development workflow (with sensitive data removed) and pair them with automated tests to form a regression baseline.
    • Fine-grained metrics: Separately track first-pass rate, average number of interaction rounds, and human intervention rate. These reflect long-horizon reliability better than a single success rate.

    6. Selection Criteria: Judging Beyond the Hype

    Back to the opening question: whether the space is crowded is not what matters. What matters is whether you can find a combination of capabilities that matches your own scenario. Evaluate along these six dimensions:

    1. Long-horizon reliability: Can it independently complete cross-file changes and self-correct when it fails?
    2. Context and adaptation: How well does it understand long repository context and private code?
    3. Toolchain integration: How smoothly does it connect with the terminal, the IDE, and code hosting platforms?
    4. Cost and latency: Measure by “total consumption per completed task” rather than unit price.
    5. Security and compliance: Does the code leave a controlled environment, and how are permissions constrained?
    6. Service stability: The pace of iteration, the completeness of documentation, and the responsiveness of technical support.

    Open-weight and closed-source options each involve trade-offs:

    • Open-weight models: Convenient for private deployment and domain fine-tuning, but inference deployment and quality tuning require investment from your own team.
    • Closed-source services: Relieve the operational burden and iterate quickly, but offer relatively limited room for customization.

    The choice should weigh your team’s engineering capability.

    7. Conclusion

    Competition among programming models has shifted from “can it generate a piece of correct code” to “can it reliably complete tasks in a real engineering environment.” This shift pushes the training paradigm toward a systematic path that connects mid-training, supervised and reinforcement fine-tuning, and agentic RL scaling, and it raises the bar for runtime engineering.

    Back to the question of whether the AI code assistant space is already too crowded: what is crowded is shallow capability; what is empty is long-horizon reliability, private-knowledge adaptation, and workflow integration. For developers, rather than chasing leaderboard rankings, it is better to use an evaluation method close to your own development workflow to keep testing models. After all, when it comes to code assistants, there is only one evaluation that truly matters: whether the tool helps you deliver faster and more reliably.