earendil-works/pi · error
Tool "${tool.name}" requires JSON-schema constrained samplin
Error message
Tool "${tool.name}" requires JSON-schema constrained sampling, but ${error.message}. What it means
Error "Tool "${tool.name}" requires JSON-schema constrained sampling, but ${error.message}." thrown in earendil-works/pi.
Source
Thrown at packages/ai/src/api/constrained-sampling.ts:219
}
if (schema.properties[inputProperty]?.type !== "string") {
throw new Error(`grammar constrained sampling property ${inputProperty} must have type string`);
}
return inputProperty;
}
export function resolveJsonSchemaStrictSampling(tool: Tool, supportsStrictMode: boolean): boolean | undefined {
const config = tool.constrainedSampling;
if (!config || config.type !== "json_schema") return undefined;
if (supportsStrictMode) {
try {
makeStrictJsonSchema(tool.parameters);
return true;
} catch (error) {
if (!(error instanceof UnsupportedStrictJsonSchemaError)) throw error;
if (config.strict !== "require") return undefined;
throw new Error(`Tool "${tool.name}" requires JSON-schema constrained sampling, but ${error.message}.`);
}
}
if (config.strict === "require") {
throw new Error(
`Tool "${tool.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.`,
);
}
return undefined;
}
export function resolveGrammarConstrainedSampling(
tool: Tool,
supportsOpenAIGrammarTools: boolean,
): GrammarConstrainedSampling | undefined {
const config = tool.constrainedSampling;
if (!config || config.type !== "grammar") {
return undefined;
}View on GitHub (pinned to 4af9d21d3b)
Solutions
- Fix the tool parameter schema per the embedded error, or disable JSON-schema constrained sampling for this tool.
When it happens
Trigger: Thrown at packages/ai/src/api/constrained-sampling.ts:219 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/ba278472807acfc0.
Report an issue: GitHub.