JuliusBrussee/caveman · error

caveman agent: Standard Schema needs inputJSONSchema or…

Error message

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

What it means

When a Standard Schema input cannot yield a JSON Schema — no explicit inputJSONSchema was provided, standard.jsonSchema is undefined, and conversion produced undefined — tool() throws because it cannot describe the tool's input to the provider. Either a hand-written inputJSONSchema or a Standard Schema jsonSchema conversion is required.

Solutions

  1. Provide inputJSONSchema explicitly (a valid draft-07 JSON Schema object for the tool input)
  2. Upgrade or switch to a schema library whose Standard Schema implementation exposes jsonSchema()
  3. If the input is already a plain JSON Schema object, pass it in a form the library treats as a raw schema rather than Standard Schema

Example fix

// before
tool({ name: "search", input: customStandardSchema, ... }) // no jsonSchema export
// after
tool({ name: "search", input: customStandardSchema, inputJSONSchema: { type: "object", properties: { q: { type: "string" } } }, ... })
Defensive patterns

Strategy: validation

Validate before calling

function hasStandardJsonSchema(schema: unknown): boolean {
  const s = schema as { ["~standard"]?: { jsonSchema?: unknown } } | undefined;
  return typeof s?.["~standard"]?.jsonSchema === "object";
}
// require hasStandardJsonSchema(input) || options.inputJSONSchema before calling tool()

Type guard

function providesInputSchema(o: { input?: unknown; inputJSONSchema?: unknown }): boolean {
  if (o.inputJSONSchema !== undefined) return true;
  const s = o.input as { ["~standard"]?: { jsonSchema?: unknown } } | undefined;
  return typeof s?.["~standard"]?.jsonSchema === "object";
}

Try / catch

try {
  const def = tool(options);
} catch (err) {
  if (err instanceof Error && err.message.includes("needs inputJSONSchema")) {
    // rebuild with an explicit inputJSONSchema object
  } else throw err;
}

Prevention

When it happens

Trigger: tool({ input: standardSchema }) where the schema's Standard Schema implementation exposes no jsonSchema property and no inputJSONSchema option is given.

Common situations: Using a schema library or version that implements Standard Schema validate but not the jsonSchema namespace; custom Standard Schema wrappers that omit jsonSchema; forgetting that raw (non-standard) schemas must be passed differently.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/91018b88eb0cb539. Report an issue: GitHub.

Appendix: 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 3ee70a1026)