{"record":{"id":"ba278472807acfc0","repo":"earendil-works/pi","slug":"tool-tool-name-requires-json-schema-constrain","errorCode":null,"errorMessage":"Tool \"${tool.name}\" requires JSON-schema constrained sampling, but ${error.message}.","messagePattern":"Tool \"(.+?)\" requires JSON-schema constrained sampling, but (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/ai/src/api/constrained-sampling.ts","lineNumber":219,"sourceCode":"\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}\n\tif (config.strict === \"require\") {\n\t\tthrow new Error(\n\t\t\t`Tool \"${tool.name}\" requires JSON-schema constrained sampling, but strict tools are unsupported.`,\n\t\t);\n\t}\n\treturn undefined;\n}\n\nexport function resolveGrammarConstrainedSampling(\n\ttool: Tool,\n\tsupportsOpenAIGrammarTools: boolean,\n): GrammarConstrainedSampling | undefined {\n\tconst config = tool.constrainedSampling;\n\tif (!config || config.type !== \"grammar\") {\n\t\treturn undefined;\n\t}","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/ai/src/api/constrained-sampling.ts#L201-L237","documentation":"Error \"Tool \"${tool.name}\" requires JSON-schema constrained sampling, but ${error.message}.\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/ai/src/api/constrained-sampling.ts:219 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the tool parameter schema per the embedded error, or disable JSON-schema constrained sampling for this tool."],"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"}