{"record":{"id":"587f7d7b4bec43b7","repo":"HKUDS/DeepTutor","slug":"llm-key-rotation-exhausted","errorCode":null,"errorMessage":"LLM key rotation exhausted","messagePattern":"LLM key rotation exhausted","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"deeptutor/core/agentic/client.py","lineNumber":156,"sourceCode":"    def __init__(self, key_pool: KeyPool, clients: dict[str, Any]) -> None:\n        self._key_pool = key_pool\n        self._clients = clients\n\n    async def create(self, **kwargs: Any) -> Any:\n        for attempt in range(2):\n            api_key = self._key_pool.next()\n            try:\n                return await self._clients[api_key].chat.completions.create(**kwargs)\n            except Exception as exc:\n                status = getattr(exc, \"status_code\", None) or getattr(\n                    getattr(exc, \"response\", None), \"status_code\", None\n                )\n                if status != 429:\n                    raise\n                self._key_pool.mark_429(api_key)\n                if attempt:\n                    raise\n        raise RuntimeError(\"LLM key rotation exhausted\")\n\n\nclass _KeyRotatingClient:\n    def __init__(self, key_pool: KeyPool, clients: dict[str, Any]) -> None:\n        self._clients = clients\n        self.chat = SimpleNamespace(completions=_KeyRotatingCompletions(key_pool, clients))\n\n    async def close(self) -> None:\n        await asyncio.gather(*(_close_client(client) for client in self._clients.values()))\n\n\nasync def _close_client(client: Any) -> None:\n    close = getattr(client, \"aclose\", None) or getattr(client, \"close\", None)\n    if not callable(close):\n        return\n    result = close()\n    if inspect.isawaitable(result):\n        await result","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/core/agentic/client.py#L138-L174","documentation":"Error \"LLM key rotation exhausted\" thrown in HKUDS/DeepTutor.","triggerScenarios":"Thrown at deeptutor/core/agentic/client.py:156 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":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}