|
1 | 1 | --- |
2 | 2 | name: skillopt-sleep |
3 | | -description: Nightly offline self-evolution for a Codex agent. Reviews past sessions, replays recurring tasks, and consolidates validated memory + skills behind a held-out gate. Use when the user wants Codex to learn from past usage, run a "sleep"/"dream" cycle, or schedule offline self-optimization. |
| 3 | +description: "Use when the user wants Codex to self-improve from past usage, asks about a nightly/offline 'sleep' or 'dream' cycle, wants Codex to review past sessions, learn preferences, consolidate memory/skills, run dry-run/run/adopt/status for SkillOpt-Sleep, or schedule offline self-optimization. Drives the skillopt_sleep engine: harvest past sessions -> mine recurring tasks -> replay offline -> consolidate validated memory + skills behind a held-out gate." |
4 | 4 | --- |
5 | 5 |
|
6 | | -# SkillOpt-Sleep (Codex skill) |
| 6 | +# SkillOpt-Sleep: offline self-evolution for a local Codex agent |
7 | 7 |
|
8 | | -This skill drives the `skillopt_sleep` engine — an offline "sleep cycle" that |
9 | | -makes a Codex agent better at the user's recurring work without retraining. |
| 8 | +SkillOpt-Sleep gives the user's Codex agent a sleep cycle. While the user is |
| 9 | +offline or on demand, it reviews past local sessions, re-runs recurring tasks |
| 10 | +on the user's own budget, and consolidates what it learns into memory and |
| 11 | +skills. It keeps only changes that pass a held-out validation gate, and live |
| 12 | +files change only after the user explicitly adopts a staged proposal. There is |
| 13 | +no model-weight training. |
10 | 14 |
|
11 | 15 | ## When to use |
12 | 16 |
|
13 | | -Trigger when the user wants to: review past sessions, learn their preferences, |
14 | | -consolidate feedback into long-term memory/skills, run a nightly/offline |
15 | | -self-improvement cycle, or adopt a staged proposal. |
| 17 | +Trigger when the user wants any of: |
16 | 18 |
|
17 | | -## How to run it |
| 19 | +- Codex to learn from past sessions or get better the more they use it; |
| 20 | +- a nightly/scheduled or on-demand sleep/dream/offline self-improvement run; |
| 21 | +- to review past sessions and distill recurring tasks; |
| 22 | +- to consolidate feedback into memory or managed skills; |
| 23 | +- to run `status`, `harvest`, `dry-run`, `run`, or `adopt` for SkillOpt-Sleep. |
| 24 | + |
| 25 | +## The cycle |
| 26 | + |
| 27 | +1. **Harvest** - read local session transcripts according to the engine |
| 28 | + configuration and normalize them into session digests. |
| 29 | +2. **Mine** - turn digests into recurring `TaskRecord`s with outcomes and |
| 30 | + checkable references where possible. |
| 31 | +3. **Replay** - re-run mined tasks offline under the current skill and memory. |
| 32 | +4. **Consolidate** - reflect on failures and propose bounded edits. |
| 33 | +5. **Gate** - accept edits only when the held-out validation score improves. |
| 34 | +6. **Stage** - write the proposal under |
| 35 | + `<project>/.skillopt-sleep/staging/<date>/`; nothing live changes. |
| 36 | +7. **Adopt** - only after explicit user approval, copy staged files over live |
| 37 | + files with backups. |
| 38 | + |
| 39 | +## How to drive it |
18 | 40 |
|
19 | 41 | Invoke the bundled runner via shell (Codex `exec` has shell access). The runner |
20 | | -finds the engine and a Python ≥ 3.10 automatically: |
| 42 | +finds the engine and a Python >= 3.10 automatically. |
21 | 43 |
|
22 | 44 | ```bash |
23 | 45 | # point at the repo if it isn't auto-detected from CWD: |
24 | 46 | export SKILLOPT_SLEEP_REPO=/path/to/SkillOpt-Sleep |
25 | | -bash "$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh" <action> --project "$(pwd)" |
| 47 | + |
| 48 | +bash "$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh" status --project "$(pwd)" |
| 49 | +bash "$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh" harvest --project "$(pwd)" |
| 50 | +bash "$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh" dry-run --project "$(pwd)" --backend mock |
| 51 | +bash "$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh" run --project "$(pwd)" --backend codex |
| 52 | +bash "$SKILLOPT_SLEEP_REPO/plugins/run-sleep.sh" adopt --project "$(pwd)" |
26 | 53 | ``` |
27 | 54 |
|
28 | | -`<action>` ∈ `status | dry-run | run | adopt | harvest`. Use `--backend codex` |
29 | | -for real improvement on the user's own Codex budget (default `mock` = no spend). |
| 55 | +Actions are `status`, `harvest`, `dry-run`, `run`, and `adopt`. |
| 56 | + |
| 57 | +- Default backend is `mock`, which is deterministic and spends no API budget. |
| 58 | +- `--backend codex` uses the user's Codex budget for real improvement. |
| 59 | +- Keep `dry-run --backend mock` as the first smoke check unless the user |
| 60 | + explicitly asked for a real optimization run. |
30 | 61 |
|
31 | 62 | ## Steps |
32 | 63 |
|
33 | 64 | 1. Run the requested action; capture stdout. |
34 | | -2. For `run`/`dry-run`: read the staged `report.md` it prints and show the user |
35 | | - the held-out baseline → candidate score and the exact proposed edits. |
36 | | -3. `run` only **stages** a proposal under `<project>/.skillopt-sleep/staging/`; |
37 | | - nothing live changes until `adopt`. Offer `/skillopt-sleep adopt`. |
38 | | -4. Never hand-edit the user's `AGENTS.md` / skills yourself — only `adopt` does, |
39 | | - and it backs up first. |
| 65 | +2. For `dry-run` and `run`, report the held-out baseline -> candidate score, |
| 66 | + gate action, task count, session count, and exact proposed edits. |
| 67 | +3. If a staging directory is printed, read `report.md` before summarizing. |
| 68 | +4. `run` only stages a proposal; nothing live changes until `adopt`. |
| 69 | +5. Offer adoption only after the user has reviewed the staged proposal. |
| 70 | +6. Never hand-edit the user's `AGENTS.md`, memory, or skills as a substitute |
| 71 | + for `adopt`; adoption is the safety boundary and writes backups first. |
| 72 | + |
| 73 | +## Hard rules |
| 74 | + |
| 75 | +- Harvest is read-only. Do not edit archived sessions or raw transcripts. |
| 76 | +- Keep raw secrets, credentials, private user data, and unsanitized transcript |
| 77 | + contents out of messages, logs, generated artifacts, and commits. |
| 78 | +- Show validation evidence before recommending adoption. |
| 79 | +- Treat generated edits as proposals, not as source of truth. |
| 80 | +- Do not rely on deprecated custom prompts or `/sleep` slash commands for this |
| 81 | + Codex integration. This skill is the entrypoint. |
40 | 82 |
|
41 | 83 | ## Validate |
42 | 84 |
|
43 | 85 | ```bash |
| 86 | +python -m skillopt_sleep dry-run --project "$(pwd)" --backend mock --json |
44 | 87 | python -m skillopt_sleep.experiments.run_gbrain --backend codex \ |
45 | 88 | --seeds brief-writer --data-root /path/to/gbrain-evals/eval/data/skillopt-v1 \ |
46 | 89 | --nights 2 --limit-replay 3 --limit-holdout 3 |
47 | 90 | ``` |
48 | | -A deficient skill goes 0.00 → 1.00 on a held-out set; the optimizer's edits are |
49 | | -gated on real-task performance. |
| 91 | + |
| 92 | +A deficient skill goes 0.00 -> 1.00 on a held-out set; the optimizer's edits |
| 93 | +are gated on real-task performance. |
0 commit comments