self-evolve-framework 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/package.json +1 -1
  2. package/template/rules/ponytail.mdc +98 -23
  3. package/template/skills/skillopt-sleep/SKILL.md +48 -34
  4. package/template/skills/skillopt-sleep/scripts/python/__init__.py +20 -0
  5. package/template/skills/skillopt-sleep/scripts/python/__main__.py +343 -0
  6. package/template/skills/skillopt-sleep/scripts/python/backend.py +1371 -0
  7. package/template/skills/skillopt-sleep/scripts/python/budget.py +75 -0
  8. package/template/skills/skillopt-sleep/scripts/python/config.py +162 -0
  9. package/template/skills/skillopt-sleep/scripts/python/consolidate.py +238 -0
  10. package/template/skills/skillopt-sleep/scripts/python/cycle.py +291 -0
  11. package/template/skills/skillopt-sleep/scripts/python/dream.py +138 -0
  12. package/template/skills/skillopt-sleep/scripts/python/experiments/__init__.py +1 -0
  13. package/template/skills/skillopt-sleep/scripts/python/experiments/gbrain_bench.py +119 -0
  14. package/template/skills/skillopt-sleep/scripts/python/experiments/personas.py +86 -0
  15. package/template/skills/skillopt-sleep/scripts/python/experiments/report.py +132 -0
  16. package/template/skills/skillopt-sleep/scripts/python/experiments/run_experiment.py +178 -0
  17. package/template/skills/skillopt-sleep/scripts/python/experiments/run_gbrain.py +209 -0
  18. package/template/skills/skillopt-sleep/scripts/python/experiments/run_transfer.py +155 -0
  19. package/template/skills/skillopt-sleep/scripts/python/experiments/sweep.py +164 -0
  20. package/template/skills/skillopt-sleep/scripts/python/gate.py +50 -0
  21. package/template/skills/skillopt-sleep/scripts/python/harvest.py +304 -0
  22. package/template/skills/skillopt-sleep/scripts/python/harvest_codex.py +253 -0
  23. package/template/skills/skillopt-sleep/scripts/python/harvest_sources.py +41 -0
  24. package/template/skills/skillopt-sleep/scripts/python/judges.py +84 -0
  25. package/template/skills/skillopt-sleep/scripts/python/llm_miner.py +134 -0
  26. package/template/skills/skillopt-sleep/scripts/python/memory.py +129 -0
  27. package/template/skills/skillopt-sleep/scripts/python/mine.py +312 -0
  28. package/template/skills/skillopt-sleep/scripts/python/replay.py +146 -0
  29. package/template/skills/skillopt-sleep/scripts/python/rollout.py +153 -0
  30. package/template/skills/skillopt-sleep/scripts/python/scheduler.py +138 -0
  31. package/template/skills/skillopt-sleep/scripts/python/slow_update.py +142 -0
  32. package/template/skills/skillopt-sleep/scripts/python/staging.py +103 -0
  33. package/template/skills/skillopt-sleep/scripts/python/state.py +96 -0
  34. package/template/skills/skillopt-sleep/scripts/python/tasks_file.py +81 -0
  35. package/template/skills/skillopt-sleep/scripts/python/types.py +146 -0
  36. package/template/skills/skillopt-sleep/scripts/shell/__init__.py +0 -0
  37. package/template/skills/skillopt-sleep/scripts/shell/eval_only.py +466 -0
  38. package/template/skills/skillopt-sleep/scripts/shell/materialize_searchqa.py +148 -0
  39. package/template/skills/skillopt-sleep/scripts/shell/run_alfworld.sh +60 -0
  40. package/template/skills/skillopt-sleep/scripts/shell/run_searchqa.sh +40 -0
  41. package/template/skills/skillopt-sleep/scripts/shell/run_spreadsheetbench.sh +39 -0
  42. package/template/skills/skillopt-sleep/scripts/shell/train.py +556 -0
  43. package/template/skills/ponytail/SKILL.md +0 -117
  44. package/template/skills/ponytail-audit/SKILL.md +0 -41
  45. package/template/skills/ponytail-debt/SKILL.md +0 -44
  46. package/template/skills/ponytail-gain/SKILL.md +0 -50
  47. package/template/skills/ponytail-help/SKILL.md +0 -69
  48. package/template/skills/ponytail-review/SKILL.md +0 -57
@@ -0,0 +1,556 @@
1
+ #!/usr/bin/env python3
2
+ """SkillOpt unified training entry point.
3
+
4
+ Usage
5
+ -----
6
+ python scripts/train.py --config configs/alfworld/default.yaml
7
+
8
+ Any YAML key can be overridden from the command line::
9
+
10
+ python scripts/train.py --config configs/alfworld/default.yaml \\
11
+ --batch_size 40 --num_epochs 2 --seed 123
12
+
13
+ Run ``python scripts/train.py --help`` for a full list of options.
14
+ """
15
+ from __future__ import annotations
16
+
17
+ import argparse
18
+ import datetime
19
+ import os
20
+ import sys
21
+
22
+ # Ensure the project root is on sys.path so ``import skillopt`` works
23
+ # regardless of where the script is invoked from.
24
+ _SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
25
+ _PROJECT_ROOT = os.path.dirname(_SCRIPT_DIR)
26
+ if _PROJECT_ROOT not in sys.path:
27
+ sys.path.insert(0, _PROJECT_ROOT)
28
+
29
+ from skillopt.model.common import default_model_for_backend, normalize_backend_name
30
+
31
+ _OPENAI_DEFAULT_MODEL_SENTINELS = {"gpt-5.4", "gpt-5.5"}
32
+
33
+
34
+ # ── Environment registry ────────────────────────────────────────────────────
35
+
36
+ _ENV_REGISTRY: dict[str, type] = {}
37
+
38
+
39
+ def _register_builtins() -> None:
40
+ """Lazy-import built-in adapters so we don't pull heavy deps at CLI parse time."""
41
+ try:
42
+ from skillopt.envs.alfworld.adapter import ALFWorldAdapter
43
+ _ENV_REGISTRY["alfworld"] = ALFWorldAdapter
44
+ except ImportError:
45
+ pass # ALFWorld deps not installed — skip
46
+ try:
47
+ from skillopt.envs.searchqa.adapter import SearchQAAdapter
48
+ _ENV_REGISTRY["searchqa"] = SearchQAAdapter
49
+ except ImportError:
50
+ pass
51
+ try:
52
+ from skillopt.envs.livemathematicianbench.adapter import LiveMathematicianBenchAdapter
53
+ _ENV_REGISTRY["livemathematicianbench"] = LiveMathematicianBenchAdapter
54
+ except ImportError:
55
+ pass
56
+ try:
57
+ from skillopt.envs.babyvision.adapter import BabyVisionAdapter
58
+ _ENV_REGISTRY["babyvision"] = BabyVisionAdapter
59
+ except ImportError:
60
+ pass
61
+ try:
62
+ from skillopt.envs.spreadsheetbench.adapter import SpreadsheetBenchAdapter
63
+ _ENV_REGISTRY["spreadsheetbench"] = SpreadsheetBenchAdapter
64
+ except ImportError:
65
+ pass
66
+ try:
67
+ from skillopt.envs.mmrb.adapter import MMRBAdapter
68
+ _ENV_REGISTRY["mmrb"] = MMRBAdapter
69
+ except ImportError:
70
+ pass
71
+ try:
72
+ from skillopt.envs.docvqa.adapter import DocVQAAdapter
73
+ _ENV_REGISTRY["docvqa"] = DocVQAAdapter
74
+ except ImportError:
75
+ pass
76
+ try:
77
+ from skillopt.envs.mathverse.adapter import MathVerseAdapter
78
+ _ENV_REGISTRY["mathverse"] = MathVerseAdapter
79
+ except ImportError:
80
+ pass
81
+ try:
82
+ from skillopt.envs.officeqa.adapter import OfficeQAAdapter
83
+ _ENV_REGISTRY["officeqa"] = OfficeQAAdapter
84
+ except ImportError:
85
+ pass
86
+ try:
87
+ from skillopt.envs.sealqa.adapter import SealQAAdapter
88
+ _ENV_REGISTRY["sealqa"] = SealQAAdapter
89
+ except ImportError:
90
+ pass
91
+ try:
92
+ from skillopt.envs.swebench.adapter import SWEBenchAdapter
93
+ _ENV_REGISTRY["swebench"] = SWEBenchAdapter
94
+ except ImportError:
95
+ pass
96
+
97
+
98
+ def get_adapter(cfg: dict):
99
+ """Instantiate the environment adapter specified in ``cfg["env"]``."""
100
+ _register_builtins()
101
+ env_name = cfg.get("env", "alfworld")
102
+ if env_name not in _ENV_REGISTRY:
103
+ raise ValueError(
104
+ f"Unknown environment '{env_name}'. "
105
+ f"Available: {list(_ENV_REGISTRY.keys())}"
106
+ )
107
+ adapter_cls = _ENV_REGISTRY[env_name]
108
+
109
+ # Inspect adapter __init__ signature and only pass accepted kwargs
110
+ import inspect
111
+ sig = inspect.signature(adapter_cls.__init__)
112
+ accepted = set(sig.parameters.keys()) - {"self"}
113
+ adapter_kwargs: dict = {}
114
+ for key in accepted:
115
+ if key in cfg:
116
+ adapter_kwargs[key] = cfg[key]
117
+
118
+ return adapter_cls(**adapter_kwargs)
119
+
120
+
121
+ # ── CLI ──────────────────────────────────────────────────────────────────────
122
+
123
+ _BOOL = lambda x: x.lower() in ("true", "1", "yes") # noqa: E731
124
+
125
+
126
+ def parse_args() -> argparse.Namespace:
127
+ p = argparse.ArgumentParser(
128
+ description="SkillOpt: Executive Strategy for Self-Evolving Agent Skills",
129
+ formatter_class=argparse.RawDescriptionHelpFormatter,
130
+ epilog=__doc__,
131
+ )
132
+ p.add_argument("--config", type=str, required=True,
133
+ help="Path to YAML config file")
134
+ p.add_argument("--cfg-options", nargs="+", default=[],
135
+ help="Override config: section.key=value (e.g. train.batch_size=40)")
136
+
137
+ # Legacy flat CLI overrides (still work, prefer --cfg-options for new usage)
138
+ p.add_argument("--env", type=str)
139
+ p.add_argument("--backend", type=str,
140
+ choices=["azure_openai", "codex", "codex_exec", "claude", "claude_chat", "claude_code_exec", "qwen", "qwen_chat", "minimax", "minimax_chat"])
141
+ p.add_argument("--optimizer_model", type=str)
142
+ p.add_argument("--target_model", type=str)
143
+ p.add_argument("--optimizer_backend", type=str)
144
+ p.add_argument("--target_backend", type=str)
145
+ p.add_argument("--reasoning_effort", type=str,
146
+ choices=["", "low", "medium", "high", "xhigh", "max"])
147
+ p.add_argument("--rewrite_reasoning_effort", type=str)
148
+ p.add_argument("--rewrite_max_completion_tokens", type=int)
149
+ p.add_argument("--azure_endpoint", type=str)
150
+ p.add_argument("--azure_api_version", type=str)
151
+ p.add_argument("--azure_api_key", type=str)
152
+ p.add_argument("--azure_openai_endpoint", type=str)
153
+ p.add_argument("--azure_openai_api_version", type=str)
154
+ p.add_argument("--azure_openai_api_key", type=str)
155
+ p.add_argument("--azure_openai_auth_mode", type=str)
156
+ p.add_argument("--azure_openai_ad_scope", type=str)
157
+ p.add_argument("--azure_openai_managed_identity_client_id", type=str)
158
+ p.add_argument("--optimizer_azure_openai_endpoint", type=str)
159
+ p.add_argument("--optimizer_azure_openai_api_version", type=str)
160
+ p.add_argument("--optimizer_azure_openai_api_key", type=str)
161
+ p.add_argument("--optimizer_azure_openai_auth_mode", type=str)
162
+ p.add_argument("--optimizer_azure_openai_ad_scope", type=str)
163
+ p.add_argument("--optimizer_azure_openai_managed_identity_client_id", type=str)
164
+ p.add_argument("--target_azure_openai_endpoint", type=str)
165
+ p.add_argument("--target_azure_openai_api_version", type=str)
166
+ p.add_argument("--target_azure_openai_api_key", type=str)
167
+ p.add_argument("--target_azure_openai_auth_mode", type=str)
168
+ p.add_argument("--target_azure_openai_ad_scope", type=str)
169
+ p.add_argument("--target_azure_openai_managed_identity_client_id", type=str)
170
+ p.add_argument("--qwen_chat_base_url", type=str)
171
+ p.add_argument("--qwen_chat_api_key", type=str)
172
+ p.add_argument("--qwen_chat_temperature", type=float)
173
+ p.add_argument("--qwen_chat_timeout_seconds", type=float)
174
+ p.add_argument("--qwen_chat_max_tokens", type=int)
175
+ p.add_argument("--qwen_chat_enable_thinking", type=_BOOL)
176
+ p.add_argument("--optimizer_qwen_chat_base_url", type=str)
177
+ p.add_argument("--optimizer_qwen_chat_api_key", type=str)
178
+ p.add_argument("--optimizer_qwen_chat_temperature", type=float)
179
+ p.add_argument("--optimizer_qwen_chat_timeout_seconds", type=float)
180
+ p.add_argument("--optimizer_qwen_chat_max_tokens", type=int)
181
+ p.add_argument("--optimizer_qwen_chat_enable_thinking", type=_BOOL)
182
+ p.add_argument("--target_qwen_chat_base_url", type=str)
183
+ p.add_argument("--target_qwen_chat_api_key", type=str)
184
+ p.add_argument("--target_qwen_chat_temperature", type=float)
185
+ p.add_argument("--target_qwen_chat_timeout_seconds", type=float)
186
+ p.add_argument("--target_qwen_chat_max_tokens", type=int)
187
+ p.add_argument("--target_qwen_chat_enable_thinking", type=_BOOL)
188
+ p.add_argument("--minimax_base_url", type=str)
189
+ p.add_argument("--minimax_api_key", type=str)
190
+ p.add_argument("--minimax_model", type=str)
191
+ p.add_argument("--minimax_temperature", type=float)
192
+ p.add_argument("--minimax_max_tokens", type=int)
193
+ p.add_argument("--minimax_enable_thinking", type=_BOOL)
194
+ p.add_argument("--codex_exec_path", type=str)
195
+ p.add_argument("--codex_exec_sandbox", type=str)
196
+ p.add_argument("--codex_exec_profile", type=str)
197
+ p.add_argument("--codex_exec_full_auto", type=_BOOL)
198
+ p.add_argument("--codex_exec_reasoning_effort", type=str)
199
+ p.add_argument("--codex_exec_use_sdk", type=str)
200
+ p.add_argument("--codex_exec_network_access", type=_BOOL)
201
+ p.add_argument("--codex_exec_web_search", type=_BOOL)
202
+ p.add_argument("--codex_exec_approval_policy", type=str)
203
+ p.add_argument("--claude_code_exec_path", type=str)
204
+ p.add_argument("--claude_code_exec_profile", type=str)
205
+ p.add_argument("--claude_code_exec_use_sdk", type=str)
206
+ p.add_argument("--claude_code_exec_effort", type=str)
207
+ p.add_argument("--claude_code_exec_max_thinking_tokens", type=int)
208
+ p.add_argument("--codex_trace_to_optimizer", type=_BOOL)
209
+ p.add_argument("--skill_init", type=str)
210
+ p.add_argument("--num_epochs", type=int)
211
+ p.add_argument("--train_size", type=int)
212
+ p.add_argument("--steps_per_epoch", type=int)
213
+ p.add_argument("--batch_size", type=int)
214
+ p.add_argument("--accumulation", type=int)
215
+ p.add_argument("--seed", type=int)
216
+ p.add_argument("--edit_budget", type=int)
217
+ p.add_argument("--min_edit_budget", type=int)
218
+ p.add_argument("--lr_scheduler", type=str,
219
+ choices=["constant", "linear", "cosine", "autonomous"])
220
+ p.add_argument("--lr_control_mode", type=str,
221
+ choices=["fixed", "autonomous", "none"])
222
+ p.add_argument("--merge_batch_size", type=int)
223
+ p.add_argument("--max_analyst_rounds", type=int)
224
+ p.add_argument("--sel_env_num", type=int)
225
+ p.add_argument("--test_env_num", type=int)
226
+ p.add_argument("--eval_test", type=_BOOL)
227
+ p.add_argument("--use_gate", type=_BOOL)
228
+ p.add_argument("--max_steps", type=int)
229
+ p.add_argument("--max_api_workers", type=int)
230
+ p.add_argument("--analyst_workers", type=int)
231
+ p.add_argument("--failure_only", type=_BOOL)
232
+ p.add_argument("--minibatch_size", type=int)
233
+ p.add_argument("--skill_update_mode", type=str,
234
+ choices=[
235
+ "patch",
236
+ "rewrite_from_suggestions",
237
+ "rewrite",
238
+ "suggestions",
239
+ "full_rewrite",
240
+ "full_rewrite_minibatch",
241
+ "minibatch_full_rewrite",
242
+ ])
243
+ p.add_argument("--use_slow_update", type=_BOOL)
244
+ p.add_argument("--slow_update_samples", type=int)
245
+ p.add_argument("--longitudinal_pair_policy", type=str,
246
+ choices=["mixed", "changed", "unchanged"])
247
+ p.add_argument("--use_meta_skill", type=_BOOL)
248
+ p.add_argument("--use_skill_aware_reflection", type=_BOOL)
249
+ p.add_argument("--skill_aware_appendix_source", type=str,
250
+ choices=["both", "failure_only"])
251
+ p.add_argument("--skill_aware_consolidate_threshold", type=int)
252
+ p.add_argument("--data_path", type=str)
253
+ p.add_argument("--split_mode", type=str,
254
+ choices=["ratio", "split_dir"])
255
+ p.add_argument("--split_ratio", type=str)
256
+ p.add_argument("--split_seed", type=int)
257
+ p.add_argument("--split_dir", type=str)
258
+ p.add_argument("--split_output_dir", type=str)
259
+ p.add_argument("--data_root", type=str)
260
+ p.add_argument("--max_turns", type=int)
261
+ p.add_argument("--workers", type=int)
262
+ p.add_argument("--limit", type=int)
263
+ p.add_argument("--shuffle_choices", type=_BOOL)
264
+ p.add_argument("--use_theorem", type=_BOOL)
265
+ p.add_argument("--use_sketch", type=_BOOL)
266
+ p.add_argument("--image_detail", type=str)
267
+ p.add_argument("--judge_model", type=str)
268
+ p.add_argument("--judge_max_completion_tokens", type=int)
269
+ p.add_argument("--judge_retries", type=int)
270
+ p.add_argument("--out_root", type=str)
271
+ p.add_argument("--mode", type=str)
272
+
273
+ return p.parse_args()
274
+
275
+
276
+ # ── Flat key → structured path mapping (for legacy CLI → structured config) ──
277
+
278
+ _LEGACY_TO_STRUCTURED: dict[str, str] = {
279
+ "backend": "model.backend",
280
+ "optimizer_model": "model.optimizer",
281
+ "target_model": "model.target",
282
+ "optimizer_backend": "model.optimizer_backend",
283
+ "target_backend": "model.target_backend",
284
+ "reasoning_effort": "model.reasoning_effort",
285
+ "rewrite_reasoning_effort": "model.rewrite_reasoning_effort",
286
+ "rewrite_max_completion_tokens": "model.rewrite_max_completion_tokens",
287
+ "azure_endpoint": "model.azure_endpoint",
288
+ "azure_api_version": "model.azure_api_version",
289
+ "azure_api_key": "model.azure_api_key",
290
+ "azure_openai_endpoint": "model.azure_openai_endpoint",
291
+ "azure_openai_api_version": "model.azure_openai_api_version",
292
+ "azure_openai_api_key": "model.azure_openai_api_key",
293
+ "azure_openai_auth_mode": "model.azure_openai_auth_mode",
294
+ "azure_openai_ad_scope": "model.azure_openai_ad_scope",
295
+ "azure_openai_managed_identity_client_id": "model.azure_openai_managed_identity_client_id",
296
+ "optimizer_azure_openai_endpoint": "model.optimizer_azure_openai_endpoint",
297
+ "optimizer_azure_openai_api_version": "model.optimizer_azure_openai_api_version",
298
+ "optimizer_azure_openai_api_key": "model.optimizer_azure_openai_api_key",
299
+ "optimizer_azure_openai_auth_mode": "model.optimizer_azure_openai_auth_mode",
300
+ "optimizer_azure_openai_ad_scope": "model.optimizer_azure_openai_ad_scope",
301
+ "optimizer_azure_openai_managed_identity_client_id": "model.optimizer_azure_openai_managed_identity_client_id",
302
+ "target_azure_openai_endpoint": "model.target_azure_openai_endpoint",
303
+ "target_azure_openai_api_version": "model.target_azure_openai_api_version",
304
+ "target_azure_openai_api_key": "model.target_azure_openai_api_key",
305
+ "target_azure_openai_auth_mode": "model.target_azure_openai_auth_mode",
306
+ "target_azure_openai_ad_scope": "model.target_azure_openai_ad_scope",
307
+ "target_azure_openai_managed_identity_client_id": "model.target_azure_openai_managed_identity_client_id",
308
+ "qwen_chat_base_url": "model.qwen_chat_base_url",
309
+ "qwen_chat_api_key": "model.qwen_chat_api_key",
310
+ "qwen_chat_temperature": "model.qwen_chat_temperature",
311
+ "qwen_chat_timeout_seconds": "model.qwen_chat_timeout_seconds",
312
+ "qwen_chat_max_tokens": "model.qwen_chat_max_tokens",
313
+ "qwen_chat_enable_thinking": "model.qwen_chat_enable_thinking",
314
+ "optimizer_qwen_chat_base_url": "model.optimizer_qwen_chat_base_url",
315
+ "optimizer_qwen_chat_api_key": "model.optimizer_qwen_chat_api_key",
316
+ "optimizer_qwen_chat_temperature": "model.optimizer_qwen_chat_temperature",
317
+ "optimizer_qwen_chat_timeout_seconds": "model.optimizer_qwen_chat_timeout_seconds",
318
+ "optimizer_qwen_chat_max_tokens": "model.optimizer_qwen_chat_max_tokens",
319
+ "optimizer_qwen_chat_enable_thinking": "model.optimizer_qwen_chat_enable_thinking",
320
+ "target_qwen_chat_base_url": "model.target_qwen_chat_base_url",
321
+ "target_qwen_chat_api_key": "model.target_qwen_chat_api_key",
322
+ "target_qwen_chat_temperature": "model.target_qwen_chat_temperature",
323
+ "target_qwen_chat_timeout_seconds": "model.target_qwen_chat_timeout_seconds",
324
+ "target_qwen_chat_max_tokens": "model.target_qwen_chat_max_tokens",
325
+ "target_qwen_chat_enable_thinking": "model.target_qwen_chat_enable_thinking",
326
+ "minimax_base_url": "model.minimax_base_url",
327
+ "minimax_api_key": "model.minimax_api_key",
328
+ "minimax_model": "model.minimax_model",
329
+ "minimax_temperature": "model.minimax_temperature",
330
+ "minimax_max_tokens": "model.minimax_max_tokens",
331
+ "minimax_enable_thinking": "model.minimax_enable_thinking",
332
+ "codex_exec_path": "model.codex_exec_path",
333
+ "codex_exec_sandbox": "model.codex_exec_sandbox",
334
+ "codex_exec_profile": "model.codex_exec_profile",
335
+ "codex_exec_full_auto": "model.codex_exec_full_auto",
336
+ "codex_exec_reasoning_effort": "model.codex_exec_reasoning_effort",
337
+ "codex_exec_use_sdk": "model.codex_exec_use_sdk",
338
+ "codex_exec_network_access": "model.codex_exec_network_access",
339
+ "codex_exec_web_search": "model.codex_exec_web_search",
340
+ "codex_exec_approval_policy": "model.codex_exec_approval_policy",
341
+ "claude_code_exec_path": "model.claude_code_exec_path",
342
+ "claude_code_exec_profile": "model.claude_code_exec_profile",
343
+ "claude_code_exec_use_sdk": "model.claude_code_exec_use_sdk",
344
+ "claude_code_exec_effort": "model.claude_code_exec_effort",
345
+ "claude_code_exec_max_thinking_tokens": "model.claude_code_exec_max_thinking_tokens",
346
+ "codex_trace_to_optimizer": "model.codex_trace_to_optimizer",
347
+ "num_epochs": "train.num_epochs",
348
+ "train_size": "train.train_size",
349
+ "steps_per_epoch": "train.steps_per_epoch",
350
+ "batch_size": "train.batch_size",
351
+ "accumulation": "train.accumulation",
352
+ "seed": "train.seed",
353
+ "minibatch_size": "gradient.minibatch_size",
354
+ "merge_batch_size": "gradient.merge_batch_size",
355
+ "analyst_workers": "gradient.analyst_workers",
356
+ "max_analyst_rounds": "gradient.max_analyst_rounds",
357
+ "failure_only": "gradient.failure_only",
358
+ "edit_budget": "optimizer.learning_rate",
359
+ "min_edit_budget": "optimizer.min_learning_rate",
360
+ "lr_scheduler": "optimizer.lr_scheduler",
361
+ "lr_control_mode": "optimizer.lr_control_mode",
362
+ "skill_update_mode": "optimizer.skill_update_mode",
363
+ "use_slow_update": "optimizer.use_slow_update",
364
+ "slow_update_samples": "optimizer.slow_update_samples",
365
+ "longitudinal_pair_policy": "optimizer.longitudinal_pair_policy",
366
+ "use_meta_skill": "optimizer.use_meta_skill",
367
+ "use_skill_aware_reflection": "optimizer.use_skill_aware_reflection",
368
+ "skill_aware_appendix_source": "optimizer.skill_aware_appendix_source",
369
+ "skill_aware_consolidate_threshold": "optimizer.skill_aware_consolidate_threshold",
370
+ "use_gate": "evaluation.use_gate",
371
+ "sel_env_num": "evaluation.sel_env_num",
372
+ "test_env_num": "evaluation.test_env_num",
373
+ "eval_test": "evaluation.eval_test",
374
+ "env": "env.name",
375
+ "skill_init": "env.skill_init",
376
+ "out_root": "env.out_root",
377
+ }
378
+
379
+
380
+ def load_config(args: argparse.Namespace) -> dict:
381
+ """Load config with _base_ inheritance, then apply CLI overrides."""
382
+ from skillopt.config import load_config as _load, flatten_config, is_structured
383
+
384
+ cfg = _load(args.config, overrides=args.cfg_options)
385
+ structured = is_structured(cfg)
386
+
387
+ # Apply legacy --key value overrides
388
+ cli = {k: v for k, v in vars(args).items()
389
+ if v is not None and k not in ("config", "cfg_options")}
390
+ if cli:
391
+ if structured:
392
+ from skillopt.config import apply_overrides
393
+ mapped = []
394
+ for k, v in cli.items():
395
+ dotted = _LEGACY_TO_STRUCTURED.get(k)
396
+ if dotted:
397
+ mapped.append(f"{dotted}={v}")
398
+ else:
399
+ mapped.append(f"env.{k}={v}")
400
+ apply_overrides(cfg, mapped)
401
+ else:
402
+ cfg.update(cli)
403
+
404
+ # Flatten structured config → flat dict for trainer/adapter
405
+ flat = flatten_config(cfg) if structured else cfg
406
+
407
+ for new_key, old_key in (
408
+ ("azure_openai_endpoint", "azure_endpoint"),
409
+ ("azure_openai_api_version", "azure_api_version"),
410
+ ("azure_openai_api_key", "azure_api_key"),
411
+ ):
412
+ if flat.get(new_key) in (None, "") and flat.get(old_key) not in (None, ""):
413
+ flat[new_key] = flat[old_key]
414
+
415
+ explicit_backend = getattr(args, "backend", None)
416
+ if explicit_backend is None:
417
+ for option in args.cfg_options or []:
418
+ key = str(option).split("=", 1)[0].strip()
419
+ if key == "model.backend":
420
+ explicit_backend = str(option).split("=", 1)[1].strip()
421
+ break
422
+
423
+ backend = normalize_backend_name(flat.get("model_backend") or flat.get("target_backend") or "azure_openai")
424
+
425
+ def _has_model_override(dotted_key: str, legacy_key: str) -> bool:
426
+ if getattr(args, legacy_key, None) is not None:
427
+ return True
428
+ for option in args.cfg_options or []:
429
+ key = str(option).split("=", 1)[0].strip()
430
+ if key == dotted_key:
431
+ return True
432
+ return False
433
+
434
+ if explicit_backend is not None:
435
+ backend = normalize_backend_name(explicit_backend)
436
+ flat["model_backend"] = backend
437
+ if backend in {"claude", "claude_chat"}:
438
+ flat.setdefault("optimizer_backend", "claude_chat")
439
+ flat.setdefault("target_backend", "claude_chat")
440
+ elif backend in {"codex", "codex_exec"}:
441
+ flat.setdefault("optimizer_backend", "openai_chat")
442
+ flat.setdefault("target_backend", "codex_exec")
443
+ elif backend == "claude_code_exec":
444
+ flat.setdefault("optimizer_backend", "openai_chat")
445
+ flat.setdefault("target_backend", "claude_code_exec")
446
+ elif backend in {"qwen", "qwen_chat"}:
447
+ flat.setdefault("optimizer_backend", "openai_chat")
448
+ flat.setdefault("target_backend", "qwen_chat")
449
+ elif backend in {"minimax", "minimax_chat"}:
450
+ flat.setdefault("optimizer_backend", "openai_chat")
451
+ flat.setdefault("target_backend", "minimax_chat")
452
+ else:
453
+ flat.setdefault("optimizer_backend", "openai_chat")
454
+ flat.setdefault("target_backend", "openai_chat")
455
+ else:
456
+ flat.setdefault("optimizer_backend", "openai_chat")
457
+ flat.setdefault("target_backend", "openai_chat")
458
+
459
+ if flat.get("optimizer_backend") == "claude_chat":
460
+ if (
461
+ str(flat.get("optimizer_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
462
+ and not _has_model_override("model.optimizer", "optimizer_model")
463
+ ):
464
+ flat["optimizer_model"] = default_model_for_backend("claude_chat")
465
+ if flat.get("optimizer_backend") == "qwen_chat":
466
+ if (
467
+ str(flat.get("optimizer_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
468
+ and not _has_model_override("model.optimizer", "optimizer_model")
469
+ ):
470
+ flat["optimizer_model"] = default_model_for_backend("qwen_chat")
471
+ if flat.get("target_backend") == "claude_chat":
472
+ if (
473
+ str(flat.get("target_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
474
+ and not _has_model_override("model.target", "target_model")
475
+ ):
476
+ flat["target_model"] = default_model_for_backend("claude_chat")
477
+ if flat.get("target_backend") == "claude_code_exec":
478
+ if (
479
+ str(flat.get("target_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
480
+ and not _has_model_override("model.target", "target_model")
481
+ ):
482
+ flat["target_model"] = default_model_for_backend("claude_chat")
483
+ if flat.get("target_backend") == "qwen_chat":
484
+ if (
485
+ str(flat.get("target_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
486
+ and not _has_model_override("model.target", "target_model")
487
+ ):
488
+ flat["target_model"] = default_model_for_backend("qwen_chat")
489
+ if flat.get("target_backend") == "minimax_chat":
490
+ if (
491
+ str(flat.get("target_model", "") or "").strip() in _OPENAI_DEFAULT_MODEL_SENTINELS
492
+ and not _has_model_override("model.target", "target_model")
493
+ ):
494
+ flat["target_model"] = (
495
+ flat.get("minimax_model")
496
+ or default_model_for_backend("minimax_chat")
497
+ )
498
+
499
+ # Auto-generate output root
500
+ if not flat.get("out_root"):
501
+ env = flat.get("env", "unknown")
502
+ model = flat.get("optimizer_model", "unknown").replace("/", "-")
503
+ ts = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
504
+ flat["out_root"] = os.path.join("outputs", f"skillopt_{env}_{model}_{ts}")
505
+
506
+ flat["out_root"] = os.path.abspath(flat["out_root"])
507
+ return flat
508
+
509
+
510
+ # ── Main ─────────────────────────────────────────────────────────────────────
511
+
512
+ def main() -> None:
513
+ args = parse_args()
514
+ cfg = load_config(args)
515
+
516
+ print(f"\n{'='*60}")
517
+ print(f" SkillOpt — Executive Strategy for Self-Evolving Agent Skills")
518
+ print(f"{'='*60}")
519
+ print(f" env: {cfg.get('env')}")
520
+ print(f" optimizer_model: {cfg.get('optimizer_model')}")
521
+ print(f" target_model: {cfg.get('target_model')}")
522
+ print(f" optimizer_backend:{cfg.get('optimizer_backend', 'openai_chat')}")
523
+ print(f" target_backend:{cfg.get('target_backend', 'openai_chat')}")
524
+ print(f" reasoning: {cfg.get('reasoning_effort') or 'off'}")
525
+ print(f" rewrite_effort: {cfg.get('rewrite_reasoning_effort') or 'off'}")
526
+ print(f" epochs: {cfg.get('num_epochs')}")
527
+ print(f" train_size: {cfg.get('train_size') or 'from dataset'}")
528
+ print(f" steps/epoch: auto")
529
+ print(f" batch_size: {cfg.get('batch_size')}")
530
+ print(f" edit_budget: {cfg.get('edit_budget')}")
531
+ print(f" lr_scheduler: {cfg.get('lr_scheduler', 'constant')}")
532
+ print(f" update_mode: {cfg.get('skill_update_mode', 'patch')}")
533
+ print(f" min_edit_budget:{cfg.get('min_edit_budget', 2)}")
534
+ print(f" minibatch_size: {cfg.get('minibatch_size')}")
535
+ print(f" seed: {cfg.get('seed')}")
536
+ print(f" meta_skill: {cfg.get('use_meta_skill', False)}")
537
+ print(f" skill_aware_reflection: {cfg.get('use_skill_aware_reflection', False)}")
538
+ print(f" slow_update: {cfg.get('use_slow_update', False)}")
539
+ print(f" out_root: {cfg.get('out_root')}")
540
+ print(f"{'='*60}\n")
541
+
542
+ # Build adapter
543
+ adapter = get_adapter(cfg)
544
+
545
+ # Build trainer and run
546
+ from skillopt.engine.trainer import ReflACTTrainer
547
+ trainer = ReflACTTrainer(cfg, adapter)
548
+ summary = trainer.train()
549
+
550
+ print(f"\n Output saved to: {cfg['out_root']}")
551
+ if summary.get("test_hard") is not None:
552
+ print(f" Final test: {summary['test_hard']:.4f}")
553
+
554
+
555
+ if __name__ == "__main__":
556
+ main()
@@ -1,117 +0,0 @@
1
- ---
2
- name: ponytail
3
- description: >
4
- Forces the laziest solution that actually works, simplest, shortest, most
5
- minimal. Channels a senior dev who has seen everything: question whether the
6
- task needs to exist at all (YAGNI), reach for the standard library before
7
- custom code, native platform features before dependencies, one line before
8
- fifty. Supports intensity levels: lite, full (default), ultra. Use whenever
9
- the user says "ponytail", "be lazy", "lazy mode", "simplest solution",
10
- "minimal solution", "yagni", "do less", or "shortest path", and whenever
11
- they complain about over-engineering, bloat, boilerplate, or unnecessary
12
- dependencies.
13
- argument-hint: "[lite|full|ultra]"
14
- license: MIT
15
- ---
16
-
17
- # Ponytail
18
-
19
- You are a lazy senior developer. Lazy means efficient, not careless. You have
20
- seen every over-engineered codebase and been paged at 3am for one. The best
21
- code is the code never written.
22
-
23
- ## Persistence
24
-
25
- ACTIVE EVERY RESPONSE. No drift back to over-building. Still active if
26
- unsure. Off only: "stop ponytail" / "normal mode". Default: **full**.
27
- Switch: `/ponytail lite|full|ultra`.
28
-
29
- ## The ladder
30
-
31
- Stop at the first rung that holds:
32
-
33
- 1. **Does this need to exist at all?** Speculative need = skip it, say so in one line. (YAGNI)
34
- 2. **Already in this codebase?** A helper, util, type, or pattern that already lives here → reuse it. Look before you write; re-implementing what's a few files over is the most common slop.
35
- 3. **Stdlib does it?** Use it.
36
- 4. **Native platform feature covers it?** `<input type="date">` over a picker lib, CSS over JS, DB constraint over app code.
37
- 5. **Already-installed dependency solves it?** Use it. Never add a new one for what a few lines can do.
38
- 6. **Can it be one line?** One line.
39
- 7. **Only then:** the minimum code that works.
40
-
41
- The ladder is a reflex, not a research project — but it runs *after* you
42
- understand the problem, not instead of it. Read the task and the code it
43
- touches first, trace the real flow end to end, then climb. Two rungs work →
44
- take the higher one and move on. The first lazy solution that works is the
45
- right one — once you actually know what the change has to touch.
46
-
47
- **Bug fix = root cause, not symptom.** A report names a symptom. Before you
48
- edit, grep every caller of the function you're about to touch. The lazy fix IS
49
- the root-cause fix: one guard in the shared function is a smaller diff than a
50
- guard in every caller — and patching only the path the ticket names leaves
51
- every sibling caller still broken. Fix it once, where all callers route through.
52
-
53
- ## Rules
54
-
55
- - No unrequested abstractions: no interface with one implementation, no factory for one product, no config for a value that never changes.
56
- - No boilerplate, no scaffolding "for later", later can scaffold for itself.
57
- - Deletion over addition. Boring over clever, clever is what someone decodes at 3am.
58
- - Fewest files possible. Shortest working diff wins — but only once you understand the problem. The smallest change in the wrong place isn't lazy, it's a second bug.
59
- - Complex request? Ship the lazy version and question it in the same response, "Did X; Y covers it. Need full X? Say so." Never stall on an answer you can default.
60
- - Two stdlib options, same size? Take the one that's correct on edge cases. Lazy means writing less code, not picking the flimsier algorithm.
61
- - Mark deliberate simplifications with a `ponytail:` comment (`// ponytail: this exists`), simple reads as intent, not ignorance. Shortcut with a known ceiling (global lock, O(n²) scan, naive heuristic)? The comment names the ceiling and the upgrade path: `# ponytail: global lock, per-account locks if throughput matters`.
62
-
63
- ## Output
64
-
65
- Code first. Then at most three short lines: what was skipped, when to add it.
66
- No essays, no feature tours, no design notes. If the explanation is longer
67
- than the code, delete the explanation, every paragraph defending a
68
- simplification is complexity smuggled back in as prose. Explanation the user
69
- explicitly asked for (a report, a walkthrough, per-phase notes) is not debt,
70
- give it in full, the rule is only against unrequested prose.
71
-
72
- Pattern: `[code] → skipped: [X], add when [Y].`
73
-
74
- ## Intensity
75
-
76
- | Level | What change |
77
- |-------|------------|
78
- | **lite** | Build what's asked, but name the lazier alternative in one line. User picks. |
79
- | **full** | The ladder enforced. Stdlib and native first. Shortest diff, shortest explanation. Default. |
80
- | **ultra** | YAGNI extremist. Deletion before addition. Ship the one-liner and challenge the rest of the requirement in the same breath. |
81
-
82
- Example: "Add a cache for these API responses."
83
- - lite: "Done, cache added. FYI: `functools.lru_cache` covers this in one line if you'd rather not own a cache class."
84
- - full: "`@lru_cache(maxsize=1000)` on the fetch function. Skipped custom cache class, add when lru_cache measurably falls short."
85
- - ultra: "No cache until a profiler says so. When it does: `@lru_cache`. A hand-rolled TTL cache class is a bug farm with a hit rate."
86
-
87
- ## When NOT to be lazy
88
-
89
- Never simplify away: input validation at trust boundaries, error handling
90
- that prevents data loss, security measures, accessibility basics, anything
91
- explicitly requested. User insists on the full version → build it, no
92
- re-arguing.
93
-
94
- Never lazy about understanding the problem. The ladder shortens the
95
- solution, never the reading. Trace the whole thing first — every file the
96
- change touches, the actual flow — before picking a rung. Laziness that skips
97
- comprehension to ship a small diff is the dangerous kind: it dresses up as
98
- efficiency and ships a confident wrong fix. Read fully, then be lazy.
99
-
100
- Hardware is never the ideal on paper: a real clock drifts, a real sensor
101
- reads off, a PCA9685 runs a few percent fast. Leave the calibration knob, not
102
- just less code, the physical world needs tuning a minimal model can't see.
103
-
104
- Lazy code without its check is unfinished. Non-trivial logic (a branch, a
105
- loop, a parser, a money/security path) leaves ONE runnable check behind, the
106
- smallest thing that fails if the logic breaks: an `assert`-based
107
- `demo()`/`__main__` self-check or one small `test_*.py`. No frameworks, no
108
- fixtures, no per-function suites unless asked. Trivial one-liners need no
109
- test, YAGNI applies to tests too.
110
-
111
- ## Boundaries
112
-
113
- Ponytail governs what you build, not how you talk (pair with Caveman for
114
- terse prose). "stop ponytail" / "normal mode": revert. Level persists until
115
- changed or session end.
116
-
117
- The shortest path to done is the right path.