JuliusBrussee/caveman · error
cave_reserved_tool_name
cave_reserved_tool_name
Error message
cave_reserved_tool_name:${declared.name} What it means
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.
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.
Example fix
// before
const tool = { kind: "tool", name: "cave_search", /* ... */ };
// after
const tool = { kind: "tool", name: "app_search", /* ... */ }; Defensive patterns
Strategy: validation
Validate before calling
const RESERVED = /^cave_/;
definition.tools.forEach(t => { if (RESERVED.test(t.name)) throw new Error(`tool name uses reserved cave_ prefix: ${t.name}`); }); Try / catch
try {
validateAgentGraph(def);
} catch (e) {
if (e instanceof Error && e.message.startsWith("cave_reserved_tool_name")) {
console.error(`Rename tool (drop the reserved cave_ prefix): ${e.message}`);
} else throw e;
} Prevention
- 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.
When it happens
Trigger: Naming a tool "cave_search", "cave_run", etc. — any name matching /^cave_/ — in any agent definition passed to validateAgentGraph.
Common situations: 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.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- cave_duplicate_tool_name
- cave_tool_definition_invalid
- cave_untrusted_tool_definition
- caveman agent: invalid tool name
- caveman agent: Standard Schema cannot emit draft-07 input…
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/e77b9682c5c001c9.
Report an issue: GitHub.
Appendix: source
Thrown at packages/agent/src/definition-graph.ts:43
// it to run closures outside an ancestor's required containment.
if (sandboxRequired && definition.sandbox === "host") {
throw new Error("cave_host_sandbox_nested_under_required");
}
const memo = visited[sandboxRequired ? 1 : 0]!;
if (memo.has(definition)) return;
active.add(definition);
const childSandboxRequired = sandboxRequired ||
definition.sandbox === "required";
const names = new Set<string>();
for (const declared of definition.tools) {
if (!declared || declared.kind !== "tool" ||
typeof declared.name !== "string") {
throw new Error("cave_tool_definition_invalid");
}
if (names.has(declared.name)) throw new Error("cave_duplicate_tool_name");
names.add(declared.name);
if (declared.name.startsWith("cave_")) {
throw new Error(`cave_reserved_tool_name:${declared.name}`);
}
if (typeof Reflect.get(declared, TOOL_IMPLEMENTATION_SOURCE) !== "string") {
throw new Error(`cave_untrusted_tool_definition:${declared.name}`);
}
if (declared.runtime?.kind !== "subagent") continue;
const child = declared.runtime.definition as AgentDefinition;
visit(child, depth + 1, childSandboxRequired);
}
active.delete(definition);
memo.add(definition);
};
visit(root, 0, false);
}
/**
* True when any agent in the graph opts into host mode.
*View on GitHub (pinned to 3ee70a1026)