How microsoft/skillopt works
1. Repository shape: This is a Python package centered on SkillOpt, a system for optimizing a text “skill document” instead of model weights. The codebase is split into a reusable core library (skillopt/), a nightly offline companion for coding agents (skillopt_sleep/), integration plugins (plugins/), benchmark assets (data/, configs/, ckpt/), and a small WebUI package (skillopt_webui/).
2. Primary training pipeline: The main architecture is a closed loop: dataset → environment rollout → scoring/evaluation → reflection/aggregation → skill update → held-out validation gate → checkpoint export. That loop is implemented across skillopt/engine, skillopt/envs, skillopt/evaluation, skillopt/gradient, skillopt/optimizer, and skillopt/scheduler.
3. Benchmark/environment boundary: Each benchmark lives in skillopt/envs/<benchmark>/ and acts like an adapter layer around a specific task family. These packages contain the benchmark-specific dataloader, rollout, adapter, evaluator, prompt templates, and an initial.md seed skill. The built-in benchmarks include alfworld, docvqa, livemathematicianbench, officeqa, searchqa, and spreadsheetbench.
4. Model/backend abstraction: skillopt/model/ isolates all LLM or execution backends behind a common interface. The repo supports multiple external targets, including OpenAI/Azure OpenAI, Claude, Qwen, MiniMax, and Codex-style execution harnesses. This is an important architectural boundary: the optimizer does not depend on one model provider, only on the backend contract.
5. Skill state and updates: The “trainable parameter” is a markdown skill file, not neural weights. The optimizer subsystem (skillopt/optimizer/) produces bounded textual edits such as add/delete/replace, applies update policies, and supports variants like skill-aware updates, slow updates, meta-skill, clipping, scheduling, and autonomous learning-rate logic. The resulting artifact is typically a best_skill.md checkpoint.
6. Validation and safety gates: skillopt/evaluation/gate.py and related scoring utilities enforce the key control point in the system: an edited skill is only accepted if it improves validation performance. This separates candidate generation from promotion to the canonical skill checkpoint, which is what makes the process reproducible and stable.
7. Configuration and experiment control: configs/ defines benchmark-specific and feature-specific YAML configuration, with a shared base in configs/_base_/. scripts/train.py and scripts/eval_only.py are the top-level entry points for running training and evaluation, while scripts/run_*.sh provide benchmark-specific launch wrappers. The data/ directory holds predefined train/val/test splits via items.json manifests, and ckpt/ stores benchmark-specific skill checkpoints and notes.
8. Prompted reasoning and reflection: The repo is heavily prompt-driven. Shared prompt templates live in skillopt/prompts/, while each environment has its own rollout, analyst, and success/error prompts. This makes prompt selection part of the architecture: rollout generation, failure analysis, and skill rewriting are all explicit stages rather than ad hoc strings in application code.
9. SkillOpt-Sleep subsystem: skillopt_sleep/ is a separate offline self-evolution pipeline for local coding agents. It adds its own cycle around state tracking, memory, harvesting session traces, replaying tasks, judging outcomes, mining reusable skills, consolidating them, and applying a gate before promotion. It is conceptually similar to SkillOpt, but optimized for agent-session artifacts rather than benchmark rollouts.
10. Agent-tool integrations: The plugins/ directory contains external integration packages for Claude Code, Codex, Copilot, and OpenClaw. These are not the core optimizer, but they are important deployment boundaries: they connect SkillOpt-Sleep to real agent runtimes, session hooks, cron-based sleep jobs, and plugin-specific skill packaging.
11. WebUI and observability: skillopt_webui/ provides an optional dashboard for monitoring experiments. It is separate from the training engine, so the core optimization loop can run headless while the UI only observes or summarizes progress.
12. Extensibility model: The repository is designed around two extension points: add a new benchmark by creating a new skillopt/envs/<name>/ package, or add a new backend by implementing a new skillopt/model/*_backend.py and registering it in the model router/config. That separation is central to how the architecture scales across tasks and model providers.
13. Tests and contract checks: The tests/ folder validates core utilities, scoring, backend behavior, type contracts, and parts of the sleep engine. Architecturally, this reinforces that the stable interfaces are the JSON/text utilities, backend adapters, skill-aware reflection, and the sleep-cycle logic.
Main entry points: trainer.py Trainer · base.py Env Base · cycle.py Sleep Cycle · router.py Model Router
Components 25
SkillOpt Core
Main optimization library for benchmark-driven skill editing
- Trainer · Coordinates the closed optimization loop
skillopt/engine/trainer.py - Env Base · Shared benchmark environment contract
skillopt/envs/base.py - Model Router · Abstracts LLM and execution backends
skillopt/model/router.py - Validation Gate · Accepts or rejects candidate skill updates
skillopt/evaluation/gate.py - Reflection · Aggregates rollout signal into update guidance
skillopt/gradient/aggregate.py - Skill Update · Produces bounded edits to the skill document
skillopt/optimizer/rewrite.py - Update Policy · Controls timing and selection of updates
skillopt/scheduler/__init__.py
Benchmarks
Task-specific environment adapters and prompt bundles
- Alfworld · Task adapter for ALFWorld
skillopt/envs/alfworld - DocVQA · Task adapter for document QA
skillopt/envs/docvqa - Live Math · Task adapter for live mathematics
skillopt/envs/livemathematicianbench - OfficeQA · Task adapter for office tasks
skillopt/envs/officeqa - SearchQA · Task adapter for search-based QA
skillopt/envs/searchqa - Spreadsheet · Task adapter for spreadsheet reasoning
skillopt/envs/spreadsheetbench
SkillOpt Sleep
Offline self-evolution pipeline for agent-session artifacts
- Sleep Cycle · Runs the SkillOpt-Sleep self-evolution loop
skillopt_sleep/cycle.py - Memory · Tracks reusable agent memories and state
skillopt_sleep/memory.py - Harvest · Collects session traces and artifacts
skillopt_sleep/harvest.py - Mine Skills · Extracts candidate reusable skills
skillopt_sleep/mine.py - Sleep Gate · Promotes mined skills after evaluation
skillopt_sleep/gate.py
Integrations
External plugin and UI deployment surfaces
- Claude Code · Agent integration for Claude Code
plugins/claude-code - Codex · Agent integration for Codex runtimes
plugins/codex - Copilot · Copilot instructions and MCP integration
plugins/copilot - OpenClaw · Sleep runner and task hooks for OpenClaw
plugins/openclaw - WebUI · Optional experiment monitoring UI
skillopt_webui/app.py
Connections 26
- Train → Trainer: launches · Training entrypoint starts the main orchestrator
- Eval Only → Trainer: runs · Evaluation entrypoint reuses the core runner
- Trainer → Env Base: loads tasks · Trainer instantiates benchmark environments
- Trainer → Model Router: queries · Rollouts and analyses call through backend abstraction
- Trainer → Reflection: analyzes · Aggregates rollout outcomes into reflection signal
- Reflection → Skill Update: guides · Reflection informs skill rewrite proposals
- Skill Update → Update Policy: updates · Scheduler controls when candidate edits are applied
- Update Policy → Validation Gate: submits · Promoted candidates are checked by validation gate
- Validation Gate → Trainer: accepts/rejects · Gate determines whether checkpoint advances
- Env Base → Alfworld: implements · Concrete benchmark adapter
- Env Base → DocVQA: implements · Concrete benchmark adapter
- Env Base → Live Math: implements · Concrete benchmark adapter
- Env Base → OfficeQA: implements · Concrete benchmark adapter
- Env Base → SearchQA: implements · Concrete benchmark adapter
- Env Base → Spreadsheet: implements · Concrete benchmark adapter
- Sleep Cycle → Harvest: collects · Offline cycle begins with trace ingestion
- Harvest → Memory: stores · Harvested artifacts are accumulated in memory
- Memory → Mine Skills: feeds · Stored traces become mining input
- Mine Skills → Sleep Gate: proposes · Mined skills are evaluated before promotion
- Sleep Gate → Sleep Cycle: promotes · Accepted skills re-enter the cycle
- Claude Code → Sleep Cycle: hooks into · Plugin provides runtime hooks for sleep jobs
- Codex → Sleep Cycle: packages · Plugin bundles skillopt-sleep integration
- Copilot → Sleep Cycle: connects · Plugin exposes Copilot integration boundary
- OpenClaw → Sleep Cycle: runs · Plugin wraps sleep execution for OpenClaw
- WebUI → Trainer: observes · UI monitors experiment progress and results
- Model Router → Trainer: serves backends · Backend router supplies model and execution targets