can1357/oh-my-pi · error
${scope} does not match schema: ${formatAllValidationIssues(
Error message
${scope} does not match schema: ${formatAllValidationIssues(sectionFailure.issues)}.${retryHint} What it means
Yielded output (terminal data or incremental section) failed JSON-schema validation against the task's declared output schema. The tool throws with all validation issues formatted, plus a retry hint showing how many in-tool schema retries remain (MAX_SCHEMA_RETRIES); after the budget is exhausted the schema constraint is dropped and the data is accepted with a schemaOverridden flag.
Source
Thrown at packages/coding-agent/src/tools/yield.ts:470
const parsed = parseJsonContainerString(data);
if (parsed !== undefined) {
const revalidated = validateData(parsed);
if (revalidated === undefined || revalidated.success) {
data = parsed;
sectionFailure = revalidated;
}
}
}
if (sectionFailure && !sectionFailure.success) {
this.#schemaValidationFailures++;
if (this.#schemaValidationFailures <= MAX_SCHEMA_RETRIES) {
const remaining = MAX_SCHEMA_RETRIES - this.#schemaValidationFailures;
const retryHint =
remaining > 0
? ` Call yield again with the corrected shape — ${remaining} retry attempt(s) remain before the schema constraint is dropped.`
: " Call yield again with the corrected shape — this is the final retry before the schema constraint is dropped.";
const scope = isIncremental ? `Section ${formatYieldLabels(yieldType as string[])}` : "Output";
throw new Error(
`${scope} does not match schema: ${formatAllValidationIssues(sectionFailure.issues)}.${retryHint}`,
);
}
schemaValidationOverridden = true;
}
}
this.#emptyResultFailures = 0;
if (status === "success" && isIncremental) this.#hasIncrementalSections = true;
const responseText =
status === "aborted"
? `Task aborted: ${errorMessage}`
: schemaValidationOverridden
? `Result submitted (schema validation overridden after ${this.#schemaValidationFailures} failed attempt(s)).`
: "Result submitted.";
return {
content: [{ type: "text", text: responseText }],
details: {View on GitHub (pinned to 9690622007)
Solutions
- Read the formatted validation issues in the message and fix each listed path/type mismatch, then call yield again with the corrected shape
- Validate the payload locally against the schema (e.g. with a JSON Schema validator) before submitting
- Check for strict-mode pitfalls: no extra properties, exact enum values, correct required fields
- If retries run out the constraint is dropped, but prefer fixing the shape — the parent may still see schemaOverridden
Example fix
// before (schema requires findings: string[])
yield({ result: { data: { findings: "none" } } });
// after
yield({ result: { data: { findings: ["no issues found"] } } }); Defensive patterns
Strategy: validation
Validate before calling
import { isValidJsonSchema } from '@oh-my-pi/pi-ai/utils/schema';
const check = validateAgainstSchema(data, outputSchema);
if (!check.valid) throw new TypeError(check.issues.map(i => `${i.path}: ${i.message}`).join('; ')); Type guard
function matchesSchema(value, validate) {
const res = validate(value);
return res === undefined || res.valid === true;
} Try / catch
try {
yield({ result: { data } });
} catch (err) {
if (err.message.includes('does not match schema')) {
const fixed = repairDataFromIssues(data, err.message); // parse issue list
yield({ result: { data: fixed } });
} else throw err;
} Prevention
- Validate the payload against the output schema locally before every yield
- Check strict-mode constraints: no extra properties, exact enum values, all required fields
- Match primitive types exactly (number vs string) and required nesting order
- Budget fixes within MAX_SCHEMA_RETRIES — the hint in the message shows remaining attempts
When it happens
Trigger: Calling yield with data (or an incremental section) whose shape violates the output schema — wrong types, missing required properties, enum violations, additionalProperties violations — while a validator (#validate) is bound.
Common situations: The model emits strings where numbers are required, omits required fields, or nests objects differently than the schema; strict-mode schemas reject extra keys the model added; partial incremental payloads are submitted that don't yet match the section's slice of the schema.
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
- result cannot contain both data and error
- result must contain either \`data\` or \`error\`. Use \`{res
- Section ${formatYieldLabels(yieldType as string[])} uses unk
- This task requires structured output matching the declared s
- data is required when yield indicates success
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/7c7700f583e2ff3f.
Report an issue: GitHub.