{"record":{"id":"9d8cb145fc6360fe","repo":"affaan-m/ECC","slug":"ratelimiterror-msg-provider-providertype-ollama-from-e","errorCode":null,"errorMessage":"RateLimitError(msg, provider=ProviderType.OLLAMA) from e","messagePattern":"RateLimitError\\(msg, provider=ProviderType\\.OLLAMA\\) from e","errorType":"exception","errorClass":"RateLimitError","httpStatus":null,"severity":"error","filePath":"src/llm/providers/ollama.py","lineNumber":106,"sourceCode":"                        id=tc.get(\"id\", \"\"),\n                        name=tc.get(\"function\", {}).get(\"name\", \"\"),\n                        arguments=tc.get(\"function\", {}).get(\"arguments\", {}),\n                    )\n                    for tc in result[\"message\"][\"tool_calls\"]\n                ]\n\n            return LLMOutput(\n                content=content,\n                tool_calls=tool_calls,\n                model=model,\n                stop_reason=result.get(\"done_reason\"),\n            )\n        except Exception as e:\n            msg = str(e)\n            if \"401\" in msg or \"connection\" in msg.lower():\n                raise AuthenticationError(f\"Ollama connection failed: {msg}\", provider=ProviderType.OLLAMA) from e\n            if \"429\" in msg or \"rate_limit\" in msg.lower():\n                raise RateLimitError(msg, provider=ProviderType.OLLAMA) from e\n            if \"context\" in msg.lower() and \"length\" in msg.lower():\n                raise ContextLengthError(msg, provider=ProviderType.OLLAMA) from e\n            raise\n\n    def list_models(self) -> list[ModelInfo]:\n        return self._models.copy()\n\n    def validate_config(self) -> bool:\n        return bool(self.base_url)\n\n    def get_default_model(self) -> str:\n        return self.default_model\n","sourceCodeStart":88,"sourceCodeEnd":119,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/src/llm/providers/ollama.py#L88-L119","documentation":"Ollama's generate() wraps exceptions whose message contains '429' or 'rate_limit' in a RateLimitError. It signals the Ollama server (or an intermediary) rejected the request due to request throttling, with the provider type OLLAMA attached.","triggerScenarios":"Sending concurrent generate() calls faster than the Ollama server's queue/limiter allows; a gateway in front of Ollama returning HTTP 429.","commonSituations":"Parallel worker pools hammering a single local Ollama instance; shared Ollama deployments with per-user quotas; API gateways (nginx, Kong) configured with rate limits.","solutions":["Back off and retry with exponential backoff on RateLimitError","Serialize or limit concurrency of generate() calls to the Ollama instance","Increase the rate limit on any intermediary gateway","Check `ollama ps` for GPU/memory contention causing throttling"],"exampleFix":"// before\nresp = provider.generate(inp)\n// after\nfor attempt in range(5):\n    try:\n        resp = provider.generate(inp); break\n    except RateLimitError:\n        time.sleep(2 ** attempt)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"from tenacity import retry, wait_exponential, stop_after_attempt\n@retry(retry=retry_if_exception_type(RateLimitError), wait=wait_exponential(min=1, max=30), stop=stop_after_attempt(5))\ndef safe_generate(inp):\n    return provider.generate(inp)","preventionTips":["Throttle concurrency to the Ollama instance","Use a queue for bulk generation jobs","Monitor 429s and back off proactively","Reserve capacity or scale Ollama replicas under load"],"tags":["rate-limit","ollama","throttling"],"backgroundTag":"rate-limit-exceeded","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}