JuliusBrussee/caveman · error · Error

caveman agent: Standard Schema needs inputJSONSchema or Stan

Error message

caveman agent: Standard Schema needs inputJSONSchema or Standard JSON Schema conversion

What it means

For a Standard Schema tool input, tool() needs a JSON Schema to send to the model. It first checks options.inputJSONSchema, then tries the standard.jsonSchema converter. If neither route yields a schema (converted is still undefined — the schema object exposes no jsonSchema converter and none was supplied), it throws 'Standard Schema needs inputJSONSchema or Standard JSON Schema conversion'.

Source

Thrown at packages/agent/src/primitives.ts:162

  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,
    input,
    effect: options.effect,
    result,
    ...(typeof options.result === "object" ? { artifact: options.result } : {}),
    ...(options.allowRepeat === undefined ? {} : { allowRepeat: options.allowRepeat }),
    timeoutMs,

View on GitHub (pinned to 27d5a3981a)

Solutions

  1. Add inputJSONSchema alongside input with the draft-07 schema for the model
  2. Upgrade the schema library to a version that ships a Standard JSON Schema converter on ~standard
  3. Or switch input to a TypeBox/native TSchema, which this library consumes directly

Example fix

// before
const t = tool({ name: "echo", effect: "read", input: customStandardSchema, execute: ... }); // no converter

// after
const t = tool({
  name: "echo",
  effect: "read",
  input: customStandardSchema,
  inputJSONSchema: { type: "object", properties: { msg: { type: "string" } } },
  execute: ...,
});
Defensive patterns

Strategy: validation

Validate before calling

const std = input["~standard"];
if (!std || std.jsonSchema?.input === undefined) {
  if (!inputJSONSchema) {
    throw new Error("schema has no JSON Schema converter; provide inputJSONSchema");
  }
}

Type guard

const hasJsonSchemaConverter = (
  v: unknown,
): v is { "~standard": { jsonSchema: { input: unknown } } } => {
  const std = (v as { "~standard"?: { jsonSchema?: { input?: unknown } } })["~standard"];
  return std?.jsonSchema?.input !== undefined;
};

Prevention

When it happens

Trigger: Passing a minimal Standard Schema implementation that has ~standard.validate but no jsonSchema converter property, and not providing inputJSONSchema. Note this is the no-converter case; a converter that throws produces error 175 instead.

Common situations: Hand-rolled schema wrappers, lightweight validators that implement only the validation half of Standard Schema, or an older schema library version released before the JSON Schema converter extension existed.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15). Data as JSON: /api/errors/91018b88eb0cb539. Report an issue: GitHub.