earendil-works/pi · error
Grammar tool call "${toolName}" requires argument "${inputPr
Error message
Grammar tool call "${toolName}" requires argument "${inputProperty}" to be a string. What it means
Error "Grammar tool call "${toolName}" requires argument "${inputProperty}" to be a string." thrown in earendil-works/pi.
Source
Thrown at packages/ai/src/api/constrained-sampling.ts:152
format: "lark" | "regex";
definition: string;
inputProperty: string;
}
export interface GrammarToolInputJsonBuffer {
input: string;
started: boolean;
closed: boolean;
}
export function getGrammarToolInput(
toolName: string,
arguments_: Record<string, unknown>,
inputProperty: string,
): string {
const input = arguments_[inputProperty];
if (typeof input !== "string") {
throw new Error(`Grammar tool call "${toolName}" requires argument "${inputProperty}" to be a string.`);
}
return input;
}
export function appendGrammarToolInputJsonDelta(
buffer: GrammarToolInputJsonBuffer,
inputProperty: string,
nextInput: string,
close: boolean,
): string | undefined {
if (buffer.closed) {
if (close && nextInput === buffer.input) return undefined;
throw new Error(`grammar tool input for property "${inputProperty}" changed after it was closed`);
}
if (!nextInput.startsWith(buffer.input)) {
throw new Error(`grammar tool input for property "${inputProperty}" changed non-monotonically`);
}
View on GitHub (pinned to 4af9d21d3b)
Solutions
- Declare the grammar tool argument property with type string.
When it happens
Trigger: Thrown at packages/ai/src/api/constrained-sampling.ts:152 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24).
Data as JSON: /api/errors/73c6e85c06743282.
Report an issue: GitHub.