AI Agent: Design Principles and Engineering Practice is an open-source book that explains how AI agents combine language models, context, and tools, with accompanying experiments and code. It is intended for readers studying the principles and engineering of AI agents, from fundamentals through production use. The catalogue skills support coding-agent work related to the book's subject matter.
Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add bojieli/ai-agent-book --skill post-training-strategygit clone --depth 1 https://github.com/bojieli/ai-agent-bookWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/bojieli/ai-agent-book/post-training-strategy)<a href="https://agentmods.dev/skills/bojieli/ai-agent-book/post-training-strategy"><img src="https://agentmods.dev/badge/skills/bojieli/ai-agent-book/post-training-strategy/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/bojieli/ai-agent-book/post-training-strategy"><img src="https://agentmods.dev/badge/skills/bojieli/ai-agent-book/post-training-strategy.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00159 | $0.04586 |
| Opus 5.5 | $0.00064 | $0.01834 |
| Sonnet 5.5 | $0.00032 | $0.00917 |
| Haiku 4.5 | $0.00016 | $0.00459 |
Grade A, and why
post-training-strategy scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 22d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 117 lines — stays where its author put it; the contents beside it link to each section on GitHub.
模型后训练策略
何时使用
- 模型在某类任务上"做不好",要判断是缺底座、缺协议还是缺策略
- 决定项目走 Mid-training / SFT / RL 哪条路线,或要不要做 RL
- 构造 Mid-training 语料、SFT 示范数据、拒绝采样数据
- 搭建 RL 训练环境、选择 RL 算法与 LoRA 超参
- 用蒸馏提升样本效率(CoT 蒸馏、Prompt 蒸馏、在轨蒸馏、自蒸馏)
- RL 训练不收敛、组内无差异、更新后能力退化,需要定位原因
核心原则
- 四阶段不是三种"微调力度",而是分别处理底座、协议与策略。 Mid-training 补知识与基础能力,SFT 固化输出格式与行为协议,RL 重新分配概率质量并探索示范之外的策略。三者各有进入门槛,不是流水线仪式。
- 数据和环境比算法更重要。 决定成败的是 Mid-training 语料是否补齐底座、示范数据是否建立行为协议、仿真环境与奖励是否提供可靠试错反馈。PPO/GRPO 的基本用法掌握即可,很多场景下前两类数据到位后根本不需要 RL。
pass@k是最重要的分流指标。 在留出任务上以接近训练的溫度采样:pass@k = 1-(1-p)^k。pass@1低但pass@k随 k 明显上升 → 正确策略已在分布里,RL/拒绝采样/蒸馏有东西可放大;合理 k 与温度下pass@k仍近零 → 基模几乎生成不出成功轨迹,此时只给 0/1 奖励,GRPO 一组 rollout 全为 0,组内优势直接消失。- "SFT 记忆、RL 泛化"是受控实验下测得的倾向,不是普遍属性。 数据足够多样、正则化得当时 SFT 也能泛化;奖励或环境有偏时 RL 也会过拟合。机制解释:极大似然 SFT 有 mass-covering 倾向,RL 配合反向 KL 有 mode-seeking 倾向。
- SFT 与预训练是同一个数学任务(预测下一个词),差别只在数据组织和损失屏蔽(只在回答 token 上回传梯度)。所以 SFT 样本效率极高(几千条见效),也因此在示范覆盖不足时容易记住问法而非形成知识。
- LoRA 是工程默认项:必须应用到所有主要权重矩阵(尤其参数占比最大的 MLP,只加注意力层会掉点);最优学习率约为全参微调的 10 倍;SFT 用中高 rank(64–256),RL 每轮信息量小、用小 rank(8–32)甚至 1。
- on-policy 是数值问题,不只是调度问题。 采样引擎与训练引擎的浮点差异会让更新前本应为 1 的概率比偏离 1,把名义上的 on-policy 悄悄变成 off-policy。sampler/trainer 一致性应与奖励曲线同等重要。
实践模式
1. 路线决策:先诊断缺口,再选方法
| 观察到的现象 | 主要缺口 | 优先方法 | 进入下一阶段的门槛 |
|---|---|---|---|
领域概念、语言或基础操作不会;合理采样下 pass@k 仍近 0 |
知识与能力不在基模有效支持中 | Mid-training;动态事实用 RAG | 领域留出集改善、通用保留集可接受、目标任务开始出现可验证的正确或部分正确轨迹 |
| 偶尔能做对,但格式、工具 schema、语气或固定流程不稳定 | 行为协议没固化 | SFT 或约束解码 | 解析成功率稳定,关键动作与输出协议可被验证器可靠评分 |
| 已有非零成功率和可靠奖励,但好策略概率低、长程决策或 OOD 泛化不足 | 概率质量分配与策略优化 | RL | 奖励与真实目标一致;rollout 组内有足够奖励差异;独立测试集随训练改善 |
| 只有少量稳定示范,尚无可交互环境 | 可模仿数据有、在线反馈无 | SFT/RFT/离线偏好优化 | 先建立基线与评估,再判断是否值得建 RL 环境 |
决策顺序:① 先排除不需要改权重的方案(prompt、工具、代码约束、上下文管理能解决就不训练;事实需频繁更新/引用/删除就走 RAG)→ ② 在目标留出集测能力支持(不只贪心 pass@1,还看固定采样配置下的 pass@k、部分进展率、格式解析率,并人工审计失败原因)→ ③ 用 SFT 立协议,不拿它硬塞知识库 → ④ 只在有探索空间时上 RL。
2. Mid-training:补底座
数据构造五步:从失败分布反推数据(按主题/语言/文档类型/代码模式/上下文长度切分评估,只针对知识与能力缺口补,别把输出格式错误误诊成知识不足)→ 构造高密度目标语料(原始文档建立术语事实关联,代码仓库学结构与依赖,教材式推导与合成释义把隐含关系写明确;做去重、质量过滤、评估集污染检查)→ 按能力配比(自然长文本 + 长文本原子能力思维链 + Agent 执行轨迹,后两类可从较强开源模型蒸馏)→ 每个阶段做双重回放(原始短文本与通用数据保留语言知识;"长度提升后的旧任务"检验同一能力在更长窗口仍成立;通用数据最好来自基模原始预训练集,取不到用 FineWeb-2 类开源语料)→ 多维门禁决定停止(留出领域任务、通用能力、原有指令遵循、目标任务 pass@1/pass@k 同时跟踪;领域升而通用降 = 混合或学习率过激,loss 降而 pass@k 不动 = 数据没覆盖所需能力或缺少访问知识的 SFT)。
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 22d ago First seen · 117 lines · 159 tokens per session scan A 34b7b049bb42
post-training-strategy is a skill published in the GitHub repository bojieli/ai-agent-book (54,406 stars, last pushed 7d ago), licensed Apache-2.0. It adds 159 tokens to every session and 4,586 once invoked, about $0.0006 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-24.
Other skills, from other repositories
v4-best-practices
Use when working with deepseek-v4-pro or deepseek-v4-flash in thinking mode on multi-step or plan-driven tasks. Provides rules to prevent stale references, unverified plan assumptions, and vague plan output.
llm-redteam-overview
LLM red team category — full AATMF v3 tactic coverage (T01–T15). Routing skill: read this first to identify which tactic applies, then load the matching sub-skill. Maps to MITRE ATLAS where overlap exists.
omh-model-setup
This is a Hermes-native model-setup workflow skill.
omh-model-optimization
This is a Hermes-native model-optimization workflow skill.
model-onboarding
Onboard a new model generation or sibling into oh-my-hermes: probe router recognition, research the official contract, write trait-to-counter calibration, place routing in both lanes, price from documented list only, gate machine config on a served route, prove with the gates, close with a benchmark pair. Use when a…
omh-llm-app-dev
This is an OMH llm-app-dev workflow skill, projected for Agent Skills hosts (Claude Code, Codex, Cursor, opencode, OpenClaw, pi).