Strict JSON Handoff Schemas with Validation and Retry Rules for Agent Pipelines

Turns a pasted pipeline description into JSON schemas for every agent-to-agent handoff, plus validation checks and retry rules for bad output.

You get: A table of handoffs, for each handoff and risks and missing information

More like this

The prompt

strict-json-handoff-schemas-with-validation-and-retry-rules-for-agent-pipelines.md
Act as a backend engineer who specializes in reliable multi-agent systems. My job is to define strict JSON handoff contracts so a bad output from one agent cannot silently break the next. Here is my pipeline description: {paste your pipeline description here}

If the description does not make the agents, their order, or what each one produces clear, ask me up to two short questions first, then wait.

Rules:
- Define one JSON Schema per agent pair, with required fields, types, enums, length limits, and additionalProperties set to false.
- Include a status field and an error field so agents can report failure without free text.
- Validation checks must be testable by code, such as schema match, non-empty fields, valid references to earlier IDs, and value ranges.
- Retry rules state the maximum attempts, the exact correction message sent back to the agent, and when to escalate to a human.

Output format:
1. Assumptions (separate list).
2. A table of handoffs: from, to, purpose.
3. For each handoff, the JSON Schema in a code block, then its validation checks and retry rule.
4. Risks and missing information.
5. Three next actions, including how to test the schemas with bad samples.

Check that every field one agent needs is produced by the one before it.

Example output

AI-written example
"""
Pipeline: Support-ticket reply. Intake Agent -> Triage Agent -> Drafter Agent -> Reviewer Agent

ASSUMPTIONS
- The Intake Agent receives raw email text and is the only source of ticket_id.
- Triage may only cite KB article IDs that exist in the KB index (KB_IDS).
- The Drafter must not invent IDs. It may cite only IDs passed to it by Triage.
- Failure is reported with status="error" and an enum code, never free text.
- Max reply length is 1,500 characters.

HANDOFFS
  #  from     -> to        purpose
  1  Intake   -> Triage    normalized customer message
  2  Triage   -> Drafter   category, priority, KB matches, plus message passthrough
  3  Drafter  -> Reviewer  draft reply with citations and confidence
"""
import json
from jsonschema import Draft202012Validator

TICKET_ID = {"type": "string", "pattern": "^TCK-[0-9]{6}$"}
ERROR = {
    "type": ["object", "null"],
    "additionalProperties": False,
    "required": ["code", "retryable"],
    "properties": {
        "code": {"enum": ["EMPTY_INPUT", "UNSUPPORTED_LANGUAGE",
                          "NO_KB_MATCH", "POLICY_CONFLICT", "INTERNAL"]},
        "retryable": {"type": "boolean"},
    },
}
STATUS = {"enum": ["ok", "error"]}

INTAKE_TO_TRIAGE = {
    "type": "object", "additionalProperties": False,
    "required": ["ticket_id", "status", "error", "customer_message", "language"],
    "properties": {
        "ticket_id": TICKET_ID, "status": STATUS, "error": ERROR,
        "customer_message": {"type": "string", "minLength": 1, "maxLength": 4000},
        "language": {"enum": ["en", "es", "de", "fr"]},
    },
}

TRIAGE_TO_DRAFTER = {
    "type": "object", "additionalProperties": False,
    "required": ["ticket_id", "status", "error", "customer_message",
                 "category", "priority", "kb_article_ids"],
    "properties": {
        "ticket_id": TICKET_ID, "status": STATUS, "error": ERROR,
        "customer_message": {"type": "string", "minLength": 1, "maxLength": 4000},
        "category": {"enum
Generated from this prompt by AI. Your results will vary.

Tips and common edits

Use when you have a draft pipeline and want enforceable contracts before writing orchestration code. Paste a plain description of the agents, their order and their outputs.

Questions about this prompt

Parallel Research Fan-Out and Fan-In with Citation Table and Decision Memo

Splits a research question across parallel research agents, defines source discovery and evidence review steps, merges findings into a citation table, and produces a decision memo without claiming live browsing.

Research-to-Report Pipeline with Planner, Researcher, Writer and Fact-Checker

Designs a four-agent pipeline for your report type with each agent's prompt, inputs, outputs and handoff format.

Subagent Roster Designer for Your Coding Project

Produces a 3-5 subagent roster with system prompts, minimal tool permissions, model tiers and explicit handoff rules for your project.

Agent Pipeline Failure Mode Audit with Retry, Fallback, and Human Escalation Rules

Audits an existing multi-agent pipeline for failure modes and produces retry limits, fallback paths, escalation triggers, and a test plan. Supports the decision on what to harden before wider rollout.

Sequential Agent Handoff Contract Builder for Research-to-Publish Chains

Designs the handoff contracts, stop conditions, and review gates for a sequential chain such as researcher, writer, editor, and fact-checker. Helps you decide whether the chain is ready to run.

Agent Tool Names, Descriptions and JSON Schemas from API Docs

Turns pasted API docs or a function list into agent-ready tool names, descriptions, JSON input schemas and when-to-use and when-not-to-use notes.

Dependency Graph Planner for a Multi-Agent Software Release Workflow

Turns a list of release tasks into a dependency graph with parallel batches, critical path, shared-resource conflicts, and agent assignments. Supports the decision on what to run now versus wait on.

Business Idea Validation Sprint with a $100 Two-Week Test

Turn a business idea and target customer into a ranked list of risky assumptions, five interview questions and a $100 test to run in two weeks.

Positioning and Messaging Hierarchy Builder from Competitor and Customer Evidence

Turns your product facts, customer evidence, and competitor notes into a tested positioning statement, messaging hierarchy, and proof-gap list so a marketing team can decide what to say and what to validate first.

Regex with Match and Non-Match Test Strings

Writes a regex for your pattern, explains each part and provides 8 strings that should match and 8 that should not.

20-Case Agent Eval Set with Pass/Fail Rubric for Normal, Edge and Unsafe Requests

Builds 20 test cases for your agent's task, with expected behavior, failure signals and a pass/fail rubric covering normal, edge and unsafe requests.

Agent Workflow Decomposition with Autonomy Levels and Stop Rules

Turns a manual process into a step-by-step agent plan with tools, approval gates, retry limits, and a build/pilot/skip recommendation.