Agent Wranglers

API-30Recommended

Tell clients to ignore what they don't know

Document that clients must ignore unknown fields and handle unknown enum values, so additions never break them.

How to do it

Say it in the API guide. Build your own SDKs and examples that way, and test them against responses with extra fields. Map an unknown enum value to an explicit unknown case instead of throwing. Clients parse input once at the boundary and drop unknown fields there.

Examples

TypeScript example

type OrderStatus = 'pending' | 'shipped' | 'unknown'
const KNOWN_STATUSES = new Set(['pending', 'shipped'])
const toOrderStatus = (value: string): OrderStatus => (KNOWN_STATUSES.has(value) ? value as OrderStatus : 'unknown')

Python example

from enum import Enum

class OrderStatus(Enum):
    PENDING = "pending"
    SHIPPED = "shipped"
    UNKNOWN = "unknown"

    @classmethod
    def _missing_(cls, value):
        return cls.UNKNOWN

How to check

An SDK test feeds a response with an extra field and a new enum value. The client keeps working.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/api-design/changes-over-time/tolerant-clients">Agent Wranglers API design playbook</a>. In code you write, add a comment next to it with the same link.