SandboxAgentProfiles

Define agents with AgentProfiles

An AgentProfile says what an agent is: its instructions, model, skills, tools, MCP servers and connections. The backend says which coding agent runs it and how the model is paid for. Keep the profile in a file in your repository, and every agent you start from it behaves the same way on Claude Code, Codex, OpenCode or Pi.

A profile in one file

Save this as agents/reviewer.json:

{
  "name": "reviewer",
  "description": "Reviews a change for bugs and missing tests.",
  "prompt": {
    "appendSystemPrompt": "You review code. Report bugs with file:line and a failing test for each. Do not edit files.",
    "instructions": ["Run the test suite before you report.", "Keep the report under 300 words."]
  },
  "resources": {
    "skills": [
      {
        "kind": "inline",
        "name": "review-checklist",
        "content": "# Review checklist\n\n- Tests pass\n- No new warnings\n- Docs updated"
      }
    ]
  }
}
FieldPurpose
prompt.appendSystemPromptText added to the coding agent’s own system prompt. Use it for a role.
prompt.systemPromptReplaces the system prompt.
prompt.instructionsLines added to the agent’s project instructions.
harnessThe coding agent the profile expects, such as "claude-code".
modelModel hints such as default and provider.
permissions, toolsAllow, ask or deny per tool; turn native tools on or off.
mcpMCP servers: a local command or a remote url.
connectionsHub connections the agent may use, each { connectionId, capabilities }. See Connections.
resources.skillsSkills to install, inline or from GitHub.
resources.files, resources.knowledgeFiles and knowledge to place in the sandbox.
subagents, hooksSubagents and lifecycle hooks for coding agents that support them.

A skill is either inline, { "kind": "inline", "name", "content" }, or from GitHub, { "kind": "github", "repository", "path", "ref" }.

Start an agent from the profile

import { readFileSync } from "node:fs";
import { Sandbox } from "@tangle-network/sandbox";
 
const client = new Sandbox({
  apiKey: process.env.TANGLE_API_KEY!,
  baseUrl: "https://sandbox.tangle.tools",
});
 
const reviewer = JSON.parse(readFileSync("agents/reviewer.json", "utf8"));
 
const box = await client.create({
  backend: { type: "claude-code", profile: reviewer },
  git: { url: "https://github.com/tangle-network/sandbox-demo" },
});
try {
  const review = await box.prompt("Review the last commit.", { sessionId: "review" });
  console.log(review.response);
} finally {
  await box.delete();
}

Swap the backend and keep the profile: the same reviewer.json runs on Codex with your ChatGPT plan, on a coding plan through OpenCode, or on the Tangle Router with no credential.

Profiles from the CLI

tangle sandbox create --profile <value> reads a file when the value starts with . or / or ends in .json. Any other value is a profile name from the platform catalog: built-in profiles plus the ones you stored.

tangle sandbox create --backend claude-code --profile ./agents/reviewer.json
tangle sandbox create --backend claude-code --profile <catalog-name>
cat agents/reviewer.json | tangle sandbox create --backend claude-code --profile-stdin

tangle agent prompt --profile <source> applies a profile to one turn. It takes a local JSON file, an https:// URL, or github:<owner>/<repo>/<path>[@<ref>], so a team can share one profile from a repository:

tangle agent prompt <sandbox-id> "Review the last commit." \
  --profile github:<owner>/<repo>/agents/reviewer.json@main

--skills, --tools and --system-prompt on the same command add to or override the profile for that turn.

Create and check a profile

tangle agent profile create agents/reviewer.json

On a terminal, create asks for each field. With --name it skips the questions and uses the flags: --description, --model, --system-prompt, --skills, --tools and --harness. It writes the profile and prints the command that runs it.

tangle agent profile show agents/reviewer.json      # prints the profile as JSON
tangle agent profile validate agents/reviewer.json  # prints Profile valid: "reviewer"

validate exits with code 65 when the profile is invalid, so it can gate a CI job.

Several profiles in one sandbox

A sandbox can host several agents, each with its own profile, in one checkout. Import @tangle-network/sandbox/agent to add box.agents:

import { Sandbox } from "@tangle-network/sandbox/agent";
 
const reviewerAgent = await box.agents.start({
  id: "reviewer-v1",
  backend: { type: "claude-code", profile: reviewer },
});

Several agents in one sandbox covers shared and isolated workspaces.

Which profile produced this sandbox

The SDK handle that applied a profile records what it applied. box.getProfileProvenance() returns the base profile’s name and SHA-256, the effective one, and when it was materialized. When the profile changes during a session, the base stays and the effective changes.

const provenance = box.getProfileProvenance();
// { base: { name, sha256 }, effective: { name, sha256 }, materializedAt }

The results of box.revertToSnapshot() and box.restorePaths() carry the same record. It is a record kept by your SDK process, not a signed attestation. To save the sandbox’s files, take a snapshot:

tangle snapshot create <sandbox-id> --tags reviewer-v1

Next