feat(sleep): opt-in llm_dream mode for LLM-generated dream variants - #244
feat(sleep): opt-in llm_dream mode for LLM-generated dream variants#244Bogdan (Dan) Baciu (bogdanbaciu21) wants to merge 1 commit into
Conversation
|
Thanks for making LLM dream generation opt-in and retaining a fallback. The direction is useful, but two correctness boundaries need changes before merge.
Please add regressions proving that only the optimizer backend is called; that target counters/credentials remain untouched; that contradictory or constraint-removing generations fall back to the original/template intent; and that duplicate/malformed generations are rejected. Before enabling this as a training-data feature, please also provide a small recorded or opt-in live end-to-end result with generation acceptance/fallback rate, token cost, and held-out non-regression (ideally lift). The existing lexical-diversity fixture uses author-written strings and does not validate the behavior or practical effect of the live generation path. |
|
Yifan Yang (@Yif-Yang) Thanks for the detailed review. I fixed both correctness boundaries and added the requested regressions and end-to-end evidence at head
I reran the focused and entire repository suites against that exact head on native Linux, macOS, and Windows. The full suite passed with 1,463 tests on Linux, 1,463 on macOS, and 1,418 on Windows; no tests failed or were deselected. Ready for re-review. |
|
Thanks — the routing and fail-closed fidelity changes look addressed. The remaining evidence still does not validate practical benefit from LLM dreams, however. The real OpenCode cycle sets both |
Rebased onto current main as one commit, with paired functional evidence: - deterministic paired dream-off/on receipt with real skill evolution (TestPairedFunctionalEvidence) - opt-in live paired receipt driver (tests/test_llm_dream_live.py) for claude, opencode, or any OpenAI-compatible backend; fails closed on backend call errors so a dead credential cannot produce a receipt - whole-message Markdown fences are normalized before the same strict JSON parse (live providers fence verdicts; content rules unchanged) - the opt-in OpenCode dream cycle now exercises real skill evolution
09d8cef to
760982a
Compare
|
Thanks for the re-review. Both remaining items are addressed, and the branch is rebased onto current main as a single commit at head
Validation at the exact head across five native runners (Ubuntu 3.10/3.11/3.12, macOS arm64, Windows): full suite 1,539 passed on Ubuntu and macOS and 1,494 on Windows with zero failures; the focused slice is 297 passed everywhere (298 on Windows); strict docs pass. Ready for re-review. |
What Problem This Solves
The three hardcoded dream wrapper templates embed each harvested request verbatim, so synthetic training variants never change how a request is actually phrased. Consolidation can therefore learn rules tied to one surface form, and the training pool under-represents the phrasing diversity real usage has.
Why This Change Was Made
This adds an opt-in
sleep.llm_dreampath that creates LLM-generated paraphrase variants through the optimizer while preserving target isolation, held-out inputs, staging, and the existing non-regression gate. The default remains off, and rejected or unavailable generations fall back to the deterministic template.The branch is rebased onto current
mainas one commit. Since the last review round it adds the requested functional evidence with real evolution enabled, plus two robustness fixes found while producing the live receipt: whole-message Markdown code fences are normalized before the same strict JSON parse (a mainstream provider fences its verdict JSON even when told not to, which previously discarded every valid verdict as malformed), and the live driver fails closed when any backend call errors, so a dead credential or invalid model id can never produce a quiet all-zero receipt.Project Fit
User Impact
Operators can opt in with
sleep.llm_dream: trueto get optimizer-written paraphrase variants of real training tasks, with task-aware fail-closed semantic verification and deterministic template fallback. Default behavior is byte-identical with the flag off. Every enabled run records acceptance/fallback counts, per-reason fallback accounting, and the optimizer token cost of generation plus verification.Proof
Functional evidence is a paired dream-off versus dream-on comparison with real skill evolution enabled, at two levels.
First, the deterministic paired contract test (
TestPairedFunctionalEvidence) runs the real dream_consolidate, consolidate, and gate path twice on the same tasks withevolve_skill=True. Template dreams embed the source phrasing verbatim, so only a literal-match rule is learnable and the gate rejects it on a differently phrased held-out task: held-out stays 0.0 and the artifact is unchanged. Withllm_dreamon, one accepted paraphrase supplies a second phrasing, reflection generalizes, the gate accepts, the skill document actually changes, and held-out moves 0.0 to 1.0. Acceptance is 1 of 2 with one deterministic-fidelity fallback, and a positive optimizer token delta is asserted from the shipped evidence events.Second, an opt-in live paired driver (
tests/test_llm_dream_live.py) runs the same shape against a real provider with real skill evolution and writes a JSON receipt. One recorded run ongpt-4o-minithrough the OpenAI-compatible backend, same four rule-judged tasks in both arms:The live verifier rejected both generated paraphrases under its "when uncertain, reject" contract, fell back to templates, and the training path was unharmed: this receipt demonstrates real end-to-end evolution, non-regression, and honest acceptance economics rather than a planted win. The deterministic test above is what pins the acceptance path and the causal lift mechanism.
Academic Support
Testing
The focused slice covers optimizer-only routing and target isolation, fail-closed task-aware semantic verification, fence normalization with strict-parse regressions, contradiction and constraint-removal fallback, malformed and duplicate rejection, the deterministic paired functional receipt, and the live driver's error gate.
Every job asserted exact candidate
760982a475342aacb416bf37bb1f92d14b9fffa9before testing. No test was deselected and no failure was masked. The Windows difference is explicit platform and optional dependency skips, not failures.Limitations & Negative Results
gpt-4o-mini: the fail-closed verifier rejected both paraphrases as uncertain. That is the designed conservative posture, and it means acceptance economics on weaker optimizer models can be poor; the feature falls back to templates at the recorded token cost rather than admitting unverified variants.Reproduce It Yourself
Live paired receipt (opt-in, spends provider tokens; claude, opencode, and any OpenAI-compatible server are supported):