{"record":{"id":"4a7cb3f355d0be92","repo":"coleam00/Archon","slug":"native-tool-inputschema-must-be-an-object-schema-w","errorCode":null,"errorMessage":"native tool inputSchema must be an object schema with `properties`","messagePattern":"native tool inputSchema must be an object schema with `properties`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/providers/src/community/pi/native-tools.ts","lineNumber":21,"sourceCode":"import type { NativeTool } from '../../types';\n\nfunction isString(v: unknown): v is string {\n  return typeof v === 'string';\n}\n\n/**\n * Convert a NativeTool's canonical JSON Schema into the TypeBox schema Pi's\n * `defineTool` expects. Same narrow subset as the Claude converter (flat object\n * of strings / string-enums / booleans with `required`); anything else throws\n * (fail-fast).\n */\nfunction jsonSchemaToTypeBox(schema: Record<string, unknown>): TObject {\n  if (\n    schema.type !== 'object' ||\n    typeof schema.properties !== 'object' ||\n    schema.properties === null\n  ) {\n    throw new Error('native tool inputSchema must be an object schema with `properties`');\n  }\n  const props = schema.properties as Record<string, Record<string, unknown>>;\n  const required = new Set(\n    Array.isArray(schema.required) ? (schema.required as unknown[]).filter(isString) : []\n  );\n\n  const shape: Record<string, TSchema> = {};\n  for (const [key, prop] of Object.entries(props)) {\n    let field: TSchema;\n    if (Array.isArray(prop.enum)) {\n      const values = prop.enum.filter(isString);\n      if (values.length === 0) {\n        throw new Error(`native tool schema: enum for '${key}' must be non-empty strings`);\n      }\n      field = Type.Union(values.map(v => Type.Literal(v)));\n    } else if (prop.type === 'string') {\n      field = Type.String();\n    } else if (prop.type === 'boolean') {","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/providers/src/community/pi/native-tools.ts#L3-L39","documentation":"jsonSchemaToTypeBox converts a plain JSON-Schema input schema into a TypeBox object schema for Pi native tools. It refuses any inputSchema that is not an object schema with a `properties` map, because Pi native tool definitions need typed per-property schemas. The throw is an upfront fail-fast against tool definitions the provider cannot represent.","triggerScenarios":"Calling buildPiNativeToolDefinitions with a tool whose inputSchema has type != 'object', lacks a `properties` key, or has `properties: null`.","commonSituations":"Hand-written tool schemas using top-level non-object types (e.g. `{type: 'string'}`), schemas copied from MCP servers that omit `properties`, or schemas typed as array at the root.","solutions":["Change the tool's inputSchema to `{type: 'object', properties: {...}}`","If the tool takes a scalar or list, wrap it: `{type:'object', properties:{ value: {type:'string'} }, required:['value']}`","Validate the inputSchema with a JSON-Schema validator before registering the tool"],"exampleFix":"// before\nconst inputSchema = { type: 'string' };\n// after\nconst inputSchema = { type: 'object', properties: { query: { type: 'string' } }, required: ['query'] };","handlingStrategy":"validation","validationCode":"function isValidRootSchema(s) {\n  return !!s && s.type === 'object' && typeof s.properties === 'object' && s.properties !== null;\n}\nif (!isValidRootSchema(tool.inputSchema)) throw new Error('tool inputSchema must be an object schema with properties');","typeGuard":"function isObjectSchema(s: unknown): s is { type: 'object'; properties: Record<string, unknown> } {\n  return typeof s === 'object' && s !== null && (s as any).type === 'object'\n    && typeof (s as any).properties === 'object' && (s as any).properties !== null;\n}","tryCatchPattern":"try {\n  const tools = buildPiNativeToolDefinitions(tools);\n} catch (err) {\n  if (err.message.includes('must be an object schema')) {\n    log.error({ tool: err.message }, 'invalid native tool inputSchema');\n  }\n  throw err;\n}","preventionTips":["Always author tool inputSchemas as object schemas with a properties map","Run a JSON-Schema meta-validation step in tests over every registered tool","Never reuse scalar-rooted MCP/OpenAPI schemas directly"],"tags":["schema","validation","native-tools"],"backgroundTag":"invalid-json-schema-root-type","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}