{
  "slug": "hf-adds-python-and-cli-sandbox-workflows-on-jobs-02c551521221",
  "title": "hf adds Python and CLI sandbox workflows on Jobs",
  "tools": [
    "hf"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-07-03T09:43:05.000Z",
  "announced_at": "2026-07-03T09:43:05.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "When you need to run repository code in an isolated cloud machine and retrieve its output or files, create a sandbox, run the command, and use the file API or CLI copy command to move files. Use a dedicated `Sandbox.create` VM or a `SandboxPool` for shared CPU sandboxes.",
    "examples": [
      "from huggingface_hub import Sandbox\n\nwith Sandbox.create(image=\"<image>\") as sbx:\n    result = sbx.run(\"<command>\")\n    print(result.stdout)\n    sbx.files.write(\"<sandbox_path>\", \"<file_contents>\")",
      "from huggingface_hub import SandboxPool\n\nwith SandboxPool(image=\"<image>\", flavor=\"cpu-basic\", warm_up=2) as pool:\n    sbx = pool.create()\n    print(sbx.run(\"<command>\").stdout)",
      "hf sandbox create\nhf sandbox exec <sandbox_id> -- <command> [<arg> ...]\nhf sandbox cp <local_path> <sandbox_id>:<sandbox_path>\nhf sandbox cp <sandbox_id>:<sandbox_path> <local_path>\nhf sandbox kill <sandbox_id>"
    ],
    "gotchas": [
      "Version: v1.22.0",
      "Sandbox.create(image): Docker image for the dedicated sandbox; defaults to `python:3.12`.",
      "Sandbox.run(command) (required): Shell string or argv list to execute; waits for completion and returns command output.",
      "SandboxPool(image): Image used by the pool; defaults to `python:3.12`.",
      "SandboxPool(flavor): Host hardware flavor; defaults to `cpu-basic`.",
      "SandboxPool(warm_up): Number of host jobs to pre-provision; defaults to 1.",
      "hf sandbox exec <sandbox_id> -- <command> [args] (required): Sandbox id and command plus its arguments. CLI docs say output is streamed and exit code propagated.",
      "hf sandbox cp <local_path> <sandbox_id>:<sandbox_path> (required): Local source and sandbox destination for copying a file into the sandbox.",
      "hf sandbox cp <sandbox_id>:<sandbox_path> <local_path> (required): Sandbox source and local destination for copying a file out.",
      "hf sandbox kill <sandbox_id> (required): Sandbox id to terminate.",
      "Prerequisite: Install `huggingface_hub` version 1.22.0 or later to use the Sandbox API and `hf sandbox` CLI.",
      "Prerequisite: The sandbox image must provide `/bin/sh`.",
      "Prerequisite: Hub authentication is needed to create and manage sandboxes; the docs describe using the same HF token for later reconnection.",
      "Sandboxes are built on Jobs; any Docker image with `/bin/sh` works and sandboxes inherit Jobs' billing, hardware flavors, and namespace permissions.",
      "`Sandbox.create` provides a dedicated VM for GPU workloads, untrusted code, and full isolation; `SandboxPool` packs many cheap CPU sandboxes into a few shared host VMs for fan-out workloads."
    ]
  },
  "why_it_matters": "Run repository code in an isolated cloud machine and retrieve its output or files.",
  "sources": [
    "https://github.com/huggingface/huggingface_hub/releases/tag/v1.22.0",
    "https://huggingface.co/docs/huggingface_hub/guides/sandbox",
    "https://huggingface.co/docs/huggingface_hub/package_reference/sandbox",
    "https://github.com/huggingface/hf-sandbox"
  ],
  "rank": 0.99063,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v2+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "wave2b-20261017",
    "verdict_id": "wave2b-20261017:wave2b-20261017-e6ed4cae21a7b793-0:gate",
    "evidence_hash": "f316d5257eea8951f435f08a3f7b5370d03f8637f0d89a9312db66c5df369f55"
  },
  "review": {
    "draft_hash": "ec8db2e1909d280bae35507613e01cd2bf6cf1f8c83e1e2dadc56eea9394b0bd",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T00:00:00.000Z",
    "decision": "wave2b-20261017:gate",
    "reason": "3 of 3 judge runs approved with p_yes >= 0.9 (mean 0.99 >= 0.9; 2 needed) and Jev gave 0.78 (>= 0.6 needed)."
  }
}
