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

  1. Read the formatted validation issues in the message and fix each listed path/type mismatch, then call yield again with the corrected shape
  2. Validate the payload locally against the schema (e.g. with a JSON Schema validator) before submitting
  3. Check for strict-mode pitfalls: no extra properties, exact enum values, correct required fields
  4. 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

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


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/7c7700f583e2ff3f. Report an issue: GitHub.