Agent Output Contract And Structured-Response Enforcer
Defines a strict machine-parseable output contract for an agent and a self-validation step that guarantees conformance.
Prompt
ROLE: You are an integration engineer ensuring an agent's responses are reliably machine-parseable by downstream systems. CONTEXT: A downstream system [SYSTEM] consumes the agent's output and breaks when the format drifts. The data the agent must return is [REQUIRED_FIELDS]. Past breakages came from [PAST_FAILURES] (e.g., extra prose, missing fields, invalid enum values). TASK: Define and enforce the output contract. 1. Specify the exact output schema: field names, types, required vs optional, allowed enum values, and formats. 2. Define rules: no prose outside the structured object, no markdown fences unless required, deterministic key order. 3. Add a self-validation step the agent runs before responding: check every field against the schema and fix violations. 4. Define behavior when the agent cannot fill a required field (explicit null with a reason vs. omission). 5. Provide one valid example and one invalid example annotated with what is wrong. OUTPUT FORMAT: (a) The schema definition; (b) the agent's output rules as direct instructions; (c) the self-validation checklist; (d) valid + invalid annotated examples. CONSTRAINTS: The contract must eliminate [PAST_FAILURES]. Never allow free-text outside the object. Required fields are never silently dropped. The agent must self-check before emitting and never emit invalid output.
How to use this prompt
- 1
Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.
- 2
Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.
- 3
Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.
Techniques in this prompt
Pins the response to a defined structure so it drops straight into your workflow.
Learn this techniqueHas the model critique its own draft against criteria, then revise — raising quality in a single pass.
Learn this techniqueIncludes worked examples so the model matches your format and quality by pattern, not description.
Learn this techniqueRecommended models
Build on this prompt
Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.
More in AI Agents & Autonomous Workflows
Autonomous Agent System Prompt Architect
Designs a complete, production-grade system prompt for an autonomous agent including persona, tool contracts, guardrails, and stop conditions.
ReAct Loop Reasoning Trace Designer
Builds a strict ReAct-style Thought/Action/Observation loop with explicit formatting and self-correction rules for tool-using agents.
Multi-Agent Orchestration Blueprint
Plans a coordinated multi-agent team with roles, hand-off contracts, shared memory, and conflict resolution for a complex objective.
Agent Tool Definition And Schema Writer
Writes precise tool/function definitions with JSON schemas, descriptions, and usage hints that minimize wrong-tool and bad-argument errors.