JuliusBrussee/caveman · error · Error
caveman agent: Standard Schema emitted invalid input JSON Sc
Error message
caveman agent: Standard Schema emitted invalid input JSON Schema
What it means
After obtaining a converted or supplied JSON Schema for a Standard Schema tool input, tool() sanity-checks that it is a plain object (isRecord). If the converter or inputJSONSchema returned an array, string, null, or a primitive, the value cannot be a JSON Schema and the factory throws 'Standard Schema emitted invalid input JSON Schema'.
Source
Thrown at packages/agent/src/primitives.ts:167
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,
input,
effect: options.effect,
result,
...(typeof options.result === "object" ? { artifact: options.result } : {}),
...(options.allowRepeat === undefined ? {} : { allowRepeat: options.allowRepeat }),
timeoutMs,
...(options.runtime === undefined ? {} : { runtime: options.runtime }),
async execute(value: unknown, signal?: AbortSignal) {
if (standard === undefined) {
return options.execute(value as never, signal);
}View on GitHub (pinned to 27d5a3981a)
Solutions
- Unwrap envelope returns: inputJSONSchema: envelope.schema rather than envelope
- Check with Array.isArray(x) || typeof x !== "object" || x === null before passing
- Upgrade the schema library if a new version returns the bare object directly
Example fix
// before
inputJSONSchema: converter.output // { draft: "07", schema: {...} }
// after
inputJSONSchema: converter.output.schema // the bare object Defensive patterns
Strategy: type-guard
Validate before calling
const isRecord = (v: unknown): v is Record<string, unknown> =>
typeof v === "object" && v !== null && !Array.isArray(v);
if (!isRecord(converted)) {
throw new Error("JSON Schema converter must return a plain schema object");
} Type guard
const isJsonObject = (v: unknown): v is Record<string, unknown> => typeof v === "object" && v !== null && !Array.isArray(v);
Prevention
- Know your converter's return shape: unwrap envelopes ({ schema }) before passing
- JSON.parse schema files and assert typeof === "object" before use
- Unit-test the tool factory against every schema pipeline you support
When it happens
Trigger: A schema library whose jsonSchema.input() returns a { $schema, schema } envelope instead of the bare schema object, or a caller passing inputJSONSchema: "string" / an array of schemas. Note: converters returning undefined take error 176's path instead.
Common situations: Mismatch between what a given validator's converter returns (some return { draft, schema } wrappers) and what this package expects (the schema object itself), or hand-written inputJSONSchema values built by JSON.parse of something that was not an object.
Related errors
- caveman agent: Standard Schema needs inputJSONSchema or Stan
- caveman agent: file path is required
- caveman agent: invalid tool name ${JSON.stringify(options.na
- caveman agent: unknown tool effect ${JSON.stringify(options.
- caveman agent: unknown tool result policy ${JSON.stringify(r
AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15).
Data as JSON: /api/errors/da34033abdc67d10.
Report an issue: GitHub.