can1357/oh-my-pi · error · StructuredSubagentError

Invalid ${scope} output schema: ${error}

Error message

Invalid ${scope} output schema: ${error}

What it means

Thrown in preflight when an output schema fails validation at build time. Schemas from the caller (normal or strict mode) or a strict-mode effective-agent schema are compiled by `buildOutputValidator`; a compile error (malformed JSON Schema, unsupported constructs) raises this with the scope (strict caller / caller / strict effective) and the underlying error message.

Source

Thrown at packages/coding-agent/src/task/structured-subagent.ts:279

	const disabledAgents = request.session.settings.get("task.disabledAgents") as string[];
	if (disabledAgents.includes(agentName)) {
		const enabled = discovery.agents
			.filter(candidate => !disabledAgents.includes(candidate.name))
			.map(candidate => candidate.name);
		throw new StructuredSubagentError(
			"preflight",
			`Agent "${agentName}" is disabled in settings. Enable it via /agents, or use a different agent type.${enabled.length > 0 ? ` Available: ${enabled.join(", ")}` : ""}`,
		);
	}

	const effectiveAgent = planMode ? createPlanModeAgent(agent) : agent;
	const schema = resolveSchema(request, effectiveAgent);
	if (schema.source === "caller" || (schema.source !== "none" && schema.mode === "strict")) {
		const { error } = buildOutputValidator(schema.schema);
		if (error) {
			const scope =
				schema.source === "caller" ? (schema.mode === "strict" ? "strict caller" : "caller") : "strict effective";
			throw new StructuredSubagentError("preflight", `Invalid ${scope} output schema: ${error}`);
		}
	}
	const agentModelOverrides = request.session.settings.get("task.agentModelOverrides");
	const parentActiveModelPattern = request.session.getActiveModelString?.();
	const modelResolution = {
		requestModel: request.model,
		settingsOverride: agentModelOverrides[agentName],
		agentModel: effectiveAgent.model,
		settings: request.session.settings,
		activeModelPattern: parentActiveModelPattern,
		fallbackModelPattern: request.session.getModelString?.(),
	};
	// Role identity and patterns come from one call so they cannot be derived
	// from different sources: the expansion below discards the alias, and the
	// child's inherited retry-fallback chain is keyed off the role.
	const { patterns: modelOverride, role: modelRole } = resolveAgentModelSelection(modelResolution);
	const isolationMode = request.session.settings.get("task.isolation.mode");
	const isIsolated = request.isolation?.requested === true;

View on GitHub (pinned to 9690622007)

Solutions

  1. Fix the schema according to the error message from buildOutputValidator
  2. Validate the JSON Schema with a standalone schema validator before passing it
  3. Drop strict mode or remove the agent-level schema if only the effective strict schema is invalid

Example fix

// before
await task({ agent: "a", outputSchema: { type: "stirng" } });
// after
await task({ agent: "a", outputSchema: { type: "string" } });
Defensive patterns

Strategy: validation

Validate before calling

const { error } = buildOutputValidator(myOutputSchema);
if (error) throw new Error(`Invalid output schema: ${error}`);
await task({ agent, outputSchema: myOutputSchema });

Try / catch

try {
  await task(req);
} catch (e) {
  if (e instanceof StructuredSubagentError && e.message.includes("output schema")) {
    return task({ ...req, outputSchema: undefined }); // degrade to unstructured
  }
  throw e;
}

Prevention

When it happens

Trigger: Passing `outputSchema` in the task request (caller scope) with invalid JSON Schema; an agent-defined schema used in strict mode that `buildOutputValidator` cannot compile.

Common situations: Handwritten schemas with typos (bad `type` values, dangling $ref); schemas copied from a different validator dialect (e.g. zod-to-JSON drift); strict mode enabled on an agent whose schema uses unsupported keywords.

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/379d4b53647fb2e3. Report an issue: GitHub.