infiniflow/ragflow · error · RuntimeError

Failed to create sandbox instance: {str(e)}

Error message

Failed to create sandbox instance: {str(e)}

What it means

The Aliyun agentrun SDK raised `ServerError` while creating a sandbox instance (template fetch/creation or instance launch). The original server message is embedded. This is an upstream/service-side failure after the provider was correctly initialized.

Source

Thrown at agent/sandbox/providers/aliyun_codeinterpreter.py:194

            )

            instance_id = sandbox.sandbox_id

            return SandboxInstance(
                instance_id=instance_id,
                provider="aliyun_codeinterpreter",
                status="READY",
                metadata={
                    "language": language,
                    "region": self.region,
                    "account_id": self.account_id,
                    "template_name": template_name,
                    "created_at": datetime.now(timezone.utc).isoformat(),
                },
            )

        except ServerError as e:
            raise RuntimeError(f"Failed to create sandbox instance: {str(e)}")
        except Exception as e:
            raise RuntimeError(f"Unexpected error creating instance: {str(e)}")

    def execute_code(self, instance_id: str, code: str, language: str, timeout: int = 10, arguments: Optional[Dict[str, Any]] = None) -> ExecutionResult:
        """
        Execute code in the Aliyun Code Interpreter instance.

        Args:
            instance_id: ID of the sandbox instance
            code: Source code to execute
            language: Programming language (python, javascript)
            timeout: Maximum execution time in seconds (max 30)
            arguments: Optional arguments dict to pass to main() function

        Returns:
            ExecutionResult containing stdout, stderr, exit_code, and metadata

        Raises:

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Read the embedded ServerError text — quota/permission/region errors are usually explicit.
  2. Verify the configured template_name exists in the target region, or clear it so the default `ragflow-<lang>-default` is (re)created.
  3. Check account quotas and IAM permissions for the Code Interpreter service.
  4. Retry after a short backoff for transient 5xx; create_instance is safe to retry since failure leaves no instance.
Defensive patterns

Strategy: retry

Validate before calling

# Fail fast on obviously broken config before touching the API
required = ["region", "account_id", "access_key_id", "access_key_secret"]
missing = [k for k in required if not config.get(k)]
if missing:
    raise ValueError(f"Aliyun sandbox config missing: {missing}")

Try / catch

import time

for attempt in range(3):
    try:
        instance = provider.create_instance("python")
        break
    except RuntimeError as e:
        if "quota" in str(e).lower() or attempt == 2:
            raise
        time.sleep(2 ** attempt)

Prevention

When it happens

Trigger: create_instance when: the `ragflow-<lang>-default` template cannot be listed or created, the account has sandbox quota/limits exceeded, the region endpoint rejects the request, or the Aliyun service returns 5xx.

Common situations: Sandbox quota exhausted on the Aliyun account; wrong region or endpoint in config; template name in config refers to a deleted template; transient Aliyun service outages; IAM permissions missing for the Code Interpreter API.

Related errors


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