Sandbox API

Architecture

Component map plus request data flow for Sandbox.Turing.Com — Agent, Harbor, and CodeEdit.

How the platform is put together, and how a request moves through it. Use the component pictures to see what exists; use the flow diagrams to see order and hand-offs.

High-level components

Sandbox HLD components

BandWhat it is
L4Your apps (Prism, CTP, …) — HTTP clients only
EdgeGateway, /docs, OpenAPI
L3Harbor API, Agent API, CodeEdit, shared Harbor worker
ElasticityPub/Sub job queue + KEDA worker scale
L2Catalog, per-tenant/project quota policy + admit, Redis
L1 / L0KeyHive, drivers, gVisor trial pods, GCS

How Agent / Harbor traffic flows

Agent and Harbor are async: you get 202 immediately; work runs on the shared worker fleet.

Step by step:

  1. Gateway authenticates and routes to Harbor or Agent.
  2. API writes a job to Pub/Sub and returns 202 + job_id.
  3. KEDA scales harbor-worker from the queue depth (dev: 2 → 8).
  4. Worker admits a per-project slot, leases a model key, runs the trial pod.
  5. You poll (or SSE) until terminal; artifacts land in GCS.

If the project is at its concurrent cap, the job stays queued (redelivered), it does not fail as a hard error. See capacity notes in Errors and limits.

How CodeEdit differs

CodeEdit is sync: one HTTP call waits for stdout/stderr. It may claim a warm pool pod (~200ms) or create one (~6s). It does not use the Agent/Harbor job queue.

Low-level packages

Sandbox LLD components

ColumnRole
HTTP edgeThin FastAPI services behind the gateway
Librariesharbor_service, agent_service, control_plane
PortsJobQueue, ObjectStore, KeyHive, SandboxDriver
RuntimeWorker Deployment, KEDA, trial pods, ResourceQuota

Import direction is one-way: services → *_service → control_plane → sandbox_core. Agent never imports Harbor’s library.

Sequence (Agent or Harbor job)