JuliusBrussee/caveman · error · Error
caveman agent: Standard Schema cannot emit draft-07 input JS
Error message
caveman agent: Standard Schema cannot emit draft-07 input JSON Schema
What it means
When a tool's input is a Standard Schema (the vendor-neutral interface exposing a '~standard' property), tool() tries to obtain a draft-07 JSON Schema by calling standard.jsonSchema.input({ target: "draft-07" }) — the wire format models require. If the schema library's converter throws during that conversion, the error is wrapped as 'Standard Schema cannot emit draft-07 input JSON Schema' with the original error attached as cause.
Source
Thrown at packages/agent/src/primitives.ts:156
throw new Error(`caveman agent: unknown tool result policy ${JSON.stringify(result)}`);
}
const timeoutMs = options.timeoutMs ?? 30_000;
if (!Number.isSafeInteger(timeoutMs) || timeoutMs <= 0) {
throw new Error("caveman agent: tool timeoutMs must be a positive integer");
}
const standard = standardToolSchema(options.input);
let input: TSchema;
if (standard === undefined) {
input = options.input as TSchema;
} else {
let converted = "inputJSONSchema" in options
? options.inputJSONSchema
: undefined;
if (converted === undefined && standard.jsonSchema !== undefined) {
try {
converted = standard.jsonSchema.input({ target: "draft-07" });
} catch (error) {
throw new Error("caveman agent: Standard Schema cannot emit draft-07 input JSON Schema", {
cause: error,
});
}
}
if (converted === undefined) {
throw new Error(
"caveman agent: Standard Schema needs inputJSONSchema or Standard JSON Schema conversion",
);
}
if (!isRecord(converted)) {
throw new Error("caveman agent: Standard Schema emitted invalid input JSON Schema");
}
input = converted as TSchema;
}
const definition = {
kind: "tool",
name: options.name,
description: options.description,View on GitHub (pinned to 27d5a3981a)
Solutions
- Inspect error.cause to see which schema construct failed to convert
- Remove or replace draft-07-incompatible keywords from the input schema
- Supply the JSON Schema directly via options.inputJSONSchema, bypassing conversion
- Downgrade/switch the schema library to a version whose converter targets draft-07
Example fix
// before
const t = tool({
name: "search",
effect: "read",
input: mySchema, // mySchema uses prefixItems (draft 2020-12 only)
execute: ...,
});
// after
const t = tool({
name: "search",
effect: "read",
input: mySchema,
inputJSONSchema: {
type: "object",
properties: { query: { type: "string" } },
required: ["query"],
},
execute: ...,
}); Defensive patterns
Strategy: try-catch
Validate before calling
let draft07: unknown;
try {
draft07 = schema["~standard"].jsonSchema?.input({ target: "draft-07" });
} catch {
draft07 = undefined;
}
if (draft07 === undefined) {
// supply inputJSONSchema explicitly instead of letting tool() convert
} Try / catch
try {
tool({ name, effect: "read", input: schema, execute });
} catch (e) {
if (e instanceof Error && e.message.includes("draft-07")) {
// inspect e.cause for the failing keyword; strip it or pass inputJSONSchema
}
throw e;
} Prevention
- Avoid draft-2020-only keywords (prefixItems, unevaluated*) in tool input schemas
- Pin schema library versions and test tool construction for every schema you ship
- Prefer letting the factory derive JSON Schema from the validator over hand-writing both
When it happens
Trigger: Using a Standard Schema validator whose jsonSchema converter cannot serialize some construct to draft-07 (e.g. draft-2020-only keywords, exotic formats, or symbols in the schema). The underlying converter error is in error.cause.
Common situations: Newer schema libraries defaulting to draft 2020-12, schemas using keywords with no draft-07 equivalent (e.g. prefixItems, some unevaluated* forms), or version drift between the schema library and this package's expectations.
Related errors
- caveman agent: Standard Schema needs inputJSONSchema or Stan
- caveman agent: Standard Schema emitted invalid input JSON Sc
- caveman agent: tool Standard Schema must implement version 1
- caveman agent: tool Standard JSON Schema converter is invali
- ${path} hooks must be a JSON object; refusing to overwrite i
AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15).
Data as JSON: /api/errors/cd336f15c27c3e8f.
Report an issue: GitHub.