Skip to content

[FEATURE]: Allow LLM execution to be provided by an external runtime #50185

Closed as not planned

Description

@andreabenetton

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

OpenCode currently owns both agent/session orchestration and the concrete execution path used to invoke LLM providers.

It would be useful to expose a stable execution boundary so that LLM execution could optionally be supplied by an external runtime, while OpenCode continues to own:

  • sessions and conversation history
  • context construction
  • agents and subagents
  • tools and permissions
  • task lifecycle and orchestration

Conceptually:

OpenCode
   |
   | LLM execution contract
   v
Execution adapter
   |
   +-- built-in OpenCode execution
   |
   +-- external runtime

The external runtime would receive the resolved request — messages, tools, model requirements and execution metadata — and return the same normalized LLM event stream OpenCode already consumes.

This could support use cases such as:

  • enterprise inference gateways
  • custom model/provider routers
  • subscription-backed execution runtimes
  • cost- or quota-aware routing
  • provider failover
  • remote or isolated inference
  • centralized credential management

The intent is not to move session or agent orchestration outside OpenCode. Only the execution of a provider turn would become replaceable.

This seems conceptually similar to #45612 and the WorkspaceDriver direction: OpenCode retains the domain semantics and lifecycle, while a replaceable driver can own the concrete execution environment. An LLM execution adapter would apply the same separation to model execution.

Related issues include #14739, #7602 and #6651, but those focus on model identity, fallback, or model selection. This proposal is specifically about exposing the execution boundary itself.

The current native/AI-SDK runtime split already appears to provide a natural seam for such an abstraction, potentially allowing this to start as a refactor with no behavior change before supporting external executors.

Activity

  1. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed proposal, @andreabenetton! As I understand it, you'd like OpenCode to expose a stable LLM execution boundary. OpenCode would keep owning sessions, context, agents, tools and permissions. Running a provider turn could then be handed to an external runtime that returns the same normalized event stream OpenCode already consumes.

    You can get part of this today with a plugin. The aisdk language hook lets a plugin return its own LanguageModelV3 for a model, and that model could forward requests to a gateway or an external runtime:

    await ctx.aisdk.hook("language", (event) => {
      if (event.model.providerID !== "my-gateway") return
      event.language = createMyExternalLanguageModel(event.model, event.options)
    })

    This has two limits:

    • It only covers models that run through the AI SDK, not models on the native provider path.
    • It works at the AI SDK level, not as a runtime-neutral contract that takes the resolved request and returns OpenCode's own event stream.

    Your proposal would fill both gaps.

    Related issues:

    Maintainers will consider this request.

  2. neriousy commented on Nov 12, 2026

    @neriousy
    Member

    Thanks for the suggestion. This isn't something we plan to build, so closing to keep the tracker focused.

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