PANGEA / EPHEMERAL SESSIONS

Run one isolated sandbox per conversation.

Any deployed Dockerfile HTTP app (dockerfile-http-v1) can spin up on-demand, kernel-isolated gVisor containers per user session—checking out pre-warmed pods in roughly 0.1s via SandboxWarmPool or cold-starting with per-session env and read-only reference files—and automatically destroy them when idle or expired.

Use Ephemeral Agent Sessions when a web app or service needs a stateful AI worker (for example a CLI agent or document reviewer holding multi-turn context in memory or /tmp) isolated per conversation rather than shared inside one long-lived web replica. Inspect active pools and live sessions read-only from the Ephemeral agent sessions panel in Your apps.

1. Deploy an HTTP agent app (dockerfile-http-v1)

Build a container that serves an HTTP server on $PORT (default 8080). Every ephemeral session launches from your project’s latest verified production image. Keep two routing rules in mind:

2. Configure the session pool

Configure concurrency, per-session compute, lifetimes, and optional warm standby replicas via CLI (requires pangea-cli 0.1.61a19 or later for pangea sessions) or MCP:

pangea sessions pool set -p PROJECT_ID \
  --warm-replicas 1 \
  --max-concurrent 4 \
  --cpu-m 500 \
  --memory-mib 1024 \
  --scratch-mib 512 \
  --idle-ttl 900 \
  --max-ttl 7200

3. Issue a least-privilege session token (pga_ses_...)

Mint a project-scoped token dedicated to session lifecycle operations—give this token to your calling web backend instead of a workspace deploy credential:

pangea sessions token create -p PROJECT_ID --label my-web-app --ttl-days 30

A pga_ses_ token holds only the sessions scope for that single project: it can create, list, inspect, extend (touch), pause, resume, and delete sessions on PROJECT_ID, and cannot deploy code, read encrypted app secrets, modify session pool limits, or access other workspaces. Manage issued tokens anytime with pangea sessions token list or pangea sessions token revoke TOKEN_ID.

4. Launch, talk over sandbox.pangea.host, extend, and clean up

Call the Agent Bridge endpoint https://pangea.host/api/agent/v1/projects/PROJECT_ID/sessions?wait=true with Authorization: Bearer pga_ses_... (or pass an empty JSON body for sub-second WarmPool checkout, or per-session env / files for an isolated cold start in ~5s):

{
  "env": {
    "CUSTOMER_TIER": "pro",
    "TOPIC": "onboarding"
  },
  "files": {
    "context/policy.md": "# Internal FAQ\nAnswer using this policy."
  },
  "idle_ttl_seconds": 900,
  "max_ttl_seconds": 7200
}

When files are provided on creation, Pangea stores them in an ephemeral Kubernetes Secret with ownerReferences tied to the Sandbox and mounts them read-only at /run/pangea-session/files/<rel_path>. When the session becomes ready, use the returned url and signed Ed25519 Scoped-Token v2 headers directly for multi-turn HTTP, Server-Sent Events (SSE), or WebSocket requests:

curl -fsS https://sandbox.pangea.host/chat \
  -H "Authorization: <session.headers.Authorization>" \
  -H "X-Sandbox-ID: <session.headers.X-Sandbox-ID>" \
  -H "X-Sandbox-Namespace: <session.headers.X-Sandbox-Namespace>" \
  -H "X-Sandbox-Port: <session.headers.X-Sandbox-Port>" \
  -H "Content-Type: application/json" \
  -d '{"message":"Summarize policy.md"}'

5. MCP tools & AI agent prompt

Your coding assistant can manage session pools, test sandboxes, and issue app tokens via MCP tools:

Configure Ephemeral Agent Sessions on Pangea project PROJECT_ID via pangea_set_session_pool (warm standby replicas for instant checkout or cold start for per-session context), create a pga_ses_ token with pangea_create_session_token, and integrate POST https://pangea.host/api/agent/v1/projects/PROJECT_ID/sessions?wait=true plus https://sandbox.pangea.host routing (remembering not to expose app routes at /healthz).

Custom Dockerfile & Session-only projects (session_only: true)

If your image only exists to power on-demand sandboxes (for example a coding tool image with git, python3, bun, claude, or codex) and does not serve a public website, create the project with session_only: true (or pangea create --dockerfile-http-v1 --session-only). Session-only projects skip public Ingress and web serving while keeping builds, secrets, and ephemeral pools intact:

Built-in Exec API (exec_mode: "builtin")

Enable exec_mode: "builtin" on session-pool (via pangea sessions pool set --exec-mode builtin or PUT /v1/projects/PROJECT_ID/session-pool) to run commands inside any active sandbox over https://sandbox.pangea.host with your session’s scoped headers:

Outbound Credential-Injecting Proxy (egress_proxies)

Keep raw API keys such as ANTHROPIC_API_KEY or OPENAI_API_KEY outside the sandbox container. Instead of setting inherit_secrets: true, register up to 8 outbound proxy routes in egress_proxies on session-pool:

{
  "exec_mode": "builtin",
  "egress_proxies": {
    "anthropic": {
      "upstream": "https://api.anthropic.com",
      "secret_key": "ANTHROPIC_API_KEY",
      "header": "x-api-key",
      "env_url": "ANTHROPIC_BASE_URL",
      "env_token": "ANTHROPIC_API_KEY"
    }
  }
}

Each session container receives only an ephemeral pga_pxy_ proxy token in env_token and the proxy base URL in env_url (for example ANTHROPIC_BASE_URL or OPENAI_BASE_URL). The pangea-egress-proxy authenticates the pga_pxy_ token and injects the real project secret into the configured outbound header solely for requests forwarded to the matching https:// upstream—with a 600s streaming read timeout for long-running LLM responses—so untrusted code inside the sandbox never sees the raw key.

Security boundaries & limits

Configure Shared AI · Overview on Features · Back to the app guide