Making Models Get Things Done: Post-Training Essentials for AI Agents and Coding Tasks

    This article explains how agent-oriented post-training helps language models complete multi-step engineering work, such as diagnosing faults, changing configurations, and running tests. It covers training signal design, error attribution, behavioral evaluation, layered benchmarks, and the tool, permission, and state management needed for safe deployment.

    1. From Knowledge Q&A to Task Execution

    Large language models have long been measured by the breadth of their knowledge and their performance on hard reasoning benchmarks. In enterprise development and operations, however, teams care whether a model can complete real work. A model that explains a concept fluently may not reliably complete a multi-step workflow such as “read logs, locate the fault, change the configuration, run tests, and submit the change.”

    Agent-oriented post-training targets this gap. It uses training signals to change how a model behaves, so that the model uses tools better, makes use of environment feedback, makes sequential decisions, and corrects its own mistakes. The gains are usually most visible in coding and automation tasks, because code repositories, terminal output, and test results provide verifiable feedback.

    This article covers five areas: training signals, inference behavior, capability breakdown, evaluation, and system engineering. It offers a reusable analytical framework. The methods and criteria can inform internal evaluation design, but they do not replace the formal evaluation report for any specific model.

    An Example of a Multi-Step Task

    Suppose a service triggers a timeout alert in the early morning. The agent needs to complete the following steps.

    1. Read the service logs from the past hour and filter for records at the ERROR level.
    2. Identify the connection pool exhaustion error and find the related configuration item, max_connections.
    3. Change the configuration to a reasonable new value and deploy it to the test environment.
    4. Run the load test and unit tests to confirm that the timeouts no longer occur.
    5. Write a change description and submit it for approval.

    Common failure modes include:

    • The log time window is wrong, so errors from a period that has already recovered are treated as the current fault.
    • An unrelated configuration item with a similar name is modified, for example another timeout parameter with the same name.
    • Tests pass, but no test case covers the concurrency scenario that caused the timeouts, and the model still declares the problem solved.
    • The change is deployed to production when the task required validation in the test environment only. This is target environment confusion.
    • After a test fails, the model runs the same command repeatedly without changing its assumptions, until a timeout occurs or the run is interrupted.

    Most of these failures do not stem from missing knowledge. They come from errors in step sequencing, environment judgment, and termination decisions. Post-training signals need to cover these stages.

    Scenarios Where the Method Does Not Fit

    Not every task suits the current agent approach. In the following cases, establish the prerequisites first, or hold off on automated execution:

    • The operation is irreversible and there is no backup or rollback, such as directly deleting data or modifying a production database.
    • No reliable test environment exists, so results cannot be verified before and after execution.
    • The task has no clear success criteria, and the team cannot state what “done” means.
    • The task involves highly sensitive data, but permissions are not isolated by task.
    • The task depends on a large amount of undocumented human expertise that the model cannot obtain from its environment.

    2. Training Signal Design: What the Model Learns

    Traditional post-training mainly targets next-token prediction quality or preference alignment. Agent-oriented post-training also needs signals that stay close to the execution process. Common signal types are listed below.

    Signal type Training objective Typical data source Main risk Suitable tasks
    Trajectory-level reward The whole task reaches its goal Automated verification of the final state The reward is too coarse to distinguish useful steps from wasted ones Multi-step repair, deployment
    Tool call correctness Function names, parameter structures, and call timing are reasonable Tool schemas and call logs The model learns the format but not when a call is appropriate Query and change tasks
    Use of environment feedback Next actions adjust based on output Terminal output, compiler errors, test reports The model learns to apply fixed phrasing instead of reading the feedback Debugging, building
    Termination judgment Judges when to finish, give up, or ask for help Human-labeled stop points and verification results Tends to stop too early or try indefinitely All tasks

    These signals are usually added through rejection sampling, process reward modeling, or reinforcement learning. Before starting similar data work, a team should define what a “successful trajectory” is. Otherwise, the reward signal is hard to keep stable.

    Defining a Successful Trajectory

    A trajectory counts as successful only when it meets all three conditions:

    1. The final state is verifiable. For example, all target tests pass and no new failing test cases appear.
    2. The steps are reasonable. There are no unauthorized operations, no repeated or ineffective tool calls, and all parameters pass schema validation.
    3. The result is reproducible. Repeated runs in the same replay environment produce the same outcome.

    A trajectory that meets only the first condition should not be used directly as a positive sample. The model might pass tests by modifying the test cases, a common form of reward hacking.

    Data Filtering Rules

    Filter training data in the following order:

    1. Remove trajectories whose final state cannot be verified automatically, or send them to a separate manual review queue.
    2. Remove trajectories that contain violations or destructive operations, whether or not they ultimately succeed.
    3. Manually review trajectories whose step count exceeds the limit. Keep only those where the extra steps have a reasonable explanation.
    4. Deduplicate by repository, task template, and time, so that one pattern does not dominate the dataset.
    5. Sample by task type in stratified fashion, so that the share of each task type can be explained.
    6. Keep failed trajectories for error analysis and comparison, but do not use them as positive samples.

    Error Attribution for Failed Trajectories

    Each failed trajectory needs its first decisive error step marked and assigned one of the following labels:

    • Goal misunderstanding: the task scope is misread, for example treating the test environment as production.
    • Planning error: steps are in the wrong order, for example submitting a change before verification.
    • Tool selection error: a write tool is called where a query tool should have been used.
    • Parameter error: a parameter value or structure is invalid.
    • Feedback neglect: key information in the previous step’s output is not used.
    • Termination error: completion is declared too early, or the model keeps trying when it should ask for help.
    • Side effect: an unauthorized or destructive operation is executed.
    • Environment failure: caused by network issues, dependent services, or sandbox problems. These should be excluded from model evaluation.

    Each trajectory gets only one primary cause. Secondary causes are recorded separately. The labeling guidelines should be written as a document, with positive and negative examples for each label.

    Annotation Quality and Sampling Checks

    Two annotators label the data independently. Their agreement is measured with Cohen’s kappa, and 0.7 is usually taken as the reference lower bound for usable agreement. If the value falls below that, revise the labeling guidelines before continuing.

    Randomly select 5% to 10% of each batch for review by a third person. If the disagreement rate between the reviewer and the original labels exceeds the team’s threshold, re-annotate the entire batch. Calibrate the threshold on the first batch of data rather than adopting someone else’s figure.

    Reward Signal Stability Checks

    Before a reward signal is used for training, run the following checks:

    1. Replay consistency: when the same trajectory is replayed several times in the same environment, reward variation should stay within an acceptable range.
    2. Human agreement: compare reward results with manual judgments on a sample, and calculate the agreement rate.
    3. Hack detection: build trajectories that only modify tests, only modify assertions, or hard-code outputs, and confirm that the reward does not give them high scores.
    4. Distribution check: look at reward distributions across tasks of different difficulty, and avoid having scores