Skip to content

opencode 1.18.5: evaluate new plugin API surface (v2 hooks, cost tiers, tool.definition, compaction hooks) #24

Description

@khalilgharbaoui

Compatibility audit against opencode 1.18.5 (2026-07-26) found nothing broken — the plugin runs a full live turn on it, and src/opencode-types.ts (our hand-written structural mirror) still matches. Details are in AGENTS.md's compatibility gotcha.

What the audit did surface is new opencode surface that overlaps things this plugin hand-rolled. Each item below is an independent evaluation, none is urgent:

1. v2 plugin API

@opencode-ai/plugin/v2 ships effect + promise flavors with a PluginContext exposing aisdk, catalog, agent, skill, command, reference, integration hooks (each with Reload). v1 Plugin is still supported and is what we use. Question: does registering our provider/models through catalog/aisdk buy anything (hot reload of the model list? cleaner account-provider expansion?) or is it churn? Do not migrate without a concrete win.

2. Long-context pricing tiers

The model schema gained optional cost.tiers ({ tier: { type: "context", size } }) and cost.experimentalOver200K. Most entries in src/models.ts declare context: 1_000_000, and Anthropic prices requests above 200K input tokens differently for the long-context models. Verify the current published numbers (see the claude-api reference, not memory) and decide whether to declare tiers so opencode's cost accounting stops understating big-context turns. Note the (N×) display-multiplier convention in defineModel assumes one flat ratio — check how a tiered model should render before changing names.

3. tool.definition hook

(input: { toolID }, output: { description, parameters }) lets a plugin overlay tool descriptions/params. We already overlay proxy-tool descriptions ourselves inside src/proxy-mcp.ts. Not obviously better, but worth knowing it exists if we ever need to adjust an opencode-native tool's description.

4. Compaction hooks

experimental.session.compacting ({ context: string[], prompt? }) and experimental.compaction.autocontinue ({ enabled }). We detect /compact via opencodeAgent === "compaction" in chat.params and run our own auto-continue nudge. The autocontinue hook in particular is adjacent to shouldAutoContinueIncompleteTurn — check for double-continue interaction before doing anything here.

5. Smaller notes

  • capabilities.interleaved gained a field: "reasoning" variant; our type mirror only lists reasoning_content / reasoning_details. Harmless (we set interleaved: false), but widen the mirror if we ever use it.
  • PluginInput gained serverUrl: URL and $: BunShell. Neither is needed today; serverUrl does not expose a version route (checked every route in sdk.gen.js).
  • experimental.chat.system.transform, chat.headers, permission.ask exist and are unused by us.
  • opencode run dropped the -a shorthand for --agent, and gained --variant / --thinking / --auto / --pure / --fork / --attach. Smoke-test scripts must spell out --agent. --variant maps to our reasoning variants and is a nice way to exercise them from the CLI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions