JuliusBrussee/caveman · error

caveman agent: unknown sandbox mode

Error message

caveman agent: unknown sandbox mode ${JSON.stringify(sandbox)}

What it means

Thrown by the agent() definition builder when the sandbox option is not one of the recognized sandbox modes. The value is echoed via JSON.stringify so an empty string, undefined-adjacent, or misspelled mode is visible in the message.

Solutions

  1. Use exactly one of the values in SANDBOX_MODES (check the exported constant)
  2. Omit the sandbox option to accept the default 'required'
  3. Fix casing/typos in the sandbox string
  4. Consult the current version's docs — the mode may have been renamed

Example fix

// before
agent({ id: "bot", sandbox: "docker" });
// after
agent({ id: "bot", sandbox: "required" }); // one of SANDBOX_MODES, or omit entirely
Defensive patterns

Strategy: validation

Validate before calling

import { SANDBOX_MODES } from "...";
if (!SANDBOX_MODES.includes(sandbox)) throw new Error(`unknown sandbox mode: ${sandbox}`);

Type guard

const isSandboxMode = (m) => SANDBOX_MODES.includes(m);

Try / catch

try { def = agent({ sandbox, ... }); } catch (err) { if (String(err.message).startsWith("caveman agent: unknown sandbox mode")) { def = agent({ sandbox: "required", ... }); } else throw err; }

Prevention

When it happens

Trigger: agent({ sandbox: 'docker' }) or any string not in SANDBOX_MODES; passing a mode spelled differently from the enum (e.g. 'none' vs 'off'); passing null explicitly instead of omitting it.

Common situations: Copying a sandbox value from another framework's config; typos like 'requierd'; upgrading the library where a mode was renamed or removed.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/ed1cd4fd368db2bf. Report an issue: GitHub.

Appendix: source

Thrown at packages/agent/src/index.ts:107

  instructions: string | FileSource;
  model: Auto | string | Model<Api>;
  reasoning?: AgentDefinition["reasoning"];
  tools?: ToolDefinition[];
  contexts?: ContextDefinition[];
  memory?: MemoryDefinition;
  output?: OutputDefinition;
  sandbox?: AgentDefinition["sandbox"];
}): AgentDefinition {
  if (!/^[a-z0-9][a-z0-9_-]{0,95}$/.test(options.id)) {
    throw new Error(`caveman agent: invalid agent id ${JSON.stringify(options.id)}`);
  }
  const tools = Object.freeze([...(options.tools ?? [])]);
  if (new Set(tools.map((item) => item.name)).size !== tools.length) {
    throw new Error("caveman agent: duplicate tool name");
  }
  const sandbox = options.sandbox ?? "required";
  if (!SANDBOX_MODES.includes(sandbox)) {
    throw new Error(`caveman agent: unknown sandbox mode ${JSON.stringify(sandbox)}`);
  }
  const reserved = tools.find((item) => item.name.startsWith("cave_"));
  if (reserved) {
    throw new Error(
      `caveman agent: tool prefix cave_ is reserved by framework (${reserved.name})`,
    );
  }
  const definition: AgentDefinition = {
    kind: "agent",
    id: options.id,
    instructions: options.instructions,
    model: options.model,
    reasoning: options.reasoning ?? "low",
    tools,
    contexts: Object.freeze([...(options.contexts ?? [])]),
    sandbox,
    ...(options.memory === undefined ? {} : { memory: options.memory }),
    ...(options.output === undefined ? {} : { output: options.output }),

View on GitHub (pinned to 3ee70a1026)