Map AI Agent State Payloads and Handover Contracts

Generate a strict Pydantic state schema for agent pipelines that defines delta updates, discard rules, and structured rejection envelopes for handoffs.

Agent prompt for Claude and ChatGPT

Prompt

Prompt
You are a senior AI systems architect. Create a rigid three-node Pydantic state schema for an agent pipeline involving a Planner, Worker, and Verifier. Follow these rules: 1. Define specific Pydantic models for each node that only allow delta updates to the shared state. 2. Include a discard rule policy for each field to prevent state bloat. 3. Define a VerifierRejection envelope that forces the worker to include a reason code and a fix instruction. 4. Use Python type hints for all attributes. Output format: 1. A summary of the state transit flow. 2. The complete Pydantic code block including the models. 3. A table detailing which node owns which field and the allowed mutation types. This is technical architecture design; do not include implementation code for the agent logic itself. Please ask these three questions before starting: 1. What is the primary domain of the agent tasks? 2. Are you using a central state store or sequential message passing? 3. What is the maximum allowed nesting depth for the state object?

Example output

Invoice pipeline state handoffPlanner to Worker to Verifier
  1. PlannerStep 1Extracts metadata and initializes the state
  2. WorkerStep 2Processes line items and updates financial totals
  3. VerifierStep 3Checks tax compliance, returns structured rejection if over threshold

Example for: an automated document processing pipeline handling invoices. ### State Transit Flow The Planner extracts metadata and initializes the state. The Worker processes line items and updates financial totals. The Verifier checks for tax compliance and returns a structured rejection if thresholds are exceeded. ### Pydantic Implementation from pydantic import BaseModel, Field from typing import List, Optional, Dict class PlannerState(BaseModel): document_id: str = Field(..., frozen=True) extracted_data: Dict = Field(default_factory=dict) class WorkerState(PlannerState): line_items: List[Dict] = Field(default_factory=list) total_amount: float = 0.0 class VerifierRejection(BaseModel): reason_code: str fix_instruction: str class FinalState(WorkerState): rejection: Optional[VerifierRejection] = None ### Field Ownership and Mutation Table | Field | Owner | Mutation Type |
| :--- | :--- | :--- |
| document_id | Planner | Immutable |
| extracted_data | Planner | Append-only |
| line_items | Worker | Full Replacement |
| total_amount | Worker | Arithmetic Update |
| rejection | Verifier | Set/Reset |

Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Forces strict field ownership to prevent race conditions in multi-agent workflows.
  • Uses Pydantic models to enforce runtime type safety and data integrity.
  • Standardizes error handling via a dedicated rejection envelope for verifiers.

Use this to define the contract between agents in a multi-agent system to prevent interface mismatch and state corruption. Paste this into ChatGPT, Claude, or Gemini when you are ready to define your system architecture.

Common edits

  • Adjust the field ownership table to match your specific agent responsibilities.
  • Add custom validators to the Pydantic models to enforce business logic constraints.

Reuse it: Use in a workflowAdapt in the builder

Prompt details

By
Prompts-GPT editors
Published
How prompts are written and checked

Did this prompt work?

Agent OrchestrationClaude

Design Human-in-the-Loop Escalation Gates for AI Agents

This prompt creates a structured risk-assessment framework for AI agents, forcing human approval for high-stakes tool invocations based on a four-tier risk rubric.

Agent Orchestration

Create Error Handling Contracts for AI Agents

This prompt transforms raw stack traces into structured error envelopes that provide agents with specific remediation steps and valid parameter constraints for self-correction.

Agent OrchestrationClaude

Define Context Compression Rules for Long-Running AI Agents

Create a formal policy for compressing conversation history and managing agent memory to ensure long-running threads remain efficient without losing critical task data.

Agent OrchestrationClaude

Design Idempotent API Tool Schemas and Retry Policies

Generate robust JSON tool schemas for AI agents that enforce idempotency, define safe retry status codes, and specify clear error recovery strategies for external APIs.

Agent OrchestrationClaude

Design Mock Tool Fixtures for Agent Trajectory Testing

Generate deterministic mock tool responses to test agent decision trees, edge-case failures, and schema-breaking payloads without live API usage or costs.

Agent OrchestrationClaude

Triage Dead-Letter Queue Logs for Failed AI Agents

Sort unhandled agent run failures into an actionable classification table separating tool downtime, invalid schema calls, and missing user context.