earendil-works/pi · error
Tool " " requires JSON-schema constrained sampling, but .
Error message
Tool "${tool.name}" requires JSON-schema constrained sampling, but ${error.message}. What it means
resolveJsonSchemaStrictSampling wraps makeStrictJsonSchema failures: when a tool demands strict sampling (config.strict === 'require') and the schema cannot be strictened for a reason the provider cannot support, the underlying UnsupportedStrictJsonSchemaError message is embedded in this error. Soft-requirement tools instead just fall back to non-strict.
Solutions
- Fix the tool parameter schema per the embedded error, or disable JSON-schema constrained sampling for this tool.
Defensive patterns
Strategy: fallback
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.
Appendix: 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)