JuliusBrussee/caveman · error
caveman agent: tool Standard JSON Schema converter is…
Error message
caveman agent: tool Standard JSON Schema converter is invalid
What it means
After confirming the `~standard` props themselves are valid, standardToolSchema checks the optional `jsonSchema` converter. If `~standard.jsonSchema` is present it must be a record with a callable `input` method (the Standard JSON Schema v1 converter shape). This error means the object advertises a JSON Schema converter but its shape is wrong, so the library cannot convert the schema to JSON Schema.
Solutions
- Ensure `~standard.jsonSchema` is an object with a callable `input` method: `jsonSchema: { input: (schema) => jsonSchemaObject, target: 'draft-2020-12' }`.
- Prefer passing a native schema (Zod/Valibot/ArkType) whose `~standard.jsonSchema` is provided by the library instead of constructing it yourself.
- If you don't need JSON Schema conversion, omit `~standard.jsonSchema` entirely (it is optional).
- Upgrade the schema library to a version implementing Standard JSON Schema v1 correctly.
Example fix
// before
schema["~standard"].jsonSchema = { input: "not-a-function" };
// after
schema["~standard"].jsonSchema = {
input: (s) => toJsonSchema(s),
target: "draft-2020-12",
}; Defensive patterns
Strategy: type-guard
Validate before calling
function hasValidJsonSchemaConverter(std: any): boolean {
const c = std?.jsonSchema;
return c === undefined || (typeof c === "object" && c !== null && typeof c.input === "function");
}
if (!hasValidJsonSchemaConverter(inputSchema?.["~standard"])) throw new Error("invalid jsonSchema converter"); Type guard
const hasJsonSchemaConverter = (v: unknown): v is { "~standard": { jsonSchema: { input: (schema: unknown, options?: unknown) => unknown } } } =>
typeof v === "object" && v !== null &&
typeof (v as any)["~standard"]?.jsonSchema === "object" && (v as any)["~standard"]?.jsonSchema !== null &&
typeof (v as any)["~standard"].jsonSchema.input === "function"; Try / catch
try {
registerTool({ inputSchema });
} catch (e) {
if (e instanceof Error && e.message.includes("Standard JSON Schema converter is invalid")) {
console.error("~standard.jsonSchema must be an object with a callable input() — omit it or use a compliant schema library", e);
} else throw e;
} Prevention
- Omit `~standard.jsonSchema` unless you actually implement the Standard JSON Schema v1 converter contract.
- Let the schema library supply the converter rather than hand-rolling `{ input: ... }`.
- Type the tool schema as `StandardSchemaV1.Props` from the standard-schema package so mismatches are caught at compile time.
When it happens
Trigger: Passing a tool whose inputSchema has `~standard` valid for validate/version/vendor, but `~standard.jsonSchema` is: not a record (e.g. a function or string), or an object whose `input` is not a function (e.g. `jsonSchema: { input: '...' }` or missing `input`).
Common situations: Hand-rolling the `jsonSchema` converter stub; using an older Standard JSON Schema draft where the converter API differed; a wrapper library exposing `jsonSchema` as a getter that resolved to a non-object; typos like `inputs` instead of `input`.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- caveman agent: tool Standard Schema must implement version…
- caveman agent: Standard Schema cannot emit draft-07 input…
- caveman agent: Standard Schema needs inputJSONSchema or…
- adapter conformance schema failed to compile
- artifactId is required
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/4d24fdfbfe373f73.
Report an issue: GitHub.
Appendix: source
Thrown at packages/agent/src/primitives.ts:221
return Object.freeze(definition);
}
function standardToolSchema(
value: unknown,
): StandardSchemaV1.Props<unknown, unknown> & {
jsonSchema?: StandardJSONSchemaV1.Converter;
} | undefined {
if (!isRecord(value) || !isRecord(value["~standard"])) return undefined;
const standard = value["~standard"];
if (standard.version !== 1 || typeof standard.vendor !== "string" ||
typeof standard.validate !== "function") {
throw new Error(
"caveman agent: tool Standard Schema must implement version 1 validation",
);
}
if (standard.jsonSchema !== undefined &&
(!isRecord(standard.jsonSchema) || typeof standard.jsonSchema.input !== "function")) {
throw new Error("caveman agent: tool Standard JSON Schema converter is invalid");
}
return standard as unknown as StandardSchemaV1.Props<unknown, unknown> & {
jsonSchema?: StandardJSONSchemaV1.Converter;
};
}
function isRecord(value: unknown): value is Record<string, unknown> {
return value !== null && typeof value === "object" && !Array.isArray(value);
}
function artifactResultPolicy(definition: ArtifactDefinition): ToolResultPolicy {
if (definition.strategy === "verbatim") {
return definition.recovery === "exact_ccr" ? "exact_ccr" : "inline";
}
if (definition.strategy === "json-index") return "compress";
return "page";
}
View on GitHub (pinned to 3ee70a1026)