{"record":{"id":"e77b9682c5c001c9","repo":"JuliusBrussee/caveman","slug":"cave-reserved-tool-name","errorCode":"cave_reserved_tool_name","errorMessage":"cave_reserved_tool_name:${declared.name}","messagePattern":"cave_reserved_tool_name:(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent/src/definition-graph.ts","lineNumber":43,"sourceCode":"    // it to run closures outside an ancestor's required containment.\n    if (sandboxRequired && definition.sandbox === \"host\") {\n      throw new Error(\"cave_host_sandbox_nested_under_required\");\n    }\n    const memo = visited[sandboxRequired ? 1 : 0]!;\n    if (memo.has(definition)) return;\n    active.add(definition);\n    const childSandboxRequired = sandboxRequired ||\n      definition.sandbox === \"required\";\n    const names = new Set<string>();\n    for (const declared of definition.tools) {\n      if (!declared || declared.kind !== \"tool\" ||\n          typeof declared.name !== \"string\") {\n        throw new Error(\"cave_tool_definition_invalid\");\n      }\n      if (names.has(declared.name)) throw new Error(\"cave_duplicate_tool_name\");\n      names.add(declared.name);\n      if (declared.name.startsWith(\"cave_\")) {\n        throw new Error(`cave_reserved_tool_name:${declared.name}`);\n      }\n      if (typeof Reflect.get(declared, TOOL_IMPLEMENTATION_SOURCE) !== \"string\") {\n        throw new Error(`cave_untrusted_tool_definition:${declared.name}`);\n      }\n      if (declared.runtime?.kind !== \"subagent\") continue;\n      const child = declared.runtime.definition as AgentDefinition;\n      visit(child, depth + 1, childSandboxRequired);\n    }\n    active.delete(definition);\n    memo.add(definition);\n  };\n\n  visit(root, 0, false);\n}\n\n/**\n * True when any agent in the graph opts into host mode.\n *","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/agent/src/definition-graph.ts#L25-L61","documentation":"Thrown by visit in validateAgentGraph when a declared tool's name starts with the reserved prefix \"cave_\". That namespace is reserved for the library's built-in host tools, so user definitions cannot shadow or impersonate them.","triggerScenarios":"Naming a tool \"cave_search\", \"cave_run\", etc. — any name matching /^cave_/ — in any agent definition passed to validateAgentGraph.","commonSituations":"Users mimicking built-in tool names they saw in traces, a generic naming template like `cave_${fnName}`, or migration from a codebase that used the cave_ prefix before adopting this library.","solutions":["Rename the tool to drop the cave_ prefix (e.g. \"cave_search\" -> \"search\").","Use a distinct namespace for your own tools, e.g. \"app_\" or your org prefix.","Fix any template-string naming code that prepends cave_ to user-provided names."],"exampleFix":"// before\nconst tool = { kind: \"tool\", name: \"cave_search\", /* ... */ };\n// after\nconst tool = { kind: \"tool\", name: \"app_search\", /* ... */ };","handlingStrategy":"validation","validationCode":"const RESERVED = /^cave_/;\ndefinition.tools.forEach(t => { if (RESERVED.test(t.name)) throw new Error(`tool name uses reserved cave_ prefix: ${t.name}`); });","typeGuard":null,"tryCatchPattern":"try {\n  validateAgentGraph(def);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith(\"cave_reserved_tool_name\")) {\n    console.error(`Rename tool (drop the reserved cave_ prefix): ${e.message}`);\n  } else throw e;\n}","preventionTips":["Prefix your own tools with an app/org namespace (app_, acme_) instead of cave_.","Add a lint/check that rejects /^cave_/ in user tool names.","Fix any naming template that prepends cave_ to dynamic names."],"tags":["reserved-namespace","naming-conflict","tool-definition"],"backgroundTag":"invalid-identifier-format","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"}