{"record":{"id":"6fbc9c055a080b4f","repo":"earendil-works/pi","slug":"grammar-constrained-sampling-property-inputprope","errorCode":null,"errorMessage":"grammar constrained sampling property ${inputProperty} must have type string","messagePattern":"grammar constrained sampling property (.+?) must have type string","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/ai/src/api/constrained-sampling.ts","lineNumber":203,"sourceCode":"\t}\n\treturn delta;\n}\n\nfunction inferGrammarInputProperty(tool: Tool): string {\n\tconst schema = tool.parameters as JsonSchemaObject;\n\tif (schema.type !== \"object\") {\n\t\tthrow new Error(\"grammar constrained sampling requires an object parameter schema\");\n\t}\n\tif (!Array.isArray(schema.required) || schema.required.length !== 1 || typeof schema.required[0] !== \"string\") {\n\t\tthrow new Error(\"grammar constrained sampling requires exactly one required string property\");\n\t}\n\n\tconst inputProperty = schema.required[0];\n\tif (!schema.properties?.[inputProperty]) {\n\t\tthrow new Error(`grammar constrained sampling requires a properties entry for ${inputProperty}`);\n\t}\n\tif (schema.properties[inputProperty]?.type !== \"string\") {\n\t\tthrow new Error(`grammar constrained sampling property ${inputProperty} must have type string`);\n\t}\n\treturn inputProperty;\n}\n\nexport function resolveJsonSchemaStrictSampling(tool: Tool, supportsStrictMode: boolean): boolean | undefined {\n\tconst config = tool.constrainedSampling;\n\tif (!config || config.type !== \"json_schema\") return undefined;\n\n\tif (supportsStrictMode) {\n\t\ttry {\n\t\t\tmakeStrictJsonSchema(tool.parameters);\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof UnsupportedStrictJsonSchemaError)) throw error;\n\t\t\tif (config.strict !== \"require\") return undefined;\n\t\t\tthrow new Error(`Tool \"${tool.name}\" requires JSON-schema constrained sampling, but ${error.message}.`);\n\t\t}\n\t}","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/ai/src/api/constrained-sampling.ts#L185-L221","documentation":"Error \"grammar constrained sampling property ${inputProperty} must have type string\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/ai/src/api/constrained-sampling.ts:203 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the grammar input property type to string."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}