{"record":{"id":"73c6e85c06743282","repo":"earendil-works/pi","slug":"grammar-tool-call-toolname-requires-argument","errorCode":null,"errorMessage":"Grammar tool call \"${toolName}\" requires argument \"${inputProperty}\" to be a string.","messagePattern":"Grammar tool call \"(.+?)\" requires argument \"(.+?)\" to be a string\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/ai/src/api/constrained-sampling.ts","lineNumber":152,"sourceCode":"\tformat: \"lark\" | \"regex\";\n\tdefinition: string;\n\tinputProperty: string;\n}\n\nexport interface GrammarToolInputJsonBuffer {\n\tinput: string;\n\tstarted: boolean;\n\tclosed: boolean;\n}\n\nexport function getGrammarToolInput(\n\ttoolName: string,\n\targuments_: Record<string, unknown>,\n\tinputProperty: string,\n): string {\n\tconst input = arguments_[inputProperty];\n\tif (typeof input !== \"string\") {\n\t\tthrow new Error(`Grammar tool call \"${toolName}\" requires argument \"${inputProperty}\" to be a string.`);\n\t}\n\treturn input;\n}\n\nexport function appendGrammarToolInputJsonDelta(\n\tbuffer: GrammarToolInputJsonBuffer,\n\tinputProperty: string,\n\tnextInput: string,\n\tclose: boolean,\n): string | undefined {\n\tif (buffer.closed) {\n\t\tif (close && nextInput === buffer.input) return undefined;\n\t\tthrow new Error(`grammar tool input for property \"${inputProperty}\" changed after it was closed`);\n\t}\n\tif (!nextInput.startsWith(buffer.input)) {\n\t\tthrow new Error(`grammar tool input for property \"${inputProperty}\" changed non-monotonically`);\n\t}\n","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/ai/src/api/constrained-sampling.ts#L134-L170","documentation":"Error \"Grammar tool call \"${toolName}\" requires argument \"${inputProperty}\" to be a string.\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/ai/src/api/constrained-sampling.ts:152 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Declare the grammar tool argument property with type 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"}