# Problem Plugins are loaded twice and event handlers are fired twice. OpenCode 0.15.2 # Steps Create a basic plugin: ```typescript import type { Plugin } from "@opencode-ai/plugin" export const PreAcceptPlugin: Plugin = async ({ client }) => { return { async event({ event }) { switch (event.type) { case "session.idle": { await client.tui.showToast({ body: { title: "[debug] event", message: event.type, variant: "info" }, }) break } default: { break } } }, } } ``` Send any message and when done processing you will see the toast show up two times. Here is a simple working fix: ```typescript import type { Plugin } from "@opencode-ai/plugin" let loaded = false export const PreAcceptPlugin: Plugin = async ({ client }) => { if (loaded) return {} loaded = true return { async event({ event }) { switch (event.type) { case "session.idle": { await client.tui.showToast({ body: { title: "[debug] event", message: event.type, variant: "info" }, }) break } default: { break } } }, } } ```
Activity
rekram1-node commentedon Oct 14, 2025
@AndrewBarba I can't replicate your issue, can you run
opencode debug configand show me the output?Maybe there are global plugins also firing?
AndrewBarba commentedon Oct 14, 2025
Ah interesting, listed twice even though my opencode.json only has it once:
opencode.json:
I guess plugins dir loaded automatically?
rekram1-node commentedon Oct 14, 2025
@AndrewBarba yes plugins dir is loaded automatically
rekram1-node commentedon Oct 14, 2025
we can add a check to not double it though