can1357/oh-my-pi · warning
yield parameters schema is invalid
Error message
yield parameters schema is invalid
What it means
After wrapping the (possibly sanitized) data schema, YieldTool validates the final `parameters` schema and stringifies it. If isValidJsonSchema fails — or any prior step in the try block throws — this Error is caught by the surrounding handler, which then falls back to a loose record schema embedding the error message, so structured output degrades gracefully rather than crashing.
Source
Thrown at packages/coding-agent/src/tools/yield.ts:340
let dataSchema: Record<string, unknown>;
if (sanitizedSchema !== undefined) {
const resolved = dereferenceJsonSchema({
...sanitizedSchema,
description: schemaDescription,
}) as Record<string, unknown>;
if (hasUnresolvedRefs(resolved)) {
throw new Error("schema contains unresolved $ref after dereferencing");
}
dataSchema = withSectionVariants(resolved);
} else {
this.strict = false;
dataSchema = looseRecordSchema(
schemaError ? schemaDescription : "Structured JSON output (no schema specified)",
);
}
parameters = wrapYieldParameters(dataSchema);
JSON.stringify(parameters);
if (!isValidJsonSchema(parameters)) throw new Error("yield parameters schema is invalid");
} catch (err) {
const errorMsg = err instanceof Error ? err.message : String(err);
parameters = wrapYieldParameters(
looseRecordSchema(`Structured JSON output (schema processing failed: ${errorMsg})`),
);
validate = undefined;
this.strict = false;
}
this.#validate = validate;
this.#validateSection = validateSection;
this.#rejectUnknownSections = rejectUnknownSections;
this.#knownSectionLabels = knownSectionLabels;
this.#isKnownSection = isKnownSection;
this.description = prompt.render(yieldDescription, { hasOutputSchema: validate !== undefined });
this.parameters = parameters;
}
View on GitHub (pinned to 9690622007)
Solutions
- Fix the supplied schema to be a valid JSON Schema (correct types, required keys referencing existing properties).
- Inspect the fallback message in the tool parameters — it embeds the original error text (`schema processing failed: ...`).
- Simplify the schema (fewer exotic keywords) and retry.
- Omit the schema to use the default loose record schema.
- null
Example fix
// before
yield({ schema: { type: "object", properties: { x: { type: "integer" } }, required: ["x","y"] } })
// after
yield({ schema: { type: "object", properties: { x: { type: "integer" } }, required: ["x"] } }) Defensive patterns
Strategy: try-catch
Validate before calling
// pre-validate with the same validator family before constructing
if (!isValidJsonSchema(candidateSchema)) console.error("invalid schema", JSON.stringify(candidateSchema)); Type guard
function isValidJsonSchema(s: unknown): boolean { /* validate against JSON Schema meta-schema */ return validateMetaSchema(s); } Try / catch
try { const t = new YieldTool({ schema }); } catch (err) { console.warn("falling back to loose schema:", err.message); const t = new YieldTool({}); // loose record schema } Prevention
- Keep schemas simple: standard types, valid `required` lists, no exotic keywords.
- Test schema construction in CI before relying on structured output.
- Read the fallback message (it embeds the original failure reason).
- Run schema sanitization/dereferencing before passing custom schemas.
When it happens
Trigger: A wrapped yield parameters schema that violates JSON Schema constraints (e.g. invalid `type` values, conflicting keywords like `required` referencing nonexistent properties, unsupported combinations introduced by withSectionVariants/wrapYieldParameters).
Common situations: Schemas with provider-unsupported keywords or malformed constraints; deeply nested schemas that sanitization mutates into invalid form; custom validators flagging fields the provider would reject.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Schema contains a circular object graph — cannot enforce str
- Schema node has no type, combinator, or $ref — cannot enforc
- Host tool "${name}" must provide a JSON Schema object
- Invalid ${scope} output schema: ${error}
- type must be a string or non-empty array of strings
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/3ad71169dcb065e7.
Report an issue: GitHub.