{"record":{"id":"62501bc2229fc899","repo":"infiniflow/ragflow","slug":"tenki-quota-exceeded-exc","errorCode":null,"errorMessage":"Tenki quota exceeded: {exc}","messagePattern":"Tenki quota exceeded: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/sandbox/providers/tenki.py","lineNumber":147,"sourceCode":"\n        create_kwargs: dict[str, Any] = {\n            \"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'}\")","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/tenki.py#L129-L165","documentation":"Raised when the Tenki SDK's client.create() throws errors.QuotaExceededError during create_instance(). The Tenki account has hit its concurrent-sandbox or total-resource quota, so the microVM cannot be provisioned; the SDK error is rewrapped as RuntimeError per the base provider contract.","triggerScenarios":"Calling create_instance() while the account already runs its maximum number of concurrent sandboxes, or when a monthly/instantaneous create quota is exhausted. The original QuotaExceededError detail is preserved in the message and via __cause__.","commonSituations":"Agent workloads spawning many code-exec sandboxes in parallel, leaked sandboxes from earlier runs that were never destroy_instance()'d consuming the concurrency budget, or a trial/low-tier Tenki plan.","solutions":["Call destroy_instance() for every sandbox when done, and sweep for leaked instances to free concurrency slots.","Reduce parallelism of create_instance() calls (semaphore/queue) to stay under the account's concurrent-sandbox limit.","Inspect the full exception text for the specific quota metric; upgrade the Tenki plan if the limit is account-level."],"exampleFix":"# before\nfor task in tasks:\n    provider.create_instance()  # quota blows up after N concurrent creates\n\n# after\nsem = asyncio.Semaphore(5)  # match account concurrency limit\nfor task in tasks:\n    async with sem:\n        inst = provider.create_instance()\n        try:\n            ...\n        finally:\n            provider.destroy_instance(inst.instance_id)","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    instance = provider.create_instance(template)\nexcept RuntimeError as exc:\n    if \"quota exceeded\" in str(exc):\n        # fall back: reuse an existing idle instance or degrade gracefully\n        instance = reuse_idle_instance() or raise","preventionTips":["Always destroy_instance() in finally blocks so concurrency slots are freed.","Cap concurrent create_instance() calls with a semaphore sized to the account limit.","Monitor quota via the Tenki console and alert before the limit is hit."],"tags":["quota","limits","sandbox","tenki"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}