SandboxRun agents with agent-runtime

Supervise agents with agent-runtime

@tangle-network/agent-runtime runs an AgentProfile as an exact execution: the coding agent, provider and model you declare are the ones that run, and spend is recorded as measured, never guessed. Its supervise() runs a supervisor agent that spawns workers, each in its own sandbox, under one budget they all draw from.

Use it when one agent should split a task across workers and you want a hard budget over the whole tree. For a fixed set of agents with their own tasks, use fleets. For a fixed topology written as data, use agent graphs.

Supervise from the CLI

tangle supervise "Add input validation to every API route and cover it with tests" \
  --harness codex --max-tokens 200000 --max-iterations 50 --max-workers 4
FlagDefaultEffect
--harnessclaude-codeThe coding agent each worker runs: Claude Code (claude-code), OpenCode (opencode), Codex (codex), Kimi Code (kimi-code) or prime.
--modelA fast Router modelThe supervisor’s model, and the only model workers may use. Pass a canonical id with its provider, such as google/<model-id>.
--max-tokens200000Token budget for the whole run.
--max-iterations50Iteration budget for the whole run.
--max-workersnoneEach worker reserves max-tokens / n tokens and max-iterations / n iterations, so at most n run at once.
--jsonoffPrints the task, result, worker sandboxes, token usage and cost. Exits 1 without a winner.

The supervisor runs on the Tangle Router with your key; each worker is a sandbox running the chosen coding agent. The command prints the result, input and output tokens, and cost, or “Unavailable” where a provider did not report them.

Supervise from TypeScript

npm install @tangle-network/agent-runtime @tangle-network/agent-interface @tangle-network/sandbox

agent-runtime needs Node.js 22.19 or later.

import { randomUUID } from "node:crypto";
import * as kernel from "@tangle-network/agent-runtime/kernel";
import type { MakeWorkerAgent, SupervisorProfile } from "@tangle-network/agent-runtime/kernel";
import { Sandbox } from "@tangle-network/sandbox";
 
const apiKey = process.env.TANGLE_API_KEY!;
const client = new Sandbox({ apiKey, baseUrl: "https://sandbox.tangle.tools" });
 
const workerSeam = kernel.workerFromBackend({
  backend: "sandbox",
  sandboxClient: client,
  maxIterations: 1,
});
const makeWorkerAgent: MakeWorkerAgent = (profile, context) =>
  workerSeam({ ...profile, harness: "claude-code" }, context);
 
const supervisor: SupervisorProfile = {
  name: "supervisor",
  harness: "cli-base",
  model: { default: "gemini-3.5-flash-lite", provider: "google" },
  tools: {
    agent_runtime_coordination_spawn_worker: true,
    agent_runtime_coordination_observe_agent: true,
  },
};
 
const result = await kernel.supervise(
  supervisor,
  { goal: "Add input validation to every API route and cover it with tests" },
  {
    budget: { maxTokens: 200_000, maxIterations: 50 },
    perWorker: { maxTokens: 50_000, maxIterations: 12 },
    makeWorkerAgent,
    router: { routerBaseUrl: "https://router.tangle.tools/v1", routerKey: apiKey },
    runId: `supervise-${randomUUID()}`,
  },
);
 
if (result.kind === "winner") console.log(result.out);
else console.log("no winner:", result.reason);
console.log(result.spentTotal);

harness: "cli-base" makes the supervisor a model that calls tools, not a coding agent process. The two coordination tools let it spawn workers and watch them. Each worker is a fresh sandbox from sandboxClient.create().

result.kind is "winner", with the delivered output in out, or "no-winner", with a reason. spentTotal holds usd, tokens and iterations for the whole tree; usdKnown: false or tokensKnown: false means a provider did not report that number, and it is not zero.

The model list for the supervisor is GET /v1/router-models with your Sandbox key, or the model list.

Other entry points

FunctionUse it for
runAgentTaskStreamOne agent turn and a normalized event stream.
runToolLoopA model calling tools until it answers or stops.
runAgentRoundsYour own plan and decide loop over agent turns.
superviseA supervisor driving workers under one budget.
runGraphA fixed topology expressed as data. See agent graphs.
startRetainedRunWork that must outlive the process that started it.

Every function takes an AgentProfile, so the same profile runs on a Tangle sandbox, in a local process or on another sandbox cloud through providerAsSandboxClient. See Run on E2B, Daytona and more.

Next