HKUDS/DeepTutor · error · RuntimeError

LLM key rotation exhausted

Error message

LLM key rotation exhausted

What it means

Error "LLM key rotation exhausted" thrown in HKUDS/DeepTutor.

Source

Thrown at deeptutor/core/agentic/client.py:156

    def __init__(self, key_pool: KeyPool, clients: dict[str, Any]) -> None:
        self._key_pool = key_pool
        self._clients = clients

    async def create(self, **kwargs: Any) -> Any:
        for attempt in range(2):
            api_key = self._key_pool.next()
            try:
                return await self._clients[api_key].chat.completions.create(**kwargs)
            except Exception as exc:
                status = getattr(exc, "status_code", None) or getattr(
                    getattr(exc, "response", None), "status_code", None
                )
                if status != 429:
                    raise
                self._key_pool.mark_429(api_key)
                if attempt:
                    raise
        raise RuntimeError("LLM key rotation exhausted")


class _KeyRotatingClient:
    def __init__(self, key_pool: KeyPool, clients: dict[str, Any]) -> None:
        self._clients = clients
        self.chat = SimpleNamespace(completions=_KeyRotatingCompletions(key_pool, clients))

    async def close(self) -> None:
        await asyncio.gather(*(_close_client(client) for client in self._clients.values()))


async def _close_client(client: Any) -> None:
    close = getattr(client, "aclose", None) or getattr(client, "close", None)
    if not callable(close):
        return
    result = close()
    if inspect.isawaitable(result):
        await result

View on GitHub (pinned to 3e82f13042)

When it happens

Trigger: Thrown at deeptutor/core/agentic/client.py:156 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/587f7d7b4bec43b7. Report an issue: GitHub.