{"record":{"id":"ab030f051d28d75b","repo":"HKUDS/nanobot","slug":"context-window-tokens-must-be-an-integer","errorCode":null,"errorMessage":"context_window_tokens must be an integer","messagePattern":"context_window_tokens must be an integer","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"nanobot/agent/model_runtime.py","lineNumber":159,"sourceCode":"    def select_model(self, model: str) -> LLMRuntime:\n        \"\"\"Change the default model without reconstructing downstream consumers.\"\"\"\n        if not isinstance(cast(object, model), str) or not model.strip():\n            raise ValueError(\"model must be a non-empty string\")\n        self._runtime = replace(\n            self._runtime,\n            model=model.strip(),\n            model_preset=None,\n        )\n        return self._runtime\n\n    def select_context_window(self, context_window_tokens: int) -> LLMRuntime:\n        \"\"\"Change the default context limit for future admissions.\"\"\"\n        raw_context_window = cast(object, context_window_tokens)\n        if not isinstance(raw_context_window, int) or isinstance(\n            raw_context_window,\n            bool,\n        ):\n            raise TypeError(\"context_window_tokens must be an integer\")\n        self._runtime = replace(\n            self._runtime,\n            context_window_tokens=context_window_tokens,\n        )\n        return self._runtime\n\n    def _refresh_provider_generation(self) -> LLMRuntime | None:\n        \"\"\"Adopt direct provider-default changes only for provider-backed defaults.\"\"\"\n        if not self._tracks_provider_generation:\n            return None\n        runtime = self._runtime\n        captured = LLMRuntime.capture(\n            runtime.provider,\n            runtime.model,\n            context_window_tokens=runtime.context_window_tokens,\n            model_preset=runtime.model_preset,\n            snapshot_signature=runtime.snapshot_signature,\n        )","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/HKUDS/nanobot/blob/42f37dc4c0e409eac7818a82d165c5f2757bc075/nanobot/agent/model_runtime.py#L141-L177","documentation":"Error \"context_window_tokens must be an integer\" thrown in HKUDS/nanobot.","triggerScenarios":"Thrown at nanobot/agent/model_runtime.py:159 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"42f37dc4c0e409eac7818a82d165c5f2757bc075","analyzedAt":"2026-08-26T00:18:52.276Z","schemaVersion":2},"datasetVersion":"2026-08-26T04:18:47.238Z"}