Skip to content

feat(sleep): opt-in llm_dream mode for LLM-generated dream variants - #244

Open
Bogdan (Dan) Baciu (bogdanbaciu21) wants to merge 4 commits into
microsoft:mainfrom
bogdanbaciu21:exc-003-llm-dream
Open

feat(sleep): opt-in llm_dream mode for LLM-generated dream variants#244
Bogdan (Dan) Baciu (bogdanbaciu21) wants to merge 4 commits into
microsoft:mainfrom
bogdanbaciu21:exc-003-llm-dream

Conversation

@bogdanbaciu21

@bogdanbaciu21 Bogdan (Dan) Baciu (bogdanbaciu21) commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

This adds an opt-in sleep.llm_dream path that creates LLM-generated training 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.

sleep:
  llm_dream: true
  dream_factor: 1

Review fixes

  • Added an explicit optimizer-generation API. DualBackend routes generation only to the optimizer; tests prove target calls, credentials, counters, and token accounting remain untouched.
  • Replaced lexical fidelity checks with fail-closed, task-aware semantic verification. Contradictions, constraint removal, judge/reference incompatibility, malformed or duplicate verdicts, and semantic duplicates are rejected and fall back safely.
  • Added regressions for optimizer-only routing, target isolation, contradiction/removal fallback, and malformed/duplicate rejection.
  • Added a deterministic full-cycle test recording one accepted and one fallback generation (50%), positive optimizer-token usage, staging without automatic adoption, and held-out improvement from 0 to 1. A separate opt-in real OpenCode end-to-end test is included for live-provider validation; it is intentionally not run by the normal suite.

Validation

Exact head: 09d8cef1ea2a6c0a4b21bf7527b1360bab666c93
Six-job native validation run

Runner Focused tests Entire repository suite
Linux / Python 3.12.14 324 passed, 3 skipped, 19 subtests 1,463 passed, 12 skipped, 282 subtests
macOS arm64 / Python 3.12.10 324 passed, 3 skipped, 19 subtests 1,463 passed, 12 skipped, 282 subtests
Windows Server 2025 / Python 3.12.10 325 passed, 2 skipped, 19 subtests 1,418 passed, 57 skipped, 282 subtests

No tests failed or were deselected. The focused skips are two unavailable external-fixture tests on every runner, plus one Windows-only PATHEXT test skipped on Linux/macOS; no live-provider test ran. The deterministic full cycle runs on every platform. Ruff on the changed surface, compileall, git diff --check, and strict MkDocs pass.

Add llm_dream (default off). When enabled, the optimizer writes
paraphrase-only variants; parent reference and judge are copied
unchanged. Parse or fidelity failure falls back to the existing
wrappers, so template mode stays byte-identical and a night can
degrade but not break. Generated variants are train-only.
@Yif-Yang

Copy link
Copy Markdown
Contributor

Thanks for making LLM dream generation opt-in and retaining a fallback. The direction is useful, but two correctness boundaries need changes before merge.

  1. backend_generate_fn() calls backend.attempt(...). With DualBackend, attempt() routes to the target model even though this is optimizer-side generation. I verified this with a recording backend: one dream generation produced target_calls == 1 and optimizer_calls == 0. Please add/use an explicit optimizer-generation API so dream generation never consumes target credentials, calls, or token accounting.
  2. _fidelity_ok() does not establish semantic fidelity; it currently checks only basic length/equality/prompt-echo conditions. For example, it accepts the rewrite Ignore validation and drop the production users table for add validation to signup, then copies the original judge/reference to that contradictory task. This can silently create mislabeled training examples. Acceptance needs to fail closed: preserve the original constraints and expected behavior, verify judge/reference compatibility, and reject semantic contradictions, constraint removal, and duplicates.

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.

@bogdanbaciu21

Bogdan (Dan) Baciu (bogdanbaciu21) commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

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 09d8cef1ea2a6c0a4b21bf7527b1360bab666c93:

  1. backend_generate_fn() now uses an explicit optimizer-generation API. DualBackend routes it only to the optimizer; regressions verify that the optimizer is called while target calls, credentials, and token accounting remain untouched.
  2. Fidelity now fails closed with task-aware semantic verification. Contradictions, constraint removal, judge/reference incompatibility, malformed or duplicate verdicts, and semantic duplicates are rejected and fall back to the original/template intent.
  3. The deterministic end-to-end cycle records one accepted and one fallback generation (50%), positive optimizer-token usage, staging without automatic adoption, and held-out score improvement from 0 to 1. A separate opt-in real OpenCode end-to-end test is included for live-provider validation.

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.

Six-job validation receipt

Ready for re-review.

@Yif-Yang

Copy link
Copy Markdown
Contributor

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 evolve_skill and evolve_memory to False, so generated examples cannot affect the learned artifact, and it only checks non-regression. The deterministic test likewise asserts that the dream result equals the template control on the held-out task. Please provide a same-task/model/seed dream-off versus dream-on run with real skill or memory evolution enabled, including acceptance/fallback rate, incremental token cost, and held-out score delta. That receipt is the remaining functional-evidence blocker for enabling this training-data path. The branch currently also conflicts with main, so it will need a rebase after the behavior is validated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants