Skip to content

fix(cli): run plugin config() hooks before reading provider config#9566

Open
kilo-code-bot[bot] wants to merge 1 commit intomainfrom
fix/provider-plugin-ordering
Open

fix(cli): run plugin config() hooks before reading provider config#9566
kilo-code-bot[bot] wants to merge 1 commit intomainfrom
fix/provider-plugin-ordering

Conversation

@kilo-code-bot
Copy link
Copy Markdown
Contributor

@kilo-code-bot kilo-code-bot Bot commented Apr 27, 2026

Summary

Move plugin.list() above cfg/ModelsDev.get() in the Provider state initializer so plugin config() hooks can mutate enabled_providers, disabled_providers, and provider entries before any downstream consumer reads them.

Before this change, ModelsDev.get() already read enabled_providers/disabled_providers from config to decide whether to inject the kilo provider — but it ran before plugins had a chance to mutate config, so plugin-authored filters were silently ignored at that stage. The rest of Provider.layer only saw plugin mutations because config.get() happens to return the same cached object reference that the plugin mutated in place. That reference-identity invariant broke whenever Instance state was disturbed between tests, causing the spurious Windows failure in https://github.com/Kilo-Org/kilocode/actions/runs/24988038428/job/73166225696.

Why

Fixes the flaky plugin config enabled and disabled providers are honored test and removes the latent bug where plugins couldn't influence the kilo-provider injection decision inside ModelsDev.get().

How to test

  1. cd packages/opencode && bun run test test/provider/provider.test.ts — the plugin config tests should pass.
  2. Write a plugin with a config() hook that sets cfg.disabled_providers = ["kilo"]; confirm the kilo provider no longer appears in the provider list.

Move plugin.list() above cfg/ModelsDev.get() in Provider state initialization
so plugin config() hooks can mutate enabled_providers, disabled_providers, and
provider entries before downstream consumers read them. ModelsDev.get()
already reads enabled/disabled to decide whether to inject the kilo provider,
so plugins must run first for that decision to see their mutations.

Fixes a flaky Windows test (plugin config enabled and disabled providers are
honored) that depended on mutation-in-place reference identity between the
plugin-captured cfg and the provider-captured cfg — an invariant that broke
whenever Instance state was disturbed between tests.
@markijbema markijbema self-assigned this Apr 27, 2026
@kilo-code-bot
Copy link
Copy Markdown
Contributor Author

kilo-code-bot Bot commented Apr 27, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • .changeset/provider-plugin-ordering.md
  • packages/opencode/src/provider/provider.ts

Reviewed by gpt-5.4-20260305 · 822,339 tokens

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant