kilocode icon indicating copy to clipboard operation
kilocode copied to clipboard

[Bug] One malformed entry in provider.<id>.models invalidates the entire provider block

Open kz363 opened this issue 2 months ago • 0 comments

Description

provider.<id>.models entries are validated as one Effect Schema struct over the whole models record. A single malformed entry — e.g. a limit object with output but no context — fails validation for the entire provider block, so every model registered under that provider disappears from the registry, including fully valid entries. Sessions then fail with Model not found: <provider>/<model> even though their individual entries are well-formed.

All-or-nothing validation is very high blast radius for a model list that can hold many entries, especially when entries are written by tooling (see below).

Schema evidence. Verified against the installed 7.7.9 CLI binary (string present in the compiled bundle):

limit:V.Struct({context:V.Finite,input:V.optional(V.Finite),output:V.Finite})
  1. When a limit object is present, limit.context is required (V.Finite, not V.optional), while limit.input is optional. That asymmetry is easy to trip.
  2. Application granularity (record-level, not per-entry) is established by the observed behavior in the repro below, not by the struct string itself — the string only proves the limit shape.
  3. The same shape is documented in the public CLI config schema ("$schema": "https://app.kilo.ai/config.json" in kilo.jsonc); under ProviderConfig.models.<id>.limit, both context and output are listed as required and input is unmentioned — so the runtime asymmetry matches the schema, but the required-ness isn't called out anywhere in prose, and nothing documents what happens to the rest of the block when one entry is invalid.

Expected vs actual:

  • Expected: the malformed entry (bad-model) is skipped with a warning naming the entry; good-model and the rest of the provider's models remain fully usable.
  • Actual: the whole provider block fails validation; every model on that provider is unresolvable until the config is manually fixed.

Impact. A single bad entry takes down all models on a provider. We hit this in production: two entries written with limit: { output: 8192 } (no context) made every model on the provider fail with Model not found: litellm/<model>, even though every entry those in-flight sessions actually used was valid.

kilo config check is listed in the CLI reference (one line: "check configuration for warnings and errors") and correctly exits nonzero — a usable gate — but its exit-code semantics are not documented, and nothing in the session start-up path surfaces "your provider block was dropped because entry X is malformed" prominently; the first symptom is an opaque Model not found at request time.

Entries may be written by tooling, not only by humans (see below), so a regression in a config generator instantly propagates to every session.

How we hit this. Our model list is generated: model entries are rendered from a local LiteLLM gateway's config by a script. Two entries lacked limit.context. Because validation is all-or-nothing, those two entries killed the entire provider — including the other entries in the same provider.<id> block. A provider block that can hold tens of model entries is exactly the case where one malformed entry should degrade gracefully rather than take down the rest.

Suggested fix

  1. Per-entry validation granularity. Validate each models entry independently: a malformed entry should be skipped (dropped from the registry) with a warning that names the provider and entry key, instead of invalidating the whole provider.<id> block. Keeping the detailed per-key error (which the validator already produces) in the warning would make the failure self-explanatory.
  2. Consistency of limit keys. limit.context is required but limit.input is optional (and unmentioned in the schema) — a surprising asymmetry that tooling gets wrong easily. Either make both optional (deriving sensible defaults) or make both required, and document the choice (the schema at https://app.kilo.ai/config.json is the source of truth for provider.<id>.models.<id>.limit and currently lists context and output as required).
  3. Document kilo config check as the official preflight gate. It already exits nonzero on invalid config, which is exactly what CI / start-up hooks need. Documenting it (including exit-code semantics) would let users and tooling catch malformed lists before sessions start. Ideally, its output could also gain a machine-readable form (e.g. --json) listing each invalid entry individually, which would pair naturally with per-entry tolerance.

Happy to provide additional repro details if useful.

Kilo version

  • @kilocode/cli 7.7.9 (verified). 7.8.1 is current stable at filing time; the 7.8.0/7.8.1 changelogs contain no provider-validation granularity changes. Re-verified on the installed 7.7.9 binary after reading those changelogs — output and registry behavior identical. 7.8.x is not installed in this environment; if maintainers confirm or deny 7.8.x behavior, that would close out the version question.

Steps to reproduce

Config (kilo.jsonc, trimmed — one valid entry + one bad entry):

{
  "$schema": "https://app.kilo.ai/config.json",
  "provider": {
    "litellm": {
      "baseUrl": "http://localhost:4000",
      "apiKey": "<redacted>",
      "models": {
        "good-model": { "name": "good-model", "limit": { "context": 128000, "output": 8192 } },
        "bad-model":  { "name": "bad-model",  "limit": { "output": 8192 } }
      }
    }
  }
}

Observed (isolated KILO_CONFIG_DIR, fresh state):

$ kilo config check
/tmp/repro/kilo.jsonc
  Configuration is invalid at /tmp/repro/kilo.jsonc: provider.litellm.models.bad-model.limit.context: Missing key
$ echo $?
1

$ kilo models | grep -E 'good-model|bad-model'
(no output — BOTH entries are gone from the registry, including the valid one)

Control: adding "context": 128000 to bad-model's limit makes kilo config check pass and good-model reappear in kilo models — the drop is caused solely by the malformed entry.

The error message correctly names the offending entry and key (provider.litellm.models.bad-model.limit.context: Missing key) — that part is good. But the consequence is that the entire provider.litellm block is rejected: good-model (a perfectly valid entry) is also unresolvable, and any session configured with litellm/good-model (or any other entry in the block) fails with Model not found: litellm/good-model.

Operating System

Linux x64

Plugins

none

Terminal

n/a (CLI only; Node v24 via nvm)

kz363 avatar Oct 03 '26 03:10 kz363