{"record":{"id":"ed1cd4fd368db2bf","repo":"JuliusBrussee/caveman","slug":"caveman-agent-unknown-sandbox-mode-json-stringi","errorCode":null,"errorMessage":"caveman agent: unknown sandbox mode ${JSON.stringify(sandbox)}","messagePattern":"caveman agent: unknown sandbox mode (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent/src/index.ts","lineNumber":107,"sourceCode":"  instructions: string | FileSource;\n  model: Auto | string | Model<Api>;\n  reasoning?: AgentDefinition[\"reasoning\"];\n  tools?: ToolDefinition[];\n  contexts?: ContextDefinition[];\n  memory?: MemoryDefinition;\n  output?: OutputDefinition;\n  sandbox?: AgentDefinition[\"sandbox\"];\n}): AgentDefinition {\n  if (!/^[a-z0-9][a-z0-9_-]{0,95}$/.test(options.id)) {\n    throw new Error(`caveman agent: invalid agent id ${JSON.stringify(options.id)}`);\n  }\n  const tools = Object.freeze([...(options.tools ?? [])]);\n  if (new Set(tools.map((item) => item.name)).size !== tools.length) {\n    throw new Error(\"caveman agent: duplicate tool name\");\n  }\n  const sandbox = options.sandbox ?? \"required\";\n  if (!SANDBOX_MODES.includes(sandbox)) {\n    throw new Error(`caveman agent: unknown sandbox mode ${JSON.stringify(sandbox)}`);\n  }\n  const reserved = tools.find((item) => item.name.startsWith(\"cave_\"));\n  if (reserved) {\n    throw new Error(\n      `caveman agent: tool prefix cave_ is reserved by framework (${reserved.name})`,\n    );\n  }\n  const definition: AgentDefinition = {\n    kind: \"agent\",\n    id: options.id,\n    instructions: options.instructions,\n    model: options.model,\n    reasoning: options.reasoning ?? \"low\",\n    tools,\n    contexts: Object.freeze([...(options.contexts ?? [])]),\n    sandbox,\n    ...(options.memory === undefined ? {} : { memory: options.memory }),\n    ...(options.output === undefined ? {} : { output: options.output }),","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/agent/src/index.ts#L89-L125","documentation":"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.","triggerScenarios":"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.","commonSituations":"Copying a sandbox value from another framework's config; typos like 'requierd'; upgrading the library where a mode was renamed or removed.","solutions":["Use exactly one of the values in SANDBOX_MODES (check the exported constant)","Omit the sandbox option to accept the default 'required'","Fix casing/typos in the sandbox string","Consult the current version's docs — the mode may have been renamed"],"exampleFix":"// before\nagent({ id: \"bot\", sandbox: \"docker\" });\n// after\nagent({ id: \"bot\", sandbox: \"required\" }); // one of SANDBOX_MODES, or omit entirely","handlingStrategy":"validation","validationCode":"import { SANDBOX_MODES } from \"...\";\nif (!SANDBOX_MODES.includes(sandbox)) throw new Error(`unknown sandbox mode: ${sandbox}`);","typeGuard":"const isSandboxMode = (m) => SANDBOX_MODES.includes(m);","tryCatchPattern":"try { def = agent({ sandbox, ... }); } catch (err) { if (String(err.message).startsWith(\"caveman agent: unknown sandbox mode\")) { def = agent({ sandbox: \"required\", ... }); } else throw err; }","preventionTips":["Reference the exported SANDBOX_MODES constant instead of string literals","Type the sandbox field as the exported union type","Re-check sandbox values after library upgrades"],"tags":["validation","agent-definition","sandbox"],"backgroundTag":"invalid-enum-value","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}