{"record":{"id":"de1cf53c4e12655c","repo":"infiniflow/ragflow","slug":"tenki-rate-limited-please-retry-exc","errorCode":null,"errorMessage":"Tenki rate limited, please retry: {exc}","messagePattern":"Tenki rate limited, please retry: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"warning","filePath":"agent/sandbox/providers/tenki.py","lineNumber":149,"sourceCode":"            \"allow_outbound\": self.allow_outbound,\n            \"max_duration\": self.max_lifetime,\n            \"metadata\": {\"source\": \"ragflow\"},\n        }\n        if self.image:\n            create_kwargs[\"image\"] = self.image\n        if self.cpu_cores > 0:\n            create_kwargs[\"cpu_cores\"] = self.cpu_cores\n        if self.memory_mb > 0:\n            create_kwargs[\"memory_mb\"] = self.memory_mb\n        if self.disk_size_gb > 0:\n            create_kwargs[\"disk_size_gb\"] = self.disk_size_gb\n\n        try:\n            sandbox = self._client.create(**create_kwargs)\n        except errors.QuotaExceededError as exc:\n            raise RuntimeError(f\"Tenki quota exceeded: {exc}\") from exc\n        except errors.RateLimitedError as exc:\n            raise RuntimeError(f\"Tenki rate limited, please retry: {exc}\") from exc\n        except errors.UnauthorizedError as exc:\n            raise SandboxProviderConfigError(\"Tenki authentication failed: check the API key.\") from exc\n        except Exception as exc:\n            # Satisfy the base contract: any other SDK failure becomes RuntimeError.\n            raise RuntimeError(f\"Failed to create Tenki sandbox: {exc}\") from exc\n\n        remote_work_dir = posixpath.join(SANDBOX_HOME, f\"ragflow-codeexec-{uuid.uuid4().hex}\")\n        try:\n            result = sandbox.exec(\n                \"mkdir\",\n                \"-p\",\n                posixpath.join(remote_work_dir, \"artifacts\"),\n                timeout=min(self.timeout, 10),\n            )\n            if result.exit_code != 0:\n                raise RuntimeError(f\"Failed to create sandbox workspace: {result.stderr_text or 'unknown error'}\")\n        except Exception:\n            self._safe_terminate(sandbox)","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/tenki.py#L131-L167","documentation":"Raised when client.create() throws errors.RateLimitedError: the Tenki API throttled the sandbox-creation request. Unlike quota errors this is transient — the message explicitly says 'please retry' — and retrying after a backoff typically succeeds.","triggerScenarios":"Bursty create_instance() calls exceeding the Tenki API's requests-per-second limit, e.g. a fan-out of agents each provisioning a sandbox at the same moment.","commonSituations":"Load tests or batch ingestion jobs that create many sandboxes in a tight loop; shared API keys across multiple RAGFlow deployments hitting the same rate bucket.","solutions":["Retry create_instance() with exponential backoff and jitter (this error is explicitly retryable).","Add client-side throttling (semaphore or token bucket) in front of create_instance().","Cache/reuse a sandbox for multiple execute_code() runs instead of creating one per request."],"exampleFix":"# before\nsandbox = provider.create_instance()\n\n# after\nfor attempt in range(5):\n    try:\n        sandbox = provider.create_instance()\n        break\n    except RuntimeError as exc:\n        if \"rate limited\" not in str(exc) or attempt == 4:\n            raise\n        time.sleep(2 ** attempt + random.random())","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"def create_with_backoff(provider, template, attempts=5):\n    for i in range(attempts):\n        try:\n            return provider.create_instance(template)\n        except RuntimeError as exc:\n            if \"rate limited\" not in str(exc) or i == attempts - 1:\n                raise\n            time.sleep((2 ** i) + random.random())","preventionTips":["Throttle create_instance() fan-out client-side instead of relying on server-side 429s.","Reuse one sandbox for several execute_code() calls within a task.","Retry only the 'rate limited' RuntimeError; quota and auth errors must not be retried."],"tags":["rate-limit","retry","sandbox","tenki"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}