earendil-works/pi · error

Tool " " requires JSON-schema constrained sampling, but…

Error message

Tool "${tool.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.

What it means

A tool requires JSON-schema strict sampling but the provider/model combination does not support strict tools at all (supportsStrictMode false). Since the requirement is mandatory, the call fails rather than silently sending an unconstrained schema the model could violate.

Solutions

  1. Disable strict mode on the tool, or use a provider that supports strict structured outputs.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at packages/ai/src/api/constrained-sampling.ts:223 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/8356fcc47d9202f6. Report an issue: GitHub.

Appendix: source

Thrown at packages/ai/src/api/constrained-sampling.ts:223

	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;
	}

	if (!supportsOpenAIGrammarTools) {
		return undefined;
	}

View on GitHub (pinned to 4af9d21d3b)