Skip to content

v1.14.32 regression: plugin agents and MCPs silently fail to register (ALS context lost during InstanceStore.boot) #25457

Closed

Description

@gabriel-ferraresi

Bug Report

Version: v1.14.32 (regression from v1.14.31)
Component: Plugin System / Instance Bootstrap
Severity: High — all third-party plugins that register agents/MCPs are broken

Summary

After upgrading from v1.14.31 to v1.14.32, third-party plugins (e.g., oh-my-opencode) load successfully (green indicator in UI) but their custom agents and MCP servers silently fail to register. Only the default build and plan agents appear. Plugin-provided MCP servers show up in the UI but are greyed out / disabled with no toggle to enable them.

Reverting to v1.14.31 immediately restores all plugin agents and MCPs.

Root Cause

The InstanceStore refactor in v1.14.32 broke AsyncLocalStorage (ALS) propagation during plugin initialization.

v1.14.31 (working)

Instance.provide() -> boot() sets ALS before running init:

typescript // packages/opencode/src/project/instance.ts @ v1.14.31 function boot(input: { directory: string; init?: () => Promise<any>; ... }) { return iife(async () => { const ctx = /* resolve context */ await context.provide(ctx, async () => { // ALS IS SET HERE await input.init?.() // plugin init runs WITH ALS available }) return ctx }) }

v1.14.32 (broken)

InstanceStore.boot() only provides InstanceRef via Effect context, not ALS:

typescript // packages/opencode/src/project/instance-store.ts @ v1.14.32 (lines 62-68) const boot = <R>(input: LoadInput<R> & { directory: string }) => Effect.gen(function* () { const ctx: InstanceContext = /* resolve context */ if (input.init) yield* input.init.pipe(Effect.provideService(InstanceRef, ctx)) // Only Effect Context, NO ALS return ctx })

Why it breaks

  1. Plugin init() runs as an async callback inside Effect.promise()
  2. InstanceRef (Effect Context) does NOT propagate across async/await boundaries — only Node.js ALS does
  3. When the plugin's async server function calls Instance.current (which uses ALS), it throws LocalContext.NotFound
  4. Agent and MCP registration silently fails — no error is surfaced to the user

The fix pattern already exists

The v1.14.32 codebase itself documents this exact limitation in packages/opencode/src/effect/bridge.ts:

"Effect's InstanceRef/WorkspaceRef do not propagate across async/await boundaries inside Effect.promise(() => async fn) callbacks that re-enter Effect via AppRuntime.runPromise, but Node's AsyncLocalStorage does. Use this whenever an Effect crosses into JS that may itself spawn new Effect runtimes (workspace adapters, legacy plugins, etc.)."

The EffectBridge.fromPromise function was added to solve this for workspace adapters, but the same pattern was not applied to the plugin initialization path in InstanceStore.boot.

Reproduction Steps

  1. Install oh-my-opencode plugin (or any plugin that registers custom agents via oh-my-openagent.jsonc)
  2. Configure agents in oh-my-openagent.jsonc
  3. Upgrade OpenCode from v1.14.31 to v1.14.32
  4. Restart OpenCode
  5. Observe: only build and plan agents appear; plugin MCPs are greyed out

Suggested Fix

Apply the same ALS restoration pattern from EffectBridge.fromPromise to InstanceStore.boot:

``typescript
// Current (broken):
if (input.init)
yield* input.init.pipe(Effect.provideService(InstanceRef, ctx))

// Fix: Also restore ALS so async callbacks inside init can access Instance.current
if (input.init) {
const { context: instanceContext } = await import("./instance-context")
yield* Effect.promise(() =>
instanceContext.provide(ctx, async () => {
await Effect.runPromise(input.init!.pipe(Effect.provideService(InstanceRef, ctx)))
})
)
}
``

Environment

  • OS: Windows 11
  • OpenCode: v1.14.32 (Desktop + CLI)
  • Plugin: oh-my-opencode@3.17.12
  • Node: v24.11.0

Related Files

File Change
packages/opencode/src/project/instance-store.ts New file — boot() provides InstanceRef but not ALS
packages/opencode/src/project/instance.ts Refactored — delegates to InstanceStore.load
packages/opencode/src/project/bootstrap.ts Refactored from Effect.gen to Service class
packages/opencode/src/effect/bridge.ts Added fromPromise — the fix pattern that should be applied to InstanceStore.boot
packages/opencode/src/plugin/index.ts WorkspaceAdaptor -> WorkspaceAdapter rename

Activity

  1. github-actions commented on May 2, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. gabriel-ferraresi commented on May 2, 2026

    @gabriel-ferraresi
    Author

    Related: #21032 — This is the same class of bug that occurred in v1.3.14. The pattern repeats: OpenCode refactors the instance bootstrap, ALS context propagation breaks, and plugins silently fail to register agents/MCPs. The root cause is the same — plugin async callbacks lose \Instance.current\ (ALS) across Effect/async boundaries. Our issue provides the exact code-level diagnosis and a suggested fix for the v1.14.32 occurrence.

  3. thdxr commented on May 2, 2026

    @thdxr
    Member

    tested a few plugins and they seem to work, checking what's going on with omo specifically

  4. gabriel-ferraresi commented on May 2, 2026

    @gabriel-ferraresi
    Author

    Confirmed fixed in v1.14.33 via PR #25449. The fix restores the init parameter (getBootstrapRunEffect()) in all 5 entry points (CLI bootstrap, TUI worker, Hono middleware, workspace router, project reload) plus adds defense-in-depth in the Agent state builder. Plugin agents and MCPs now register correctly after upgrading to v1.14.33. Closing.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions