HKUDS/nanobot · error · TypeError
context_window_tokens must be an integer
Error message
context_window_tokens must be an integer
What it means
Error "context_window_tokens must be an integer" thrown in HKUDS/nanobot.
Source
Thrown at nanobot/agent/model_runtime.py:159
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,
)
return self._runtime
def _refresh_provider_generation(self) -> LLMRuntime | None:
"""Adopt direct provider-default changes only for provider-backed defaults."""
if not self._tracks_provider_generation:
return None
runtime = self._runtime
captured = LLMRuntime.capture(
runtime.provider,
runtime.model,
context_window_tokens=runtime.context_window_tokens,
model_preset=runtime.model_preset,
snapshot_signature=runtime.snapshot_signature,
)View on GitHub (pinned to 42f37dc4c0)
When it happens
Trigger: Thrown at nanobot/agent/model_runtime.py:159 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/ab030f051d28d75b.
Report an issue: GitHub.