Error Handling Across Protocols
This document outlines AdCP’s approach to error handling across MCP and A2A protocols, providing consistent patterns for both fatal errors and non-fatal warnings.Philosophy
Pending States vs Errors
Pending States (Normal Flow):pending: Request received and queuedprocessing: Operation in progresspending_manual: Operation requires human approvalpending_permission: Operation blocked by permissionspending_approval: Awaiting ad server approval
- Task-level failures that prevent completion
- Authentication failures
- Invalid parameters
- Resource not found
- Authorization denied
Error Response Patterns
AdCP uses a two-tier error handling approach:- Task-Level Errors (Non-Fatal): Warnings and issues that don’t prevent operation completion
- Protocol-Level Errors (Fatal): Operations that cannot be completed
Task-Level Error Handling
Non-Fatal Errors vs Warnings
AdCP distinguishes between two types of task-level issues: Non-Fatal Errors: Actual failures that prevented part of the request from being fulfilled. These go in theerrors array:
message field:
Partial Success Support
Tasks can succeed while returning non-fatal errors in theerrors array or warnings in the message field:
Non-Fatal Errors (partial failures in errors array):
- Discovery tasks: Can find some results while reporting regions/platforms with no data
- Activation tasks: Can activate on some platforms while failing on others
- Creation tasks: Can create some packages while others fail validation
message field):
- Discovery tasks: Can find results while noting data freshness or coverage limitations in the message
- Activation tasks: Can activate successfully while noting suboptimal configuration in the message
- Creation tasks: Can create resources while suggesting optimization opportunities in the message
Error Object Structure
Theerrors array contains error objects for actual failures:
Warning Communication
Warnings and advisory information should be communicated in the human-readablemessage field rather than cluttering the errors array. This keeps the errors array focused on actionable failures that require programmatic handling.
Protocol-Level Error Handling
MCP (Model Context Protocol)
For fatal errors that prevent task completion, MCP uses theisError: true pattern:
- Authentication failures
- Invalid tool parameters
- Resource not found
- Authorization denied
- System errors
A2A (Agent-to-Agent Protocol)
For fatal errors, A2A uses thestatus: "failed" pattern:
- Skill execution failures
- Invalid request parameters
- External service unavailable
- Authentication issues
Error Recovery Strategies
Retry Logic
- Check
retry_afterfield for appropriate retry timing - Implement exponential backoff for rate limiting and service issues
- Categorize errors by retry-ability (permanent vs temporary)
Actionable Feedback
- Use
suggestionfield to guide remediation steps - Include relevant context in
detailsobject for debugging - Provide specific field paths for validation errors
- Reference external resources when additional action is required
Context Preservation
- Use
context_idfor session management across related operations - Include
task_idfor asynchronous operation tracking - Preserve request context in error details for debugging
Implementation Guidelines
Error Message Construction
Good error messages:- Explain what went wrong and why
- Provide specific remediation steps
- Include relevant context (IDs, values, constraints)
- Use clear, non-technical language
Error Code Naming
- Use
SCREAMING_SNAKE_CASEformat - Be specific and descriptive
- Group by category (ACTIVATION_, TARGETING_, PRICING_, etc.)
- Avoid generic codes like
ERRORorFAILED
Validation Error Patterns
For field validation issues:Common Error Scenarios
Authentication & Authorization
- Invalid credentials: Protocol-level fatal error
- Insufficient permissions: Protocol-level fatal error
- Account restrictions: Task-level warning with limited functionality
Resource Management
- Resource not found: Protocol-level fatal error
- Resource unavailable: Task-level warning with alternatives
- Resource limitations: Task-level warning with impact description
Data Quality Issues
- Invalid input data: Protocol-level fatal error
- Stale data: Task-level warning communicated in message field
- Incomplete data: Task-level warning communicated in message field
Testing Error Scenarios
When implementing AdCP tasks, test these error scenarios:- Invalid authentication → Protocol-level fatal
- Missing required fields → Protocol-level fatal
- Field validation failures → Protocol-level fatal
- Resource limitations → Task-level warnings in message field
- Partial data issues → Task-level warnings in message field
- Service degradation → Task-level warnings in message field with retry guidance
Reference
- Error Codes Reference - Complete list of standardized error codes
- MCP Specification - Official MCP error handling
- A2A Protocol Guide - A2A-specific error patterns