Configuration

Configure agent behavior, models, providers, and tools via sandcaster.json.

Two-Layer Configuration

Sandcaster uses a two-layer config model:

  1. sandcaster.json — project defaults, committed to your repo, applied to every run
  2. API request body — per-run overrides, useful for dynamic prompts and one-off model switches

Values in the API request override matching fields from sandcaster.json. Fields not present in the request fall back to the project config.

sandcaster.json Fields

FieldTypeDescription
systemPromptstringBase instructions prepended to every agent run
modelstringDefault model alias or full model ID
maxTurnsintegerMaximum number of conversation turns before the agent stops
timeoutintegerSandbox lifetime in seconds before forced shutdown
outputFormatobjectJSON Schema describing the expected structured output
skillsDirstringPath to the directory containing skill markdown files
allowedToolsstring[]Whitelist of tool names the agent may call
templateSkillsbooleanWhen true, skills are baked into the sandbox template image
agentsobjectNamed sub-agent definitions for multi-agent workflows
providerstringLLM provider: anthropic, openai, google, or openrouter
sandboxProviderstringSandbox backend: e2b, docker, vercel, or cloudflare
thinkingLevelstringExtended thinking budget: none, low, medium, or high
compositeobjectMulti-sandbox orchestration settings

Example Config

{
	"systemPrompt": "You are a senior product analyst. Be concise and cite sources.",
	"model": "sonnet",
	"maxTurns": 40,
	"timeout": 300,
	"provider": "anthropic",
	"sandboxProvider": "e2b",
	"skillsDir": "./skills",
	"allowedTools": ["bash", "read_file", "write_file", "web_search"]
}

Sub-Agents

Define named sub-agents under the agents key. Each sub-agent inherits the root config and can override any field:

{
	"model": "sonnet",
	"agents": {
		"researcher": {
			"systemPrompt": "You are a research specialist. Find primary sources.",
			"model": "opus",
			"maxTurns": 20
		},
		"writer": {
			"systemPrompt": "You are a technical writer. Be clear and structured.",
			"model": "sonnet",
			"maxTurns": 15
		}
	}
}

The orchestrating agent can spawn researcher and writer as independent sub-agents with their own sandboxes and model settings.

Skills

Skills are markdown files that extend what an agent knows how to do. Place them in skillsDir (default ./skills/). Each file follows the SKILL.md format:

# Web Search Skill

Use this skill to search the web for current information.

## When to use
- Researching recent events or data
- Finding documentation or API references

## How to use
Call the `web_search` tool with a clear, specific query.

When templateSkills is true, skills are baked into the E2B sandbox template at build time, which speeds up cold starts.

Structured Output

Set outputFormat to a JSON Schema object to receive structured output instead of free text:

{
	"outputFormat": {
		"type": "object",
		"properties": {
			"summary": { "type": "string" },
			"competitors": {
				"type": "array",
				"items": {
					"type": "object",
					"properties": {
						"name": { "type": "string" },
						"strengths": { "type": "array", "items": { "type": "string" } },
						"weaknesses": { "type": "array", "items": { "type": "string" } }
					}
				}
			},
			"recommendation": { "type": "string" }
		},
		"required": ["summary", "recommendation"]
	}
}

The agent formats its final response to match the schema before the run ends.

LLM Provider Selection

Set provider in sandcaster.json or override per request. Sandcaster reads the corresponding API key from your environment:

ProviderField valueEnvironment variable
AnthropicanthropicANTHROPIC_API_KEY
OpenAIopenaiOPENAI_API_KEY
GooglegoogleGOOGLE_API_KEY
OpenRouteropenrouterOPENROUTER_API_KEY

Model Aliases

AliasResolves to
sonnetclaude-sonnet-4-6
opusclaude-opus-4-6
haikuclaude-haiku-4-5
gpt5gpt-5.4
gpt5minigpt-5-mini
geminigemini-3.1-pro-preview

Sandbox Provider Selection

Set sandboxProvider to choose your execution backend. If not set, Sandcaster auto-detects based on available API keys and environment:

ProviderField valueBest for
E2Be2bCloud-hosted, fast cold starts, managed isolation
DockerdockerSelf-hosted, local development
VercelvercelEdge-native deployments
CloudflarecloudflareCloudflare Workers environment

Auto-detection priority: E2B (if E2B_API_KEY is set) → Docker (if Docker socket is available) → error.

Composite Sandboxes

For multi-agent workflows that need parallel execution across multiple sandboxes, configure composite:

{
	"composite": {
		"maxSandboxes": 5,
		"maxTotalSpawns": 20,
		"allowedProviders": ["e2b", "docker"]
	}
}
FieldTypeDescription
maxSandboxesintegerMaximum number of sandboxes running concurrently
maxTotalSpawnsintegerLifetime cap on total sandboxes spawned per run
allowedProvidersstring[]Restrict which sandbox backends sub-agents may use