Skip to main content

Error Codes

ARC Protocol error taxonomy and conventions.

Error Structure

{
"error": {
"code": -32600,
"message": "Invalid request format",
"details": {
"field": "method",
"reason": "required field missing"
}
}
}

Standard RPC Errors (-32xxx)

Borrowed from JSON-RPC conventions:

CodeNameDescription
-32700Parse ErrorInvalid JSON
-32600Invalid RequestMalformed ARC message
-32601Method Not FoundUnknown method
-32602Invalid ParamsInvalid parameters
-32603Internal ErrorServer internal error

Agent Errors (-41xxx)

CodeNameDescription
-41001Agent Not FoundTarget agent does not exist
-41002Agent Not AvailableAgent exists but unavailable
-41003Agent OverloadedAgent cannot accept requests

Task Errors (-42xxx)

CodeNameDescription
-42001Task Not FoundTask ID does not exist
-42002Task Already CompletedCannot modify completed task
-42003Task Already CanceledCannot modify canceled task
-42004Task Processing ErrorError during task execution

Chat Errors (-43xxx)

CodeNameDescription
-43001Chat Not FoundChat ID does not exist
-43002Chat Already ClosedCannot send to closed chat
-43003Chat TimeoutChat session timed out
-43004Chat Participant LimitToo many participants
-43005Invalid Chat MessageMalformed message
-43006Chat Buffer OverflowMessage buffer full

Security Errors (-44xxx)

CodeNameDescription
-44001Authentication FailedInvalid or missing token
-44002Authorization FailedInsufficient permissions
-44003Insufficient ScopeOAuth2 scope missing
-44004Token ExpiredBearer token expired

Protocol Errors (-45xxx)

CodeNameDescription
-45001Unsupported VersionARC version not supported
-45002Rate Limit ExceededToo many requests
-45003Request Too LargePayload exceeds limit
-45004Network ErrorNetwork communication failed

Error Handling

Client Side

from arc.exceptions import (
TaskNotFoundError,
ChatNotFoundError,
AgentNotFoundError,
AuthenticationError
)

try:
response = await client.task.create(...)
except TaskNotFoundError as e:
# Handle task not found (code: -42001)
print(f"Error: {e.code} - {e.message}")
except AgentNotFoundError as e:
# Handle agent not found (code: -41001)
print(f"Agent unavailable: {e.message}")
except AuthenticationError as e:
# Handle auth error (code: -44001)
print(f"Authentication failed: {e.message}")

Server Side

from arc.exceptions import TaskNotFoundError

@server.agent_handler("my-agent", "task.info")
async def get_task_info(params, context):
task = get_task(params["taskId"])

if not task:
raise TaskNotFoundError(f"Task {params['taskId']} not found")

return {"type": "task", "task": task}

Error Response Format

{
"arc": "1.0",
"id": "request-123",
"responseAgent": "server-agent",
"targetAgent": "client-agent",
"error": {
"code": -42001,
"message": "Task not found",
"details": {
"taskId": "task-123",
"timestamp": "2025-01-06T00:00:00Z"
}
}
}

Custom Errors

Implement custom error codes outside reserved ranges:

# Custom error codes (avoid -32xxx, -41xxx, -42xxx, -43xxx, -44xxx, -45xxx)
class CustomBusinessError(ARCException):
def __init__(self, message: str):
super().__init__(
code=-50001, # Custom range
message=message
)

Best Practices

  1. Use Standard Codes - Use ARC standard codes when applicable
  2. Provide Details - Include helpful error details
  3. Log Errors - Log errors with trace IDs for debugging
  4. Handle Gracefully - Implement proper error handling
  5. Return Appropriate Codes - Match error type to situation

Error Ranges Summary

RangeCategoryUsage
-32xxxStandard RPCProtocol-level errors
-41xxxAgentAgent-related errors
-42xxxTaskTask operation errors
-43xxxChatChat operation errors
-44xxxSecurityAuthentication/authorization
-45xxxProtocolProtocol-level issues
-50xxx+CustomApplication-specific errors