{"record":{"id":"91018b88eb0cb539","repo":"JuliusBrussee/caveman","slug":"caveman-agent-standard-schema-needs-inputjsonsche","errorCode":null,"errorMessage":"caveman agent: Standard Schema needs inputJSONSchema or Standard JSON Schema conversion","messagePattern":"caveman agent: Standard Schema needs inputJSONSchema or Standard JSON Schema conversion","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/agent/src/primitives.ts","lineNumber":162,"sourceCode":"  const standard = standardToolSchema(options.input);\n  let input: TSchema;\n  if (standard === undefined) {\n    input = options.input as TSchema;\n  } else {\n    let converted = \"inputJSONSchema\" in options\n      ? options.inputJSONSchema\n      : undefined;\n    if (converted === undefined && standard.jsonSchema !== undefined) {\n      try {\n        converted = standard.jsonSchema.input({ target: \"draft-07\" });\n      } catch (error) {\n        throw new Error(\"caveman agent: Standard Schema cannot emit draft-07 input JSON Schema\", {\n          cause: error,\n        });\n      }\n    }\n    if (converted === undefined) {\n      throw new Error(\n        \"caveman agent: Standard Schema needs inputJSONSchema or Standard JSON Schema conversion\",\n      );\n    }\n    if (!isRecord(converted)) {\n      throw new Error(\"caveman agent: Standard Schema emitted invalid input JSON Schema\");\n    }\n    input = converted as TSchema;\n  }\n  const definition = {\n    kind: \"tool\",\n    name: options.name,\n    description: options.description,\n    input,\n    effect: options.effect,\n    result,\n    ...(typeof options.result === \"object\" ? { artifact: options.result } : {}),\n    ...(options.allowRepeat === undefined ? {} : { allowRepeat: options.allowRepeat }),\n    timeoutMs,","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/agent/src/primitives.ts#L144-L180","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add inputJSONSchema alongside input with the draft-07 schema for the model","Upgrade the schema library to a version that ships a Standard JSON Schema converter on ~standard","Or switch input to a TypeBox/native TSchema, which this library consumes directly"],"exampleFix":"// before\nconst t = tool({ name: \"echo\", effect: \"read\", input: customStandardSchema, execute: ... }); // no converter\n\n// after\nconst t = tool({\n  name: \"echo\",\n  effect: \"read\",\n  input: customStandardSchema,\n  inputJSONSchema: { type: \"object\", properties: { msg: { type: \"string\" } } },\n  execute: ...,\n});","handlingStrategy":"validation","validationCode":"const std = input[\"~standard\"];\nif (!std || std.jsonSchema?.input === undefined) {\n  if (!inputJSONSchema) {\n    throw new Error(\"schema has no JSON Schema converter; provide inputJSONSchema\");\n  }\n}","typeGuard":"const hasJsonSchemaConverter = (\n  v: unknown,\n): v is { \"~standard\": { jsonSchema: { input: unknown } } } => {\n  const std = (v as { \"~standard\"?: { jsonSchema?: { input?: unknown } } })[\"~standard\"];\n  return std?.jsonSchema?.input !== undefined;\n};","tryCatchPattern":null,"preventionTips":["Prefer established schema libraries that ship both validation and conversion","Smoke-test every custom schema wrapper by constructing the tool at import time","Keep an inputJSONSchema fallback ready for validators without converters"],"tags":["json-schema","standard-schema","api-misuse","schema-conversion"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}