{"record":{"id":"772320eb68f5dca7","repo":"coleam00/Archon","slug":"native-tool-schema-unsupported-type-for-key","errorCode":null,"errorMessage":"native tool schema: unsupported type for '${key}' (only string / string-enum / boolean)","messagePattern":"native tool schema: unsupported type for '(.+?)' \\(only string / string-enum / boolean\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/providers/src/community/pi/native-tools.ts","lineNumber":42,"sourceCode":"  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') {\n      field = Type.Boolean();\n    } else {\n      throw new Error(\n        `native tool schema: unsupported type for '${key}' (only string / string-enum / boolean)`\n      );\n    }\n    if (typeof prop.description === 'string') {\n      field = Type.Unsafe<unknown>({ ...field, description: prop.description });\n    }\n    shape[key] = required.has(key) ? field : Type.Optional(field);\n  }\n  return Type.Object(shape);\n}\n\n/**\n * Adapt NativeTools to Pi `ToolDefinition`s for the `customTools` array. The\n * handler's text result becomes the tool's content; `details` is unused.\n */\nexport function buildPiNativeToolDefinitions(nativeTools: NativeTool[]): ToolDefinition[] {\n  return nativeTools.map(spec =>\n    defineTool({","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/providers/src/community/pi/native-tools.ts#L24-L60","documentation":"jsonSchemaToTypeBox supports only three property kinds for Pi native tools: string, string-enum, and boolean. Any other property type (number, integer, array, object, missing type) throws this error listing the supported set.","triggerScenarios":"A property in inputSchema.properties with `type: 'number'`, `'integer'`, `'array'`, `'object'`, or no `type` and no `enum`, passed to buildPiNativeToolDefinitions.","commonSituations":"Schemas ported from richer tool frameworks that use numeric params or nested objects, and schemas where a property's `type` was forgotten entirely.","solutions":["Change numeric properties to `type: 'string'` and parse in the handler","Flatten nested object parameters into top-level string/boolean properties","Express a bounded list as a string enum where possible","If complex schemas are required, pass the tool through the regular (prompt-based) tool path instead of native tools"],"exampleFix":"// before\n{ type: 'object', properties: { count: { type: 'integer' } } }\n// after\n{ type: 'object', properties: { count: { type: 'string', description: 'integer as string' } } }","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set(['string', 'boolean']);\nfor (const [key, prop] of Object.entries(schema.properties)) {\n  const ok = Array.isArray(prop.enum) || SUPPORTED.has(prop.type);\n  if (!ok) throw new Error(`property '${key}' type '${prop.type}' unsupported; use string, string-enum, or boolean`);\n}","typeGuard":"function isSupportedProperty(prop: unknown): boolean {\n  if (typeof prop !== 'object' || prop === null) return false;\n  const p = prop as { enum?: unknown; type?: unknown };\n  return Array.isArray(p.enum) || p.type === 'string' || p.type === 'boolean';\n}","tryCatchPattern":"try {\n  const defs = buildPiNativeToolDefinitions(tools);\n} catch (err) {\n  if (err.message.includes('unsupported type')) {\n    log.warn({ err: err.message }, 'native tool schema narrowed');\n    // fall back to prompt-based tools for this tool\n  } else throw err;\n}","preventionTips":["Design native tool params using only string, string-enum, and boolean","Encode numbers as strings with a description, parse in the handler","Keep a unit test that converts every tool schema at registration time to catch regressions early"],"tags":["schema","validation","native-tools"],"backgroundTag":"unsupported-schema-type","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}