kosa8 docs Dashboard
esc
↑ ↓ move↵ openRuns in your browser; nothing you type is sent anywhere.

Guides / kosa8 Cloud / GitHub Action

GitHub Action

The kosa8ai/sandbox-action action runs a command in a sealed kosa8 Cloud sandbox from a workflow, prints its output and deletes the sandbox. Use it for untrusted code, an AI agent's changes, or anything you would rather not run on the CI runner itself. It is published at github.com/kosa8ai/sandbox-action; use exactly kosa8ai/sandbox-action@v1, because the kosa8 name on GitHub is not kosa8's.

Add your key as a secret#

Make a kosa8 Cloud API key with the sandboxes:write scope at app.kosa8.com. In the repository, open Settings → Secrets and variables → Actions and add it as KOSA8_API_KEY.

Use the action#

jobs:
  sandbox:
    runs-on: ubuntu-latest
    steps:
      - id: box
        uses: kosa8ai/sandbox-action@v1
        with:
          api-key: ${{ secrets.KOSA8_API_KEY }}
          template: python
          command: python3 -c "import platform; print(platform.platform())"
      - run: echo "exit ${{ steps.box.outputs.exit-code }} in ${{ steps.box.outputs.sandbox-id }}"

Inputs and outputs#

InputDefaultWhat it does
api-keyrequiredA kosa8 Cloud API key (k8c_live_…; a capability token is refused). Masked in the log.
commandrequiredA shell line, run as sh -c in the sandbox. Several lines are fine.
templateorg defaultbase, python, node, or any template your organization has.
timeout600Seconds to wait for the command. The sandbox is also created with a lifetime of timeout + 300 s, so a cancelled job leaves nothing running.
keepfalsetrue keeps the sandbox (no lifetime) for later steps or for looking at afterwards; delete it yourself.
fail-on-errortrueFail the step when the command exits non-zero.
api-urlhttps://api.kosa8.comThe API to call.
OutputIs
exit-codeThe command's exit code.
sandbox-idThe sandbox's id, sbx_….

How it behaves#

  • stdout and stderr are printed, in collapsible groups, when the command finishes. The API returns a command's output at the end today, so a long command shows nothing until it is done.
  • On kosa8 Cloud a single command must finish within 90 seconds, whatever timeout says; a longer one fails with 504 exec_timeout. Split longer work into several steps with keep: true, or start it in the background and poll for a result file.
  • The sandbox is deleted when the step ends, whether the command passed, failed or the step errored. If that delete fails, the step warns, and the sandbox's lifetime removes it.
  • A refusal is explained in the log. For a 402 (no plan, a plan limit, payment_required or spending_cap_reached) the log says what to do and links app.kosa8.com/#usage.
  • It is plain bash with curl and jq, both on GitHub's hosted runners: no Node.js build and nothing downloaded at run time.
  • It uses your plan's Cloud sandbox-hours like any kosa8 Cloud sandbox, while it runs (kosa8 Cloud has what each plan includes).

Keep untrusted text out of command. GitHub pastes ${{ … }} expressions into the line before it runs, so a branch name or PR title put there becomes shell code in the sandbox. Values such as github.repository and github.sha are safe.

A full workflow#

This runs a public repository's tests inside a sandbox on every push. It fits a small test suite: the download, install and test run must finish within the 90-second limit above, so split a bigger one into steps.

name: tests in a kosa8 sandbox
on:
  push:
permissions:
  contents: read
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - id: box
        uses: kosa8ai/sandbox-action@v1
        with:
          api-key: ${{ secrets.KOSA8_API_KEY }}
          template: python
          timeout: "900"
          command: |
            set -e
            cd /workspace
            python3 -c "import io, tarfile, urllib.request; tarfile.open(fileobj=io.BytesIO(urllib.request.urlopen('https://codeload.github.com/${{ github.repository }}/tar.gz/${{ github.sha }}').read())).extractall('src')"
            cd src/*
            python3 -m pip install -q -r requirements.txt pytest
            python3 -m pytest -q

Plain HTTP calls work from any CI system too; the action is the same three calls (POST /v1/sandboxes, POST /v1/sandboxes/{id}/exec, DELETE /v1/sandboxes/{id}) shown in kosa8 Cloud.

Something wrong or missing? Write to contact@kosa8.com.

The kosa8 weekly

Agent security news, one industry deep-dive and a hands-on challenge, every Monday. Unsubscribe in one click.

© 2026 kosa8 · kosa8.com · Zero Trust cybersecurity infrastructure for AI agents · Local models served by llamay · Agent gateway: MAQPNA