GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(core): run Code Mode on the bytecode VM behind experimental.codemodeVm by jlongster · Pull Request #62358 · anomalyco/opencode

Conversation

@jlongster

@jlongster jlongster commented Nov 6, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

Stacked on #62357 (codemode-vm-flag). Runs OpenCode's Code Mode execute tool and CodeModeTool.check on the bytecode VM behind the experimental flag experimental.codemode_vm, which is off by default. With the flag off, core behaves exactly like dev.

Supersedes the PR #61856 → #62086 stack.

Design

  • Experimental flag (default off):
    • Declared as codemode_vm on ConfigExperimental.Info (packages/schema/src/config/experimental.ts). ConfigNormalize also accepts experimental.codemodeVm.
    • tool.ts reads it on each execution, from OPENCODE_FLAGS (codemode_vm turns it on, -codemode_vm turns it off) and then from config.
  • Per-engine runtime cache (packages/core/src/codemode/tool.ts): prepared runtimes are cached per inventory and per engine. When the flag is on, CodeMode.make gets engine: "vm"; otherwise the code path is dev's. The catalog reuses whichever runtime already exists, so the tools aren't prepared twice.
  • fetch.ts is unchanged from dev.

Verification

  • packages/core:
    • bun run typecheck:tsc is clean.
    • test/tool-execute.test.ts, test/codemode, test/config/normalization.test.ts: 93 pass, 0 fail. The Code Mode tests are parameterised over experimental.codemode_vm off and on, and include a check of the per-engine cache.
    • The wider Code Mode-related core tests (MCP, plugins, tool registry, shell, execute): 252 pass, 0 fail.
  • packages/codemode (base feat(codemode): add a bytecode VM engine behind CodeMode.make({ engine: "vm" }) #62357): 1,592 pass on legacy, on vm and in round-trip mode; test262 13,329 pass on both engines.

Benchmarks (packages/codemode/script/bench.ts, 11 iterations)

Benchmark Legacy (median / min) VM (median / min) Speedup (min)
numeric loop 48.3 ms / 47.6 ms 17.6 ms / 14.8 ms 3.2×
closure recursion (fib 22) 35.4 ms / 33.0 ms 4.7 ms / 4.5 ms 7.3×
array callbacks (50k) 275.8 ms / 256.5 ms 81.9 ms / 78.3 ms 3.3×
promise fan-out (5k) 34.4 ms / 31.1 ms 14.8 ms / 8.5 ms 3.7×
tool fan-out (1k) 15.0 ms / 13.6 ms 8.8 ms / 7.2 ms 1.9×
JSON round-trip 194.9 ms / 185.7 ms 53.7 ms / 48.9 ms 3.8×
generator iteration 85.2 ms / 74.0 ms 5.1 ms / 4.9 ms 15.1×
string building 82.9 ms / 75.2 ms 18.8 ms / 16.6 ms 4.5×
Map/Set ops 74.8 ms / 70.4 ms 14.0 ms / 12.9 ms 5.5×

Visual

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 72" width="240" height="72" fill="none">
  <style>
    .t { font: 600 9px ui-monospace, SFMono-Regular, Menlo, monospace; fill: currentColor; }
    .m { font: 500 8px ui-monospace, SFMono-Regular, Menlo, monospace; fill: currentColor; opacity: 0.55; }
    .box { stroke: currentColor; stroke-width: 1.25; rx: 5; }
    .knob { animation: slide 3s ease-in-out infinite; }
    .vm { animation: glow 3s ease-in-out infinite; }
    @keyframes slide {
      0%, 40% { transform: translateX(0px); }
      55%, 90% { transform: translateX(10px); }
      100% { transform: translateX(0px); }
    }
    @keyframes glow {
      0%, 40% { opacity: 0.35; }
      55%, 90% { opacity: 0.95; }
      100% { opacity: 0.35; }
    }
    @media (prefers-reduced-motion: reduce) {
      .knob { animation: none; transform: translateX(10px); }
      .vm { animation: none; opacity: 0.9; }
    }
  </style>
  <rect class="box" x="8" y="12" width="108" height="48" opacity="0.45"/>
  <text class="m" x="16" y="27">experimental</text>
  <text class="t" x="16" y="42">codemode_vm</text>
  <rect x="84" y="34" width="22" height="11" rx="5.5" stroke="currentColor" stroke-width="1.2" opacity="0.6"/>
  <circle class="knob" cx="90" cy="39.5" r="3.5" fill="currentColor"/>
  <path d="M116 36 H136" stroke="currentColor" stroke-width="1.25" opacity="0.45"/>
  <polygon points="136,36 131,33 131,39" fill="currentColor" opacity="0.6"/>
  <rect class="box vm" x="140" y="12" width="92" height="48"/>
  <text class="t" x="150" y="29">execute</text>
  <text class="m" x="150" y="42">engine: "vm"</text>
  <text class="m" x="150" y="52">legacy when off</text>
</svg>

Added by the opencode bot (AI-generated).

Public API: adds the optional experimental.codemode_vm config key, default off (backwards compatible)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot added the contributor label Nov 6, 2026
This was referenced Nov 6, 2026
feat(codemode): make Code Mode runs suspendable and resumable #61856
Closed
feat(codemode): suspend only durable work, resume with host outcomes, and save fetch responses #62086
Closed
@jlongster
jlongster force-pushed the codemode-vm-opencode branch 3 times, most recently from 0cf2d0b to d500c7f Compare November 6, 2026 16:02
Base automatically changed from codemode-vm-flag to dev November 6, 2026 17:37
jlongster added 2 commits November 6, 2026 17:37
@jlongster
feat(core): add experimental.codemode_vm config flag
26ee0fc
@jlongster
feat(core): run Code Mode on the bytecode VM behind experimental.code…
122885f
…mode_vm
@jlongster
jlongster force-pushed the codemode-vm-opencode branch from d500c7f to 122885f Compare November 6, 2026 17:38
opencodejr[bot]
opencodejr Bot reviewed Nov 6, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The core change looks sound: with the flag off, the code path is the same as dev, and the engine is chosen per call from config, with a separate runtime cache for each engine.

How I checked: core Code Mode, config and normalization tests pass (93/0), and typecheck:tsc is clean. packages/codemode tests pass (1595/0). Sandbox-escape probes against both engines gave identical, contained results: no process or globalThis, the Function constructor is blocked, and an infinite loop ends at the timeout. My end-to-end TUI drive run with the flag on finished the turn, but the execute call never appeared, so it did not confirm anything.

Public API: one addition, the optional boolean config key experimental.codemode_vm (default off), shown in the OpenAPI spec and the generated client types. Config also accepts experimental.codemodeVm as an alias, and OPENCODE_FLAGS accepts codemode_vm / -codemode_vm. All of this is backwards compatible; existing configs are unaffected.

Concerns, both inline:

  • The flag reads OPENCODE_FLAGS with its own parser instead of Flag. As a result, all and experimental.all_flags don't turn it on.
  • The camelCase codemodeVm alias in normalization is a one-off that no other experimental key has.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/src/codemode/tool.ts
@@ -71,6 +73,22 @@ export type Inventory = {
readonly namespaces?: ReadonlyMap<string, ToolNamespace>
}

/** Reads `experimental.codemode_vm` (or `OPENCODE_FLAGS`) on every call; without one, it is off. */
const vmEnabled = Effect.gen(function* () {

@opencodejr opencodejr Bot Nov 6, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reparses OPENCODE_FLAGS by hand instead of going through Flag, so it doesn't match how the other flags work: OPENCODE_FLAGS=all and experimental.all_flags: true won't turn it on, even though ConfigFlag documents both as turning every flag on. It also accepts codemodeVm in the environment variable. I'd pick one of these:

  • Register it in ConfigFlag.registry and read it with Flag.enabled("codemode_vm"). Note that this would turn it on by default in local and dev builds.
  • Keep it config-only, like partRowsEnabled in session/projector.ts, and drop the environment-variable handling.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/src/config/normalize.ts
@@ -465,6 +465,15 @@ function normalizeExperimental(
const value = decodeEncoded(schema, experimental[key], ["experimental", key], diagnostics)
if (value !== undefined) result[key] = value
})
if (!own(experimental, "codemode_vm") && own(experimental, "codemodeVm")) {

@opencodejr opencodejr Bot Nov 6, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No other experimental key has a camelCase alias, and the schema doesn't mention codemodeVm. A one-off alias for a brand-new key is extra surface we'd have to keep supporting. Unless there's a reason for it, I'd drop it and accept only codemode_vm.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
opencodejr[bot]
opencodejr Bot reviewed Nov 6, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push only rebases the branch onto dev now that #62357 has merged. The two core commits are unchanged, and the core Code Mode and config tests still pass (93/0) with typecheck:tsc clean.

Both earlier points are still open: the hand-rolled OPENCODE_FLAGS parsing in tool.ts, and the one-off codemodeVm alias in normalization.

Public API: unchanged since the last review. It adds the optional experimental.codemode_vm config key (default off), which shows up in the OpenAPI spec and the generated client types. This is backwards compatible.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jlongster
jlongster merged commit 7f321ab into dev Nov 6, 2026
23 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@jlongster
jlongster deleted the codemode-vm-opencode branch November 6, 2026 17:56
@thdxr thdxr mentioned this pull request Nov 6, 2026
release: new docs at /docs, lighter home page (dev → production) #62402
Closed
@amrkmn amrkmn mentioned this pull request Nov 7, 2026
opencode 2.2.6 amrkmn/homebrew-tap#1217
Closed
1 task
This was referenced Nov 7, 2026
feat: opencode release v2.2.6 sprisa/opencode-server#84
Merged
Tool release: OpenCode 2 v2.2.6 (was v2.2.5) agent-sh/agnix#1808
Closed
autonull pushed a commit to autonull/opencode_spacegraph that referenced this pull request Nov 7, 2026
@jlongster me
feat(core): run Code Mode on the bytecode VM behind experimental.code…
0842783
…modeVm (anomalyco#62358)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@jlongster
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.