Repository navigation
feat(core): add experimental stateful Code Mode REPL - #68600
Draft
rekram1-node wants to merge 6 commits into
Draft
rekram1-node wants to merge 6 commits into
rekram1-node wants to merge 6 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
N/A (experimental
featbehindoptInOnlyflagcodemode_repl).Type of change
What does this PR do?
Adds an experimental, opt-in persistent REPL for Code Mode (
executetool), guarded by the newoptInOnlyflagcodemode_repl(requiresfull_codemode; enable withOPENCODE_FLAGS=full_codemode,codemode_replorexperimental.codemode_repl: true).psychoscript@0.14.0: bumpspsychoscriptfrom0.11.0to0.14.0(includes feat(runtime): add experimental persistent sessions psychoscript#249).@opencode/codemode: wrapsruntime.experimental.session()andruntime.experimental.restore()frompsychoscript/effect, including optionalSessionStore, and resets per-cell tool call lists inrun.metadatawhenrunIdchanges between cells.packages/core/src/codemode/repl.ts,sql.ts): stores one zstd-compressed root snapshot per session incodemode_repl_sessionand SHA-256 content-addressed blobs incodemode_repl_blob+codemode_repl_blob_ref. After each settled cell (including throws), bindings untouched for >5 cells unload automatically to blobs, and transient blobs written during a tool-inventory swap are GC'd in the commit transaction. Cold sessions evict by LRU (MAX_WARM_SESSIONS = 64/MAX_WARM_BYTES = 256 MiB), spilling remaining bindings so cold restores stay tiny and lazy.copiedSeq; revertstagecancels any active background REPL job and drops the warm VM (leaving SQLite intact for undo); revertcommitresets ifvisible_seq >= boundary.seq; session delete releases refs and cleans orphan blobs. Tool catalog changes (e.g. MCP add/remove) transfer state cleanly to the new runtime; build or extension-mode changes reset with a 1-line[repl reset: ...]footer.Tool.check, and subagents stay stateless.executekeeps its name andcodeparameter. Live binding summaries append as a 1-line tool-result footer (prompt-cache safe). Onlycodemode_replis added to the experimental config flag registry (client types regenerated).How did you verify your code works?
cd packages/codemode && bun typecheck && bun run typecheck:tsc && bun test— 337 pass, 0 fail.cd packages/core && bun typecheck && bun run typecheck:tsc— 0 errors across 2,104 files.cd packages/core && bun test test/codemode/repl.test.ts test/codemode.test.ts test/codemode-input-blocks.test.ts test/codemode/durable.test.ts test/codemode/execute-durable.test.ts test/automation.test.ts— 114 pass, 0 fail (covers persistence, cold unloading to SQLite blobs, lazy restore afterforget, MCP inventory swap, zero-copy fork + orphan blob GC, mode-key reset notice, per-cellinputsscoping, and automation parity).cd packages/client && bun run generate— regeneratedpackages/client/src/promise/generated/types.ts.bunx oxlinton all modified/new source files — clean.Screenshots / recordings
N/A (no UI changes).
Checklist