diff --git a/src/index.ts b/src/index.ts index 2dc657d5..cb8df6a1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,6 +30,7 @@ import { isInternalStructuredSession, noteStructuredOutputStep, rememberSessionModel, + setConnectedProviders, STRUCTURED_OUTPUT_AGENT, STRUCTURED_OUTPUT_MAX_STEPS, STRUCTURED_OUTPUT_TOOLS, @@ -435,6 +436,14 @@ export const OpenCodeMemPlugin: Plugin = async (ctx: PluginInput) => { } } catch (error) { log("Failed to refresh opencode provider state", { error: String(error) }); + // The host provider directory may be unavailable (e.g. a plugin context + // without `ctx.provider`). Keep the explicitly configured provider + // connected so structured-output calls are attempted instead of being + // denied by the connectivity gate; a bad provider id still fails loudly + // on the call itself and falls back to the external API. + if (CONFIG.opencodeProvider) { + setConnectedProviders([CONFIG.opencodeProvider]); + } } };