Choosing Coding Foundation Models: From Code Completion to AI Agents

    This guide explains how coding models are evolving from token-level code completion to repository-level agents. It compares function-level and repository-level evaluations, outlines the roles of Mid-Training, SFT, RFT, and agent reinforcement learning, and provides an N-Back experiment specification for evaluating whether a model can generate a runnable web application.

    1. Changing Roles and Evaluation Criteria

    Over the past year, AI coding tools have changed significantly. Early products focused primarily on code completion: the model read the context before the cursor and predicted the next sequence of tokens. More recent products attempt to understand tasks independently, call tools, and modify entire projects. This type of system is commonly referred to as an AI agent.

    Evaluation criteria have changed accordingly. HumanEval and MBPP mainly test whether a model can write an isolated function, measuring function-level pass rates. SWE-bench gives the model an issue from a real code repository. The model must locate the relevant files, modify the code, run tests, and continue fixing the implementation based on the errors it receives.

    The two evaluation approaches differ as follows:

    Dimension Function-Level Evaluation (HumanEval, MBPP) Repository-Level Evaluation (SWE-bench)
    Input Function signature and docstring Issue description and a complete code repository
    Required capabilities Write a correct standalone function Locate files, use the command line, and run tests
    Evaluation method Unit tests pass Relevant tests pass after the fix
    Value for model selection Reflects isolated coding ability More closely resembles everyday software engineering

    When selecting a model, the key question is whether it can complete the loop of reading a repository, modifying code, running tests, and iterating on the fix, rather than relying only on function-level pass rates.

    2. What the Three Training Stages Address

    The original author divides agent-model training into three stages. The explanations below are based on that description. As of this writing, no corresponding paper or third-party evaluation has been identified, so these claims should be treated as information that still requires verification.

    2.1 Mid-Training: Building Fundamental Capabilities

    Before supervised fine-tuning, a model typically goes through Mid-Training. The goal is to develop the basic capabilities required of an agent, including:

    • Instruction following and multi-turn interaction: Understanding requirements with multiple constraints while maintaining context across several turns.
    • Tool calling and parameter generation: Determining when an external tool is needed and generating valid parameters, such as function arguments or shell command options.
    • Code knowledge and reasoning: Learning syntax and framework APIs while improving its ability to reason through complex logic. According to the original description, this stage may also cover Git workflows, including branch management and submitting pull requests.

    2.2 SFT: Learning to Produce the Required Output

    Supervised fine-tuning (SFT) relies on high-quality question-and-answer data. The described training data covers common user tasks such as code explanation, unit-test generation, and bug fixing. It also includes scenarios involving web frontends, backend APIs, and data-processing scripts.

    SFT teaches a model to follow expected response formats and operational patterns. However, a model trained only with SFT may learn answers that look correct without ensuring that the code actually runs. This is the problem addressed by the next stage.

    2.3 RFT: Selecting Samples Through Verification

    Rejection fine-tuning (RFT) consists of three steps:

    1. Sampling: Ask the model to generate multiple candidate answers for the same problem.
    2. Filtering: Use automatically verifiable methods, such as tests, compilation, or answer matching, to determine which candidates are correct. Keep only the candidates that pass.
    3. Fine-tuning: Use the retained answers as training data for another round of fine-tuning.

    The main difference between RFT and SFT is the source of the data. SFT uses human-labeled data or existing answers, while RFT uses answers generated by the model and then verified. RFT is suitable for tasks with clear evaluation criteria, such as coding problems with executable tests. For open-ended problems without an objective standard, the filtering criteria are less clear and the results are harder to guarantee.

    The following checklist can help determine whether a workflow is genuinely using RFT:

    • Does the training data come from the model’s own samples rather than manually written answers?
    • Is there an automated verification method, such as testing, compilation, or static analysis?
    • Are the pass rate and number of retained samples recorded for each problem?
    • Are evaluation problems excluded from the training data to prevent test leakage?

    2.4 Agent Reinforcement Learning: Practicing the Complete Loop in an Environment

    Agent reinforcement learning allows a model to practice repeatedly in an executable environment. The process mainly includes four components:

    • Environment: A code repository, an isolated sandbox, and executable tests.
    • Actions: Reading files, editing code, running commands, and submitting changes.
    • Rewards: Passing tests, following the required output format, and using a reasonable number of steps.
    • Feedback: Returning error messages to the model so it can revise its implementation in the next round.

    The basic loop is:

    1. Observe the current state.
    2. Select a tool.
    3. Execute the action.
    4. Read the output.
    5. Make corrections.
    6. Continue until the tests pass or the step limit is reached.

    This approach also introduces risks. If the reward depends only on whether tests pass, the model might delete or modify the tests to obtain a reward. This behavior is known as reward hacking. Possible safeguards include making test files read-only and checking the diff produced by every modification.

    3. N-Back Experiment Page: Task Specification and Acceptance Checklist

    N-Back is a commonly used working-memory task in cognitive psychology. Participants see a sequence of stimuli and determine whether the current stimulus matches the one shown N steps earlier. The specification below can be used to evaluate whether a coding model can generate a runnable experiment page.

    3.1 Task Specification

    • Inputs: N value from 1 to 3, stimulus sequence length with a default of 30, stimulus display duration with a default of 1,500 milliseconds, interval between stimuli with a default of 500 milliseconds, and stimulus type with letters as the default.
    • Outputs: The judgment for each trial, whether it was a match or non-match, accuracy, hit count, and false-alarm count.
    • Page elements: A stimulus display area, a Match button, a Start button, an End button, a progress indicator, and a results panel.

    3.2 Interaction Flow

    1. The user selects an N value and clicks Start.
    2. The page displays the stimuli in sequence according to the configured timing.
    3. While a stimulus is visible, the user clicks Match or does nothing.
    4. When the sequence ends, the results panel displays accuracy, hit count, and false-alarm count.
    5. The user can start the task again, with the previous settings retained on the page.

    3.3 Test Example

    For N=2 and the sequence A B A C A, the third stimulus matches the first stimulus, and the fifth stimulus matches the third stimulus. A generated implementation should therefore identify the third and fifth positions as matches and use the remaining positions to evaluate non-match responses.