{"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":"validation","errorClass":null,"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/3ee70a102609e550bd2e68004bf5990a9341c851/packages/agent/src/primitives.ts#L144-L180","documentation":"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.","triggerScenarios":"tool({ input: standardSchema }) where the schema's Standard Schema implementation exposes no jsonSchema property and no inputJSONSchema option is given.","commonSituations":"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.","solutions":["Provide inputJSONSchema explicitly (a valid draft-07 JSON Schema object for the tool input)","Upgrade or switch to a schema library whose Standard Schema implementation exposes jsonSchema()","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"],"exampleFix":"// before\ntool({ name: \"search\", input: customStandardSchema, ... }) // no jsonSchema export\n// after\ntool({ name: \"search\", input: customStandardSchema, inputJSONSchema: { type: \"object\", properties: { q: { type: \"string\" } } }, ... })","handlingStrategy":"validation","validationCode":"function hasStandardJsonSchema(schema: unknown): boolean {\n  const s = schema as { [\"~standard\"]?: { jsonSchema?: unknown } } | undefined;\n  return typeof s?.[\"~standard\"]?.jsonSchema === \"object\";\n}\n// require hasStandardJsonSchema(input) || options.inputJSONSchema before calling tool()","typeGuard":"function providesInputSchema(o: { input?: unknown; inputJSONSchema?: unknown }): boolean {\n  if (o.inputJSONSchema !== undefined) return true;\n  const s = o.input as { [\"~standard\"]?: { jsonSchema?: unknown } } | undefined;\n  return typeof s?.[\"~standard\"]?.jsonSchema === \"object\";\n}","tryCatchPattern":"try {\n  const def = tool(options);\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"needs inputJSONSchema\")) {\n    // rebuild with an explicit inputJSONSchema object\n  } else throw err;\n}","preventionTips":["Confirm the schema library implements the Standard Schema jsonSchema namespace, not just validate","Always pair custom Standard Schema wrappers with explicit inputJSONSchema","Pin schema-library versions and check Standard Schema capability notes before upgrading"],"tags":["schema","json-schema","standard-schema","missing-capability"],"backgroundTag":"unsupported-operation","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"}