{"record":{"id":"cccc33f2799a814a","repo":"JuliusBrussee/caveman","slug":"caveman-agent-tool-standard-schema-must-implement","errorCode":null,"errorMessage":"caveman agent: tool Standard Schema must implement version 1 validation","messagePattern":"caveman agent: tool Standard Schema must implement version 1 validation","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent/src/primitives.ts","lineNumber":215,"sourceCode":"      value: Function.prototype.toString.call(options.execute),\n      enumerable: false,\n      configurable: false,\n      writable: false,\n    },\n  );\n  return Object.freeze(definition);\n}\n\nfunction standardToolSchema(\n  value: unknown,\n): StandardSchemaV1.Props<unknown, unknown> & {\n  jsonSchema?: StandardJSONSchemaV1.Converter;\n} | undefined {\n  if (!isRecord(value) || !isRecord(value[\"~standard\"])) return undefined;\n  const standard = value[\"~standard\"];\n  if (standard.version !== 1 || typeof standard.vendor !== \"string\" ||\n      typeof standard.validate !== \"function\") {\n    throw new Error(\n      \"caveman agent: tool Standard Schema must implement version 1 validation\",\n    );\n  }\n  if (standard.jsonSchema !== undefined &&\n      (!isRecord(standard.jsonSchema) || typeof standard.jsonSchema.input !== \"function\")) {\n    throw new Error(\"caveman agent: tool Standard JSON Schema converter is invalid\");\n  }\n  return standard as unknown as StandardSchemaV1.Props<unknown, unknown> & {\n    jsonSchema?: StandardJSONSchemaV1.Converter;\n  };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n  return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction artifactResultPolicy(definition: ArtifactDefinition): ToolResultPolicy {\n  if (definition.strategy === \"verbatim\") {","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/agent/src/primitives.ts#L197-L233","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","If building the props manually, set `~standard: { version: 1, vendor: '<your vendor>', validate: (value) => {...} }` with validate as a function.","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`.","Check the schema library version for Standard Schema v1 support and upgrade it."],"exampleFix":"// before\nconst tool = { inputSchema: { \"~standard\": { version: \"1.0\", vendor: 42 } } };\n// after\nimport { z } from \"zod\";\nconst tool = { inputSchema: z.object({ query: z.string() }) };","handlingStrategy":"type-guard","validationCode":"function isValidStandardProps(s: unknown): boolean {\n  if (typeof s !== \"object\" || s === null) return false;\n  const std = (s as any)[\"~standard\"];\n  return !!std && std.version === 1 && typeof std.vendor === \"string\" && typeof std.validate === \"function\";\n}\nif (!isValidStandardProps(inputSchema)) throw new Error(\"schema must implement Standard Schema v1\");","typeGuard":"const isStandardSchemaV1 = (v: unknown): v is { \"~standard\": { version: 1; vendor: string; validate: (value: unknown) => { issues: readonly unknown[] | undefined } } } =>\n  typeof v === \"object\" && v !== null &&\n  typeof (v as any)[\"~standard\"] === \"object\" && (v as any)[\"~standard\"]?.version === 1 &&\n  typeof (v as any)[\"~standard\"]?.vendor === \"string\" &&\n  typeof (v as any)[\"~standard\"]?.validate === \"function\";","tryCatchPattern":"try {\n  registerTool({ inputSchema });\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"Standard Schema must implement version 1\")) {\n    console.error(\"inputSchema is not a Standard Schema v1 object; pass a Zod/Valibot/ArkType schema\", e);\n  } else throw e;\n}","preventionTips":["Always pass native schema-library objects (Zod/Valibot/ArkType) as tool inputSchema instead of hand-built `~standard` objects.","Pin schema library versions known to implement Standard Schema v1 (Zod >= 3.24).","Add a unit test that registers every tool definition at startup so bad schemas fail fast."],"tags":["standard-schema","validation","tools","typescript"],"backgroundTag":"schema-validation-failed","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}