JuliusBrussee/caveman · error

caveman agent: tool Standard Schema must implement version…

Error message

caveman agent: tool Standard Schema must implement version 1 validation

What it means

standardToolSchema validates that a tool's input schema object implements the Standard Schema spec (`~standard` property). The library requires `~standard.version === 1`, a string `vendor`, and a callable `validate` function. This error is thrown when the object has a `~standard` property but that property is missing one of these required members, so the tool's schema cannot be validated at runtime.

Solutions

  1. Pass a real schema object from a Standard Schema v1 compliant library (Zod >= 3.24, Valibot, ArkType) as the tool's inputSchema instead of a hand-made `~standard` object.
  2. If building the props manually, set `~standard: { version: 1, vendor: '<your vendor>', validate: (value) => {...} }` with validate as a function.
  3. If you have a plain JSON Schema, wrap it with a converter (e.g. `zod-to-json-schema` inverse or the library's jsonSchema input) or use `jsonSchema` input support rather than faking `~standard`.
  4. Check the schema library version for Standard Schema v1 support and upgrade it.

Example fix

// before
const tool = { inputSchema: { "~standard": { version: "1.0", vendor: 42 } } };
// after
import { z } from "zod";
const tool = { inputSchema: z.object({ query: z.string() }) };
Defensive patterns

Strategy: type-guard

Validate before calling

function isValidStandardProps(s: unknown): boolean {
  if (typeof s !== "object" || s === null) return false;
  const std = (s as any)["~standard"];
  return !!std && std.version === 1 && typeof std.vendor === "string" && typeof std.validate === "function";
}
if (!isValidStandardProps(inputSchema)) throw new Error("schema must implement Standard Schema v1");

Type guard

const isStandardSchemaV1 = (v: unknown): v is { "~standard": { version: 1; vendor: string; validate: (value: unknown) => { issues: readonly unknown[] | undefined } } } =>
  typeof v === "object" && v !== null &&
  typeof (v as any)["~standard"] === "object" && (v as any)["~standard"]?.version === 1 &&
  typeof (v as any)["~standard"]?.vendor === "string" &&
  typeof (v as any)["~standard"]?.validate === "function";

Try / catch

try {
  registerTool({ inputSchema });
} catch (e) {
  if (e instanceof Error && e.message.includes("Standard Schema must implement version 1")) {
    console.error("inputSchema is not a Standard Schema v1 object; pass a Zod/Valibot/ArkType schema", e);
  } else throw e;
}

Prevention

When it happens

Trigger: Passing a tool whose `inputSchema` is an object exposing `~standard` but with: `version !== 1`, a non-string `vendor`, or a `validate` that is not a function — e.g. a hand-rolled `{ "~standard": { version: "1.0" } }` or an object that merely mimics the spec.

Common situations: Hand-constructing Standard Schema props instead of using a schema library (Zod/Valibot/ArkType); copying an old pre-v1 Standard Schema draft object; passing a plain JSON Schema (which has no `~standard` at all is fine, but a partially-migrated shim is not); a schema library exporting an incompatible/experimental `~standard` implementation.

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


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

Appendix: source

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

      value: Function.prototype.toString.call(options.execute),
      enumerable: false,
      configurable: false,
      writable: false,
    },
  );
  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") {

View on GitHub (pinned to 3ee70a1026)