infiniflow/ragflow · error · RuntimeError

Tenki execution failed: {exc}

Error message

Tenki execution failed: {exc}

What it means

Catch-all RuntimeError for sandbox.exec() failures that are not timeout or session-loss errors — network drops to the Tenki API mid-exec, SDK protocol errors, or exec-level failures. The original SDK exception is preserved as __cause__.

Source

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

        script_path, argv = self._prepare_script(sandbox, remote_work_dir, normalized_lang, code, args_json)

        requested_timeout = self.timeout if timeout is None else int(timeout)
        if requested_timeout <= 0:
            raise RuntimeError(f"Execution timeout must be greater than 0 seconds, got {requested_timeout}.")
        exec_timeout = min(requested_timeout, self.timeout)

        start_time = time.time()
        try:
            result = sandbox.exec(*argv, cwd=remote_work_dir, timeout=exec_timeout)
        except (errors.CommandTimeoutError, errors.PrimitiveTimeoutError) as exc:
            logger.warning("Tenki execution timed out (instance=%s, timeout=%ss)", instance_id, exec_timeout)
            raise TimeoutError(f"Execution timed out after {exec_timeout} seconds") from exc
        except (errors.SessionTerminatedError, errors.SessionNotFoundError) as exc:
            # The sandbox was reclaimed (e.g. max_lifetime) or lost mid-run;
            # surface it as RuntimeError per the base contract, not an SDK type.
            raise RuntimeError(f"Tenki sandbox is no longer available: {exc}") from exc
        except Exception as exc:
            raise RuntimeError(f"Tenki execution failed: {exc}") from exc
        execution_time = time.time() - start_time

        stdout = result.stdout_text
        stderr = result.stderr_text
        exit_code = int(result.exit_code)

        self._validate_output_size(stdout, stderr)
        stdout, structured_result = extract_structured_result(stdout)

        return ExecutionResult(
            stdout=stdout,
            stderr=stderr,
            exit_code=exit_code,
            execution_time=execution_time,
            metadata={
                "instance_id": instance_id,
                "language": normalized_lang,
                "script_path": script_path,

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Check exc.__cause__ for the SDK's original error text — it distinguishes 'executable not found' from transport failures.
  2. If transport-related, retry execute_code() on the same instance (the session may still be alive).
  3. Verify the image provides python3 (python template) and node (javascript template) executables.

Example fix

# before
result = provider.execute_code(instance_id, code)

# after
try:
    result = provider.execute_code(instance_id, code)
except RuntimeError as exc:
    logger.error("tenki exec failed: %s", exc.__cause__)
    raise
Defensive patterns

Strategy: try-catch

Try / catch

try:
    result = provider.execute_code(instance_id, code)
except RuntimeError as exc:
    if "Tenki execution failed" in str(exc):
        cause = exc.__cause__
        logger.error("exec error, cause=%r", cause)
        if is_transient(cause):  # e.g. transport error
            return provider.execute_code(instance_id, code)
    raise

Prevention

When it happens

Trigger: Transient network interruptions between the provider and Tenki while the script runs, SDK errors while streaming stdout/stderr, or the sandbox runtime failing to spawn the executable (e.g. python3/node missing in a custom image).

Common situations: Custom images without python3 or node on PATH (argv is [executable, script_path]); flaky egress from self-hosted RAGFlow to the Tenki API; SDK version drift between the tenki package and API.

Related errors


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