infiniflow/ragflow · error · RuntimeError

Tenki quota exceeded: {exc}

Error message

Tenki quota exceeded: {exc}

What it means

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.

Source

Thrown at agent/sandbox/providers/tenki.py:147

        create_kwargs: dict[str, Any] = {
            "allow_outbound": self.allow_outbound,
            "max_duration": self.max_lifetime,
            "metadata": {"source": "ragflow"},
        }
        if self.image:
            create_kwargs["image"] = self.image
        if self.cpu_cores > 0:
            create_kwargs["cpu_cores"] = self.cpu_cores
        if self.memory_mb > 0:
            create_kwargs["memory_mb"] = self.memory_mb
        if self.disk_size_gb > 0:
            create_kwargs["disk_size_gb"] = self.disk_size_gb

        try:
            sandbox = self._client.create(**create_kwargs)
        except errors.QuotaExceededError as exc:
            raise RuntimeError(f"Tenki quota exceeded: {exc}") from exc
        except errors.RateLimitedError as exc:
            raise RuntimeError(f"Tenki rate limited, please retry: {exc}") from exc
        except errors.UnauthorizedError as exc:
            raise SandboxProviderConfigError("Tenki authentication failed: check the API key.") from exc
        except Exception as exc:
            # Satisfy the base contract: any other SDK failure becomes RuntimeError.
            raise RuntimeError(f"Failed to create Tenki sandbox: {exc}") from exc

        remote_work_dir = posixpath.join(SANDBOX_HOME, f"ragflow-codeexec-{uuid.uuid4().hex}")
        try:
            result = sandbox.exec(
                "mkdir",
                "-p",
                posixpath.join(remote_work_dir, "artifacts"),
                timeout=min(self.timeout, 10),
            )
            if result.exit_code != 0:
                raise RuntimeError(f"Failed to create sandbox workspace: {result.stderr_text or 'unknown error'}")

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Call destroy_instance() for every sandbox when done, and sweep for leaked instances to free concurrency slots.
  2. Reduce parallelism of create_instance() calls (semaphore/queue) to stay under the account's concurrent-sandbox limit.
  3. Inspect the full exception text for the specific quota metric; upgrade the Tenki plan if the limit is account-level.

Example fix

# before
for task in tasks:
    provider.create_instance()  # quota blows up after N concurrent creates

# after
sem = asyncio.Semaphore(5)  # match account concurrency limit
for task in tasks:
    async with sem:
        inst = provider.create_instance()
        try:
            ...
        finally:
            provider.destroy_instance(inst.instance_id)
Defensive patterns

Strategy: fallback

Try / catch

try:
    instance = provider.create_instance(template)
except RuntimeError as exc:
    if "quota exceeded" in str(exc):
        # fall back: reuse an existing idle instance or degrade gracefully
        instance = reuse_idle_instance() or raise

Prevention

When it happens

Trigger: 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__.

Common situations: 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.

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/62501bc2229fc899. Report an issue: GitHub.