#14647·kilocode

Transient Kilo model-catalog fetch failure silently removes the provider and breaks every model in a worktree

Author: fpligerCreated Sep 28, 2026Updated Sep 28, 2026
Labelsbug

Description

Description

When the Kilo model-catalog fetch fails or returns empty, the kilo provider is silently removed from a worktree's provider list, and every Kilo model in that worktree then fails with a misleading Model not found: kilo/<model-id>. error. New sessions and forks inside that worktree stay broken regardless of which model is selected, while other worktrees keep working normally.

This affects Kilo organization accounts, because the models.dev fallback and the fetch retry are both skipped when an organization ID is present.

The error is not caused by an invalid model ID: the same model streams successfully in another worktree in the same backend process moments later, and the model is present in the gateway catalog.

Steps to reproduce

Deterministic (unit-level):

  1. Sign in with a Kilo account that has an organization (auth.json entry for kilo has an accountId).
  2. Make the org-scoped Kilo catalog fetch return an empty result / error (e.g. take the process offline, or make fetchKiloModels return { models: {}, error }).
  3. In a directory whose provider state is built while the fetch is failing, request any Kilo model.
  4. Observe the failure below. A second directory whose provider state was built earlier still works; forking inside the affected directory also fails.

Observed (real-world):

  1. Long-running session in a worktree works normally on kilo/deepseek/deepseek-v4.1-flash.
  2. Machine goes idle for ~2.5h (overnight sleep) and a transient network failure occurs.
  3. Sending "continue" fails with Model not found: kilo/deepseek/deepseek-v4.1-flash.
  4. Switching the picker to a different model (kilo/deepseek/deepseek-v4-pro-0813, then kilo/moonshotai/kimi-k3) still fails, once per attempt.
  5. Creating forks of the session also fails with the same class of error for whatever model is selected.
  6. Meanwhile the same model (kilo/deepseek/deepseek-v4-pro-0813) streams successfully in a different worktree handled by the same backend process, and the model is present in the live gateway catalog.

Expected behavior

A transient catalog fetch failure should not remove the provider or permanently break a directory. At minimum, the error should say that the provider catalog failed to load, and the state should recover once the fetch succeeds.

Actual behavior

  • kilo disappears from the provider list for that directory.
  • Every Kilo model returns Model not found: kilo/<model-id>.
  • Forks inherit the broken per-directory provider state, so they fail too.
  • The state does not self-heal until the directory's provider state is invalidated (e.g. successful hourly models.dev refresh or a backend restart).

Error surfaced in the UI/logs:

Model not found: kilo/deepseek/deepseek-v4-pro-0813.
{
  "name": "UnknownError",
  "data": { "message": "Model not found: kilo/deepseek/deepseek-v4-pro-0813." }
}

Backend log (redacted):

level=ERROR message="prompt_async failed" cause="Cause([Die(ProviderModelNotFoundError: Model not found: kilo/deepseek/deepseek-v4.1-flash.)])"
level=ERROR message="prompt_async failed" cause="Cause([Die(ProviderModelNotFoundError: Model not found: kilo/deepseek/deepseek-v4-pro-0813.)])"
level=ERROR message="prompt_async failed" cause="Cause([Die(ProviderModelNotFoundError: Model not found: kilo/moonshotai/kimi-k3.)])"

Note the missing No models are currently available. hint — see root cause.

Environment

  • Kilo Code VS Code extension 7.7.9 (CLI backend bundled at the same version, tag v7.7.9)
  • Reported from the Agent Manager (VS Code), but the failure is in the CLI backend provider state
  • OS: macOS <version>
  • Kilo account type: organization

Root cause

The chain (line numbers from v7.7.9):

  1. packages/opencode/src/kilocode/provider/catalog.ts — organization() returns the account's org from OAuth accountId, so org is set.

  2. packages/opencode/src/provider/model-cache.ts — the Kilo catalog is fetched org-scoped (fetch, ~L283). A failed fetch still gets committed and cached for the 5-minute TTL (~L211-225, L251-253); the empty result is only logged at debug/warn level.

  3. packages/opencode/src/provider/models.ts:88-99 — because org is set, the models.dev fallback is skipped, and the retry refresh is gated on !org:

    typescript
    const models = !valid || org || Object.keys(fetched).length > 0 ? fetched : (fallback?.models ?? {})
    ...
    if (valid && !org && Object.keys(fetched).length === 0) yield* cache.refresh("kilo", fetch)…

    So an empty fetch result becomes the provider's model list, with no fallback and no retry.

  4. packages/opencode/src/provider/provider.ts:1780-1783 — any provider with zero models is deleted:

    typescript
    if (Object.keys(provider.models).length === 0) {
      delete providers[providerID]
      continue
    }
  5. packages/opencode/src/provider/provider.ts:1957-1969 — getModel takes the missing-provider branch and hardcodes modelsEmpty = false (~L1967, a kilocode_change), so the diagnostic hint is suppressed and the message is just Model not found: kilo/<id>.

  6. Provider state is per-directory InstanceState (provider.ts:1428), so only the affected worktree is poisoned. It is rebuilt only when ModelsRefresh.notify() fires (provider.ts:1796, packages/opencode/src/kilocode/provider/models-refresh.ts) on a successful models.dev refresh, not when the 5-minute Kilo cache recovers — so it looks permanent.

  7. A fork runs in the same directory, so it inherits the poisoned state and getModel fails for any selected model.

The trigger is a transient org-scoped catalog fetch failure; the bug is how the code handles that empty result (delete the provider + misleading error + no recovery).

Possible fix?

  • models.ts: when org is set and fetched is empty, fall back to fallback.models (or otherwise avoid emitting an empty kilo provider), and schedule a retry when the result is empty regardless of org.
  • provider.ts: don't silently delete providers with an empty model map, or at minimum make the error accurate — distinguish "unknown provider" from "provider catalog failed to load", and stop hardcoding modelsEmpty = false on the missing-provider branch.
  • Invalidate/rebuild provider state when ModelCache recovers, instead of waiting up to an hour for a models.dev refresh.

Workaround

Reload the VS Code window or restart the kilo serve backend. This disposes the per-directory Instances and rebuilds the provider state, which clears the poisoned entry. No files or sessions need to be deleted.

Related

  • #14531 / commit 89f0cbad72 ("recover Agent Manager session recovery and model providers when the CLI backend reconnects during startup", shipped in 7.7.10) is adjacent but client-side (re-fetches providers for the picker); it does not fix the server-side "org + empty fetch → provider deleted → misleading ModelNotFound" path.
  • Behavior of skipping public-model fallbacks for org accounts was introduced in 7.5.10 (#13692).

Plugins

No response

Kilo version

Kilo v 7.7.3, VS Code Kilo Ext v 7.8.1

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

MacOS 26.3.1

Terminal

No response