self-evolve-framework 1.2.0 → 1.4.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.
- package/README.md +22 -11
- package/bin/cli.js +1 -0
- package/package.json +1 -1
- package/template/skills/ponytail/SKILL.md +133 -0
- package/template/skills/ponytail/scripts/hooks/claude-codex-hooks.json +44 -0
- package/template/skills/ponytail/scripts/hooks/copilot-hooks.json +21 -0
- package/template/skills/ponytail/scripts/hooks/ponytail-activate.js +91 -0
- package/template/skills/ponytail/scripts/hooks/ponytail-config.js +122 -0
- package/template/skills/ponytail/scripts/hooks/ponytail-instructions.js +94 -0
- package/template/skills/ponytail/scripts/hooks/ponytail-mode-tracker.js +55 -0
- package/template/skills/ponytail/scripts/hooks/ponytail-runtime.js +68 -0
- package/template/skills/ponytail/scripts/hooks/ponytail-statusline.ps1 +21 -0
- package/template/skills/ponytail/scripts/hooks/ponytail-statusline.sh +12 -0
- package/template/skills/ponytail/scripts/hooks/ponytail-subagent.js +22 -0
- package/template/skills/ponytail/scripts/mcp/README.md +46 -0
- package/template/skills/ponytail/scripts/mcp/index.js +48 -0
- package/template/skills/ponytail/scripts/mcp/instructions.js +26 -0
- package/template/skills/ponytail/scripts/mcp/package.json +13 -0
- package/template/skills/ponytail/scripts/mcp/test/instructions.test.js +22 -0
- package/template/skills/ponytail-audit/SKILL.md +41 -0
- package/template/skills/ponytail-debt/SKILL.md +44 -0
- package/template/skills/ponytail-gain/SKILL.md +50 -0
- package/template/skills/ponytail-help/SKILL.md +69 -0
- package/template/skills/ponytail-review/SKILL.md +57 -0
- package/template/skills/skillopt-sleep/SKILL.md +48 -34
- package/template/skills/skillopt-sleep/scripts/python/__init__.py +20 -0
- package/template/skills/skillopt-sleep/scripts/python/__main__.py +343 -0
- package/template/skills/skillopt-sleep/scripts/python/backend.py +1371 -0
- package/template/skills/skillopt-sleep/scripts/python/budget.py +75 -0
- package/template/skills/skillopt-sleep/scripts/python/config.py +162 -0
- package/template/skills/skillopt-sleep/scripts/python/consolidate.py +238 -0
- package/template/skills/skillopt-sleep/scripts/python/cycle.py +291 -0
- package/template/skills/skillopt-sleep/scripts/python/dream.py +138 -0
- package/template/skills/skillopt-sleep/scripts/python/experiments/__init__.py +1 -0
- package/template/skills/skillopt-sleep/scripts/python/experiments/gbrain_bench.py +119 -0
- package/template/skills/skillopt-sleep/scripts/python/experiments/personas.py +86 -0
- package/template/skills/skillopt-sleep/scripts/python/experiments/report.py +132 -0
- package/template/skills/skillopt-sleep/scripts/python/experiments/run_experiment.py +178 -0
- package/template/skills/skillopt-sleep/scripts/python/experiments/run_gbrain.py +209 -0
- package/template/skills/skillopt-sleep/scripts/python/experiments/run_transfer.py +155 -0
- package/template/skills/skillopt-sleep/scripts/python/experiments/sweep.py +164 -0
- package/template/skills/skillopt-sleep/scripts/python/gate.py +50 -0
- package/template/skills/skillopt-sleep/scripts/python/harvest.py +304 -0
- package/template/skills/skillopt-sleep/scripts/python/harvest_codex.py +253 -0
- package/template/skills/skillopt-sleep/scripts/python/harvest_sources.py +41 -0
- package/template/skills/skillopt-sleep/scripts/python/judges.py +84 -0
- package/template/skills/skillopt-sleep/scripts/python/llm_miner.py +134 -0
- package/template/skills/skillopt-sleep/scripts/python/memory.py +129 -0
- package/template/skills/skillopt-sleep/scripts/python/mine.py +312 -0
- package/template/skills/skillopt-sleep/scripts/python/replay.py +146 -0
- package/template/skills/skillopt-sleep/scripts/python/rollout.py +153 -0
- package/template/skills/skillopt-sleep/scripts/python/scheduler.py +138 -0
- package/template/skills/skillopt-sleep/scripts/python/slow_update.py +142 -0
- package/template/skills/skillopt-sleep/scripts/python/staging.py +103 -0
- package/template/skills/skillopt-sleep/scripts/python/state.py +96 -0
- package/template/skills/skillopt-sleep/scripts/python/tasks_file.py +81 -0
- package/template/skills/skillopt-sleep/scripts/python/types.py +146 -0
- package/template/skills/skillopt-sleep/scripts/shell/__init__.py +0 -0
- package/template/skills/skillopt-sleep/scripts/shell/eval_only.py +466 -0
- package/template/skills/skillopt-sleep/scripts/shell/materialize_searchqa.py +148 -0
- package/template/skills/skillopt-sleep/scripts/shell/run_alfworld.sh +60 -0
- package/template/skills/skillopt-sleep/scripts/shell/run_searchqa.sh +40 -0
- package/template/skills/skillopt-sleep/scripts/shell/run_spreadsheetbench.sh +39 -0
- package/template/skills/skillopt-sleep/scripts/shell/train.py +556 -0
|
@@ -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()
|