Cost Optimization
~9 min readUpdated: December 2026

AdaOPD: Multi-Turn Adaptive On-Policy Distillation with Prefix Replay

AdaOPD Multi-Turn Adaptive On-Policy Distillation with Prefix Replay Architecture in Smoke Monkey

AdaOPD (arXiv:2612.00078) solves the environment-rollout bottleneck in multi-turn on-policy agent distillation. By pairing adaptive history sampling (student-to-teacher likelihood ratio on recorded trajectories) with adaptive token-prefix weighting (teacher-to-student ratio on current-turn prefixes), AdaOPD distills Qwen3-30B-A3B-Instruct into Qwen3-8B to 58.7% macro-average accuracy—cutting rollout time per update by 75% versus online OPD.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

AdaOPD: Multi-Turn Adaptive On-Policy Distillation with Prefix Replay: AdaOPD (arXiv:2612.00078) solves the environment-rollout bottleneck in multi-turn on-policy agent distillation. By pairing adaptive history sampling (student-to-teacher likelihood ratio on recorded trajectories) with adaptive token-prefix weighting (teacher-to-student ratio on current-turn prefixes), AdaOPD distills Qwen3-30B-A3B-Instruct into Qwen3-8B to 58.7% macro-average accuracy—cutting rollout time per update by 75% versus online OPD. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.

Key Architectural Takeaways
Quick Implementation Exampleadaopd-distilled-worker-agent.ts
adaopd-distilled-worker-agent.tstypescript
import { createAgent } from '@smoke-monkey/harness';
// Deploy an AdaOPD-distilled Qwen3-8B student checkpoint locally via vLLM / Ollama
const agent = createAgent({
agentId: 'adaopd-qwen3-8b-python-worker',
provider: 'openai-compatible',
model: 'qwen3-8b-adaopd-py',
baseUrl: process.env.VLLM_BASE_URL || 'http://127.0.0.1:8000/v1',
apiKey: process.env.VLLM_API_KEY || 'local-key',
workspacePath: process.cwd(),
permissions: {
read_file: 'allow',
write_file: 'allow',
run_command: 'ask',
},
mcpServers: {
pythonSandbox: {
command: 'python3',
args: ['-m', 'mcp_python_interpreter', '--timeout', '15'],
},
},
});
async function main() {
const result = await agent.run(
'Write and execute a Python verification script for the matrix solver in src/solver.py and report exact residuals.'
);
console.log('Distilled 8B agent result:', result.summary);
}
main().catch(console.error);
Video Guides

Watch: Related Video Guides

On-Policy Distillation: LLM's Post-Training Meta of 2026

How On-Policy Distillation Changes LLM Weights

Why Naive Prefix Replay Suffers From Dual Distribution Mismatch

Online On-Policy Distillation (OPD) delivers dense token-level teacher feedback on a student agent's own rollouts, preventing compounding errors. However, for multi-turn tool-using agents (Python interpreters, bash shells, SQL sandboxes), running live environment interactions on every gradient step creates a severe latency bottleneck.

ReOPD replaces live environment execution with *prefix replay*—sampling a past teacher history and letting the student generate only the current turn. arXiv:2612.00078 proves that naive prefix replay splices two mismatched distributions:

  1. History Mismatch: The student trains on teacher-recorded histories it would rarely reach on its own policy.
  2. Intra-Turn Prefix Mismatch: Once the student emits a few divergent tokens inside the current turn, the teacher assigns near-zero probability to that partial prefix, destabilizing dense token-level KL updates.
Distillation Method (Teacher: Qwen3-30B-A3B -> Student: Qwen3-8B)AIME24AIME25AMC23MinervaOlympiadMATH500Macro Avg
Base Qwen3-8B21.3%11.3%43.1%37.2%34.4%64.8%35.3%
Cold Start SFT23.9%19.6%67.8%38.6%49.0%82.0%46.8%
Online OPD40.8%29.2%77.8%45.1%56.9%89.0%56.5%
ReOPD (Uniform Replay)40.8%33.8%83.4%42.5%55.6%88.1%57.4%
AdaOPD (Ours)44.2%36.3%82.2%44.0%56.2%89.2%58.7%

How AdaOPD Factorizes History Sampling & Token-Prefix Weighting

AdaOPD solves both mismatches from a single KL projection objective over spliced states, yielding two lightweight tempered likelihood ratios:

  • Adaptive History Weight: Computes a tempered student-to-teacher likelihood ratio on recorded teacher turns so replay sampling focuses on trajectories compatible with the student's current policy.
  • Adaptive Token-Prefix Weight: Scales per-token KL loss by a tempered teacher-to-student ratio over the student's preceding tokens within the turn, preventing erratic teacher gradients on diverged branches.
  • 4x Faster Multi-Turn Updates: Even after amortizing replay-pool scoring, AdaOPD cuts rollout time per update by ~75% relative to fully online OPD while gaining +2.2 points macro-average accuracy.

Pair AdaOPD Students with Frontier Orchestrators

Distilling domain-specific Python/bash tool traces from a 30B–100B teacher into an 8B AdaOPD student lets Smoke Monkey Canvas run parallel local subagents at sub-second latency and near-zero marginal cost.

Serving Distilled 8B Tool-Using Agents Locally

Once your AdaOPD student checkpoint is merged, serve it behind an OpenAI-compatible vLLM or Ollama endpoint with tool-calling enabled:

bash
# Serve distilled Qwen3-8B agent checkpoint on a single 24GB GPU (RTX 4090 / L4)
vllm serve ./checkpoints/qwen3-8b-adaopd \
  --served-model-name qwen3-8b-adaopd-py \
  --enable-auto-tool-choice \
  --tool-call-parser hermes \
  --max-model-len 32768 \
  --port 8000

Point Smoke Monkey Harness worker agents to http://127.0.0.1:8000/v1 for sovereign, low-latency code execution and math verification loops.

Google Search Questions & Answers

Frequently Asked Questions

Q:How does AdaOPD speed up multi-turn agent distillation?

Instead of interacting with live Python/code sandboxes on every update like online OPD, AdaOPD replays scored teacher histories and lets the student generate only the current turn—reducing rollout time per update by an estimated 75%.

Q:What accuracy did AdaOPD achieve when distilling Qwen3-30B-A3B-Instruct into Qwen3-8B?

After 100 updates, AdaOPD reached 58.7% macro-average accuracy across six benchmarks (AIME24 44.2%, AIME25 36.3%, AMC23 82.2%, Minerva 44.0%, Olympiad 56.2%, MATH500 89.2%), outperforming online OPD (56.5%) and ReOPD (57.4%).

Q:What is the difference between ReOPD and AdaOPD?

ReOPD samples prefix histories uniformly and weights all student tokens equally. AdaOPD introduces KL-derived adaptive history sampling and adaptive token-prefix weighting to correct off-policy drift.

Q:Where do distilled 8B agents fit inside Smoke Monkey Canvas?

Use an AdaOPD-distilled 8B model on local 24 GB GPUs as high-throughput verification, unit-testing, or Python calculation workers orchestrated by a frontier planner.

Related Alternatives & Comparisons

Related Architecture Guides

View all guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness