HKUDS/nanobot · error · ValueError
model must be a non-empty string
Error message
model must be a non-empty string
What it means
Raised by ModelRuntime.select_model when the model argument fails the isinstance-str check or is blank after stripping. It guards the runtime model override path (which also clears model_preset); None or empty model names from config or SDK calls are rejected before the runtime is rebuilt.
Solutions
- Pass a concrete non-empty model identifier such as "gpt-4o" or "claude-sonnet-4-20250514"
- If the value comes from user input, validate it is a non-empty string before calling select_model
- To select by preset instead, call select_preset with a preset name
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at nanobot/agent/model_runtime.py:144 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/60fcff9fb1a2b63d.
Report an issue: GitHub.
Appendix: source
Thrown at nanobot/agent/model_runtime.py:144
presets=self._model_presets,
provider=self._runtime.provider,
loader=self._preset_snapshot_loader,
)
runtime = self.resolve_snapshot(snapshot)
self._resolved_presets[normalized] = runtime
return runtime
def select_preset(self, name: str | None) -> LLMRuntime:
"""Select a named preset as the default for future turns."""
runtime = self.resolve_preset(name)
self._runtime = runtime
self._tracks_provider_generation = False
return runtime
def select_model(self, model: str) -> LLMRuntime:
"""Change the default model without reconstructing downstream consumers."""
if not isinstance(cast(object, model), str) or not model.strip():
raise ValueError("model must be a non-empty string")
self._runtime = replace(
self._runtime,
model=model.strip(),
model_preset=None,
)
return self._runtime
def select_context_window(self, context_window_tokens: int) -> LLMRuntime:
"""Change the default context limit for future admissions."""
raw_context_window = cast(object, context_window_tokens)
if not isinstance(raw_context_window, int) or isinstance(
raw_context_window,
bool,
):
raise TypeError("context_window_tokens must be an integer")
self._runtime = replace(
self._runtime,
context_window_tokens=context_window_tokens,View on GitHub (pinned to 42f37dc4c0)