HKUDS/nanobot · error · KeyError

model_preset not found. Available

Error message

model_preset {name!r} not found. Available: {', '.join(presets) or '(none)'}

What it means

Raised by normalize_preset_name when the stripped preset name does not exactly match any key in the presets dict (fuzzy matching against available keys is attempted first but found no candidate). The message lists the actually available preset names so callers can self-correct; '(none)' appears when no presets are configured at all.

Solutions

  1. Use one of the preset names listed in the error message
  2. Check for typos or case differences in the preset name
  3. Add the missing preset under model_presets in the configuration
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nanobot/agent/model_presets.py:87 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/nanobot@42f37dc4c0 (2026-08-26). Data as JSON: /api/errors/db2e917aff629d34. Report an issue: GitHub.

Appendix: source

Thrown at nanobot/agent/model_presets.py:87

    presets: dict[str, ModelPresetConfig],
    provider: LLMProvider,
    loader: PresetSnapshotLoader | None,
) -> ProviderSnapshot:
    if loader is not None:
        return replace(loader(name), model_preset=name)
    return build_static_preset_snapshot(provider, name, presets[name])


def normalize_preset_name(name: str | None, presets: dict[str, ModelPresetConfig]) -> str:
    if not isinstance(name, str) or not name.strip():
        raise ValueError("model_preset must be a non-empty string")
    name = name.strip()
    if name in presets:
        return name
    matches = [candidate for candidate in presets if candidate.casefold() == name.casefold()]
    if len(matches) == 1:
        return matches[0]
    raise KeyError(f"model_preset {name!r} not found. Available: {', '.join(presets) or '(none)'}")

View on GitHub (pinned to 42f37dc4c0)