JuliusBrussee/caveman · error
cave_internal_run_option
cave_internal_run_option
Error message
cave_internal_run_option: Cave Build execution is available through caveman-agent dev/build after lock validation
What it means
`rejectInternalRunOptions` guards the public `run()` surface: caller-supplied RunOptions may not carry framework-internal fields (`buildIdentity`, `efficiencyPlan`, `lockedBuild`, `candidatePlan`, `caveRoute`, `invocationTrace`, `invocationState`). These belong to the package-internal compiler/CLI path only; Cave Build execution must go through `caveman-agent dev/build` after lock validation. The throw prevents untrusted callers from injecting build identity, plans, or routing into a public run.
Solutions
- Remove the reserved keys from your options object before calling run() — pass only documented public RunOptions
- If you need locked-build execution, use the `caveman-agent dev/build` CLI path with lock validation instead of injecting plan/identity fields
- Construct options explicitly (whitelist fields) rather than spreading an unknown object
Example fix
// before
await run({ ...sessionOptions, prompt }); // contains caveRoute/invocationState
// after
await run({ prompt, model: sessionOptions.model }); // only public fields Defensive patterns
Strategy: validation
Validate before calling
const RESERVED = ['buildIdentity','efficiencyPlan','lockedBuild','candidatePlan','caveRoute','invocationTrace','invocationState'];
const leaked = RESERVED.filter((k) => k in options);
if (leaked.length) throw new Error(`reserved internal options not allowed: ${leaked.join(',')}`); Type guard
function isPublicRunOptions(o: object): boolean { return !['buildIdentity','efficiencyPlan','lockedBuild','candidatePlan','caveRoute','invocationTrace','invocationState'].some((k) => k in o); } Try / catch
try { await run(options); } catch (e) { if (String((e as Error).message).startsWith('cave_internal_run_option:')) { /* strip reserved keys and retry */ } else throw e; } Prevention
- Never spread unknown/session-internal objects into run() options
- Build options objects with an explicit whitelist of public RunOptions fields
- Sanitize any serialized options blob before replaying it
When it happens
Trigger: Calling `run(options)` (or a public entry point that forwards into it) with any of the seven reserved keys present in the options object — typically by spreading an internal/session object into user options, replaying a serialized options blob that captured internal fields, or forwarding `caveRoute` from a coding session into a fresh public call.
Common situations: Piping session-internal options back into a new run, copying options from a compiled/locked build attempt into public `run()`, or an SDK version change where an option was renamed and an old internal key now leaks into the public object.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- ambiguous escaped path sequence
- auth_token: in is ignored — the inbound token is read only…
- awscreds: AWS_CONTAINER_CREDENTIALS_FULL_URI is not a valid…
- awscreds: refusing plaintext container credentials endpoint…
- awscreds: refusing plaintext IMDS endpoint at host
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/f4087f18146a29aa.
Report an issue: GitHub.
Appendix: source
Thrown at packages/agent/src/runtime.ts:5003
}
}
return false;
}
/**
* Refuse caller-supplied build identity, plan, or routing.
*
* Exported for the other public entry points that forward caller options into
* `runAgentInternal` (`./code`): the guard belongs to whoever accepts the
* untrusted object, and it must run BEFORE any session-internal field is merged
* in, or the session's own plan and route would trip it.
*/
export function rejectInternalRunOptions(options: RunOptions): void {
const value = options as Record<string, unknown>;
if ("buildIdentity" in value || "efficiencyPlan" in value ||
"lockedBuild" in value || "candidatePlan" in value || "caveRoute" in value ||
"invocationTrace" in value || "invocationState" in value) {
throw new Error(
"cave_internal_run_option: Cave Build execution is available through caveman-agent dev/build after lock validation",
);
}
}
function sandboxDependencyReadRoots(): string[] {
const resolved = [
import.meta.resolve("@earendil-works/pi-agent-core"),
import.meta.resolve("@earendil-works/pi-ai"),
].map((url) => fileURLToPath(url));
const roots = new Set<string>();
for (const path of resolved) {
const pnpm = path.indexOf("/node_modules/.pnpm/");
if (pnpm >= 0) {
roots.add(path.slice(0, pnpm + "/node_modules/.pnpm".length));
} else {
roots.add(dirname(dirname(path)));
}View on GitHub (pinned to 3ee70a1026)