Skill Internalization for Post-Training: A Practical Guide
Post-training often turns into memorizing successful trajectories. This article explains how to treat agents as “teaching materials” rather than exam answers: lock experimental conditions, write short executable skills, keep skills in training but strip them at evaluation, and produce data without success-sample bias. Readers get a controlled comparison protocol, a skill template, Keep vs Remove findings, a data pipeline, an evaluation contract, and an engineering checklist for terminal, retrieval, and software-engineering tasks.
Post-training is easy to reduce to “memorize the successful traces.” Terminal operations, deep retrieval, and software-engineering repair all look like multi-step decisions: observe the environment, choose the next action, correct from feedback. If you only supervised-fine-tune on successful traces as gold answers, the student model often memorizes one surface order that happened to work, not transferable operating principles. Change the directory layout, the error text, or the ranking of retrieval hits, and the memory fails. A subtler issue is train–eval mismatch: training inputs are stuffed with temporary hints, tool returns, and human-written step notes that all disappear at evaluation, so the model faces a different input distribution.
Raising the agent from answer-taker to a “curriculum role” targets that gap. Curriculum work does not sit the exam for the student. It turns scattered successes into teachable skill specs: what the goal is, when to activate, input/output constraints, how to back off on failure, and which steps must not be skipped. The student reads those specs during training and produces the matching behavior. At the final exam, the specs are removed; only internalized parameters are tested. That split separates prompt engineering from capability learning and prevents eval-time prompt crutches from hiding training quality.
1. Fix experimental conditions before comparing methods
Whether skills help cannot be judged from a single demo. Reproducible comparison should lock four things.
First, freeze the teacher. The teacher that generates traces and skill specs, sampling temperature, stop conditions, and tool permissions stay constant. If the teacher changes, student score changes cannot be attributed.
Second, freeze the task pool. Terminal tasks cover file search, permissions, processes, and script debugging. Retrieval covers multi-hop queries, evidence checks, and conflict resolution. Software engineering covers defect localization, patch generation, and regression checks. Difficulty mix, languages, and repo scale are set in advance so “easy items” are not added later.
Third, freeze training sample size. Use the same number of traces for every method. Do not feed more data just because a method filters more successes. Sample size is a strong confounder.
Fourth, freeze the fine-tuning recipe. Learning rate, epochs, context length, whether loss is on responses only or the full sequence, and whether general instruction data is mixed, all live in one config. Method comparison may change only whether skill text stays in the input and how that text is produced.
Under that control, a common result is that data from a curriculum pipeline trains small-to-medium students better overall than ordinary SFT on successful traces alone, on the three task families above. Gains vary by task; terminal and engineering repair are often more stable than open retrieval because environment feedback is more verifiable. Report numbers only from your own controls; do not treat one experiment’s percentage points as universal constants.
2. A skill spec is not another system prompt
Specs should be short, executable, and checkable, not prose memoirs. A usable spec usually has five parts.
- Trigger: which observations activate the skill, so the same empty slogan is not applied at every step.
- Action skeleton: three to seven ordered actions, each tied to an observable environment change.
- Evidence rule: conclusions must point to command output, retrieved spans, or test results; no evidence-free claims.
- Failure backoff: next step when a command is non-zero, retrieval is empty, or a patch fails tests—not free-form retry.
- Stop: what counts as done, and when to give up and report a block.
A schematic template in plain text, not bound to any framework:
Skill: reproduce then patchTrigger: task asks to fix a defect and a failure description already existsSteps:1. Reproduce the failure with a minimal command and save output2. Read only the code range directly tied to the error3. Make one minimal change4. Re-run the same command to check the failure is gone5. If a new failure appears, revert the change and record the diffForbidden: large rewrites before reproduction; guessing instead of test outputDone: original failure gone and no same-severity new failure introduced
The teacher’s job is to draft or revise such specs next to real traces and check that the spec can explain key decisions in the trace. Student supervision maps “task + skill spec + observations” to “next action or final answer.” Skills are the textbook; traces are the worked examples. Do not fuse them into one unsplittable long prompt.
3. Why training should keep skill instructions even when evaluation strips them
Intuition says: to match the exam distribution, delete skill instructions from training inputs and keep only task and observations, with the same gold actions. Experiments often go the other way: with identical supervised outputs, Keep (skill text retained) beats Remove (skill text deleted). Across task groups, Keep is often stably a few points higher (about two to four percentage points in magnitude), but you must remeasure the delta on your pool.
The reason is not that the exam still shows the skill. The exam protocol requires the student to run with no generated skills, on internalized ability only. Keep acts in the gradient. The skill compresses “why this step is right” into an input-side condition. When fitting the same output string, the model is more likely to align to reusable operating principles than to accidental wording in one trace. After Remove, the same output must be memorized from principle-free inputs, so the model more easily learns surface co-occurrence: this error string followed by that command.
That does not contradict “train and serve should match.” Distribution matching is a constraint, not the only objective. If matching is done by deleting the only field that carries structure, the model gets an exam-like shell and a worse internal representation. A better pattern: keep skills in training, but keep the text stable, short, and bound to task type; at eval, always empty the field and report the empty-skill score. Do not substitute a with-skill score.
A third control—skills at both train and eval—measures the prompt’s ceiling, not student ability. Publish empty-skill scores externally; with-skill scores are only for diagnosing whether the spec is executable.
4. How to produce data without washing successful samples
Ordinary success filtering is biased: easy tasks succeed more, and error-correction signal in failures is discarded. Curriculum-style samples can follow this pipeline.
- Sample from the frozen task pool and log full interactions, including failure branches, not only the last success.
- Have the teacher draft a skill for each trace, covering backoff points in the trace.
- Filter by rules: drop specs that are too long, steps that are not observable, commands that contradict the environment, or specs that write the answer in. Leaking the final patch or answer into the skill is writing the exam key into the stem.
- Build paired samples. The same output is paired with Keep and Remove inputs so the only difference is the skill field.
- Hold out validation tasks the teacher never drafted skills for, so teacher-seen items do not leak into student eval.
Stratify sample size by task family, not global random sampling. Step-count distributions for terminal, retrieval, and engineering differ by an order of magnitude; without stratification, short tasks dominate the loss. A trace can be sliced into many “current observation → next step” examples, but slices of the same trace must not cross train and validation.
Compute loss only on actions and brief necessary reasons, not on the skill text itself. The skill is a condition, not a target to recite. If the spec is in the loss, capacity goes into repeating the textbook and the model is more fragile when the textbook is removed.
5. Evaluation protocol: zero mount at exam time
Eval must be a non-negotiable protocol or scores are meaningless.
- The student receives only the raw task, initial environment state, and live observations.
- Do not inject skill names, skill bodies, teacher drafts, or success-trace summaries.
- Tool permissions, timeouts, and retry counts match the baseline exactly.
- Terminal tasks: whether commands reach a checkable state. Retrieval: whether evidence supports the conclusion. Engineering: whether tests pass and the patch stays in bounds.
- Report all three family scores plus the average for the same checkpoint, and the delta versus ordinary success-trace SFT. Do not report only the best family.
Only if Keep is better in training and empty-skill eval is also better can you claim internalization. If only with-skill eval improves, you optimized the prompt, not the model. If Remove wins on empty-skill eval, check whether skills overfit the teacher’s voice, are too long and crowd out task context, or disagree with the outputs.
6. Engineering checklist for production pipelines
Treat the method as a data product, not a one-off script.
Versioning: number the task-pool version, teacher config, skill template, filters, and fine-tuning recipe separately. Any change re-runs Keep, Remove, and ordinary-trace groups; do not reuse old conclusions.
Spot checks: humans review a small set of skills to confirm answers are not written into steps. Automatic rules check that commands are in the allowed environment set and that retrieval citations exist in the observations.
Resources: the skill field lengthens inputs. Count tokens in advance so long skills do not truncate early observations. If truncation hits observations instead of skills, the model learns to read the spec and ignore the environment.
Regression: after each student update, replay the three families under the same empty-skill protocol. If the average rises but one family drops sharply, stop merging data and check whether that family’s skills over-generalized.
Safety: skills may describe only benign development and operations. Traces involving unauthorized access, credential theft, or destructive commands are dropped; they must not enter the textbook for “one more experience.”
Monitoring: if production still needs human prompts to finish tasks, internalization is insufficient. Go back to failure traces and add backoff steps. Do not permanently hang an ever-growing skill library in production. A skill library belongs in data production; it must not quietly become a hidden system prompt at eval or online.
7. What actually improves behavior versus just adding prompt text
Effective skills have three properties. They change the action distribution: under the same task, the order of critical steps is more stable than in ordinary traces. They are falsifiable: environment feedback can tell whether a step was done. They transfer: a surface-different, structure-same task still uses the same steps.
Ineffective skills are correct filler, e.g. “analyze carefully and give a high-quality answer.” Leaving such text in the input can even slightly hurt the Remove control: it occupies context without constraining actions. Another failure mode is a skill that only retells one trace’s concrete path; the model still learns an instance. Templates should use roles and conditions, not one-off file names and line numbers; those details stay in observations.
Constrain the teacher as well. “Freely summarize lessons” yields long, non-executable essays. Better: from failure points and the checks that finally passed, write only trigger, ordered steps, and stop, with a length cap. Student gains come from structure, not style.
8. Suggested practice order
Do not start by changing model architecture. Recommended order: lock the task pool and recipe; build an ordinary SFT baseline on existing successful traces; produce Keep and Remove paired data in parallel; compare all three under the empty-skill protocol; keep only skill templates that stably beat the baseline; then grow the task pool. At each step, answer whether score movement came from skills, more samples, a stronger teacher, or a looser eval.
For product teams, the direct gain is turning prompt assets into training assets. Skill specs teach during data generation; exam and production no longer depend on the same bolted-on text. For research teams, Keep beating Remove is a reminder that train–eval consistency is not “delete information.” It is: after seeing structure, the model can still decide at the same quality without a structure prompt. Measuring that difference is more valuable than another uncontrolled dump of successful traces.
