Agent Output Schema and Repair Rules

A strict output schema for an agent's response, with validation and repair instructions.

Intermediate · Works with ChatGPT, Claude, Gemini, Copilot

The prompt

Design a strict output schema for this agent step.

What the step produces and who/what consumes it downstream:
{{STEP_OUTPUT}}

Cases where the natural output might not fit a clean schema:
{{EDGE_CASES}}

Write the schema (fields, types, required vs optional) and, for each edge case, say whether it should be represented in the schema or rejected upstream. Include what the agent should do when its own output fails validation — retry with what feedback, or escalate.

Why this prompt works

Deciding upfront how to handle validation failures avoids agents that silently loop or emit malformed output when a case wasn't anticipated.

How to customize it

  • List the actual downstream consumer so the schema matches real needs
  • Specify the retry feedback content, not just 'retry on failure'

Common mistakes

  • Designing the schema only for the happy path and ignoring the ambiguous cases
  • Allowing unlimited silent retries with no escalation path

Example

Input

Step output: A JSON object with category and confidence, consumed by a routing service

What a good answer looks like

A schema definition plus a short table of edge cases with their handling and repair path.

Make this prompt fit your work

ModelCoach.ai scores your version, shows what to improve and explains why, right inside ChatGPT, Claude, Gemini and Copilot.

Related prompts