{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "https://docs.anychat.ai/schemas/test-case.schema.json",
    "title": "Anychat test case",
    "description": "One test case: an English brief (the use case), a scenario (which persona the case runs against and what the agent knows), the person's script, and expectations (deterministic checks + judge criteria). Unknown keys are errors.",
    "type": "object",
    "additionalProperties": false,
    "required": [
        "title",
        "turns"
    ],
    "properties": {
        "key": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]{0,118}$"
        },
        "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300
        },
        "brief": {
            "type": "object",
            "additionalProperties": false,
            "required": [
                "scenario",
                "expected"
            ],
            "properties": {
                "scenario": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000
                },
                "expected": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000
                }
            }
        },
        "notes": {
            "type": "string",
            "maxLength": 4000
        },
        "tags": {
            "type": "array",
            "items": {
                "type": "string",
                "maxLength": 60
            },
            "maxItems": 20
        },
        "samples": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5
        },
        "origin": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "conversationId": {
                    "type": "string"
                },
                "userId": {
                    "type": "string"
                },
                "recordedAt": {
                    "type": "string"
                },
                "generatedFrom": {
                    "type": "string",
                    "maxLength": 4000
                },
                "generatedAt": {
                    "type": "string"
                },
                "kind": {
                    "type": "string",
                    "enum": [
                        "conversation",
                        "playbookExample",
                        "generated"
                    ]
                },
                "turnId": {
                    "type": "string"
                },
                "playbookId": {
                    "type": "string",
                    "maxLength": 200
                },
                "exampleIndex": {
                    "type": "integer",
                    "minimum": 0
                }
            }
        },
        "scenario": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "channel": {
                    "type": "string",
                    "enum": [
                        "rcs",
                        "sms",
                        "whatsapp",
                        "appleMessages"
                    ]
                },
                "provider": {
                    "type": "string",
                    "maxLength": 40
                },
                "persona": {
                    "oneOf": [
                        {
                            "type": "null"
                        },
                        {
                            "type": "object",
                            "additionalProperties": false,
                            "required": [
                                "id"
                            ],
                            "properties": {
                                "id": {
                                    "type": "string",
                                    "maxLength": 64
                                }
                            }
                        },
                        {
                            "type": "object",
                            "additionalProperties": false,
                            "required": [
                                "preset"
                            ],
                            "properties": {
                                "preset": {
                                    "type": "object",
                                    "additionalProperties": false,
                                    "properties": {
                                        "fields": {
                                            "type": "object",
                                            "additionalProperties": false,
                                            "properties": {
                                                "fullName": {
                                                    "type": "string",
                                                    "maxLength": 200
                                                },
                                                "firstName": {
                                                    "type": "string",
                                                    "maxLength": 100
                                                },
                                                "lastName": {
                                                    "type": "string",
                                                    "maxLength": 100
                                                },
                                                "email": {
                                                    "type": "string",
                                                    "maxLength": 300
                                                },
                                                "phone": {
                                                    "type": "string",
                                                    "maxLength": 50
                                                },
                                                "company": {
                                                    "type": "string",
                                                    "maxLength": 200
                                                },
                                                "title": {
                                                    "type": "string",
                                                    "maxLength": 200
                                                },
                                                "productInterest": {
                                                    "type": "string",
                                                    "maxLength": 200
                                                },
                                                "status": {
                                                    "type": "string",
                                                    "enum": [
                                                        "new",
                                                        "contacted",
                                                        "qualified",
                                                        "converted",
                                                        "lost"
                                                    ]
                                                },
                                                "source": {
                                                    "type": "string",
                                                    "maxLength": 200
                                                },
                                                "customFields": {
                                                    "description": "Values are strings; a number or boolean (a typed People field such as `isCheckedIn: true`) is accepted and stored as its string.",
                                                    "type": "object",
                                                    "additionalProperties": {
                                                        "type": [
                                                            "string",
                                                            "number",
                                                            "boolean"
                                                        ],
                                                        "maxLength": 2000
                                                    }
                                                },
                                                "assignedRepresentativeId": {
                                                    "type": "string",
                                                    "maxLength": 200
                                                },
                                                "tags": {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "string",
                                                        "maxLength": 60
                                                    }
                                                },
                                                "notes": {
                                                    "type": "string",
                                                    "maxLength": 5000
                                                }
                                            }
                                        },
                                        "consent": {
                                            "type": "object",
                                            "additionalProperties": false,
                                            "required": [
                                                "status"
                                            ],
                                            "properties": {
                                                "status": {
                                                    "type": "string",
                                                    "enum": [
                                                        "granted",
                                                        "denied",
                                                        "unknown"
                                                    ]
                                                }
                                            }
                                        },
                                        "historySeed": {
                                            "type": "array",
                                            "maxItems": 40,
                                            "items": {
                                                "type": "object",
                                                "additionalProperties": false,
                                                "required": [
                                                    "role",
                                                    "content"
                                                ],
                                                "properties": {
                                                    "role": {
                                                        "type": "string",
                                                        "enum": [
                                                            "user",
                                                            "assistant"
                                                        ]
                                                    },
                                                    "content": {
                                                        "type": "string",
                                                        "maxLength": 4000
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    ]
                },
                "appointments": {
                    "type": "array",
                    "maxItems": 5,
                    "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                            "startsIn"
                        ],
                        "properties": {
                            "startsIn": {
                                "type": "string",
                                "pattern": "^-?P(?!$)(\\d+D)?(T(\\d+H)?(\\d+M)?)?$"
                            },
                            "durationMinutes": {
                                "type": "integer",
                                "minimum": 5,
                                "maximum": 480
                            },
                            "representativeId": {
                                "type": "string",
                                "maxLength": 200
                            },
                            "status": {
                                "type": "string",
                                "enum": [
                                    "scheduled",
                                    "cancelled",
                                    "completed"
                                ]
                            }
                        }
                    }
                },
                "start": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "inbound": {
                            "type": "boolean"
                        },
                        "outreach": {
                            "description": "Operator-originated start. Name the Outreach that begins the conversation (`outreachId`) plus any `inputs` its opener declares: the Outreach carries the opener template, the Playbook, the Goal and the class together, exactly as a real send resolves them.",
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                                "outreachId": {
                                    "description": "The Outreach that starts the conversation. Supplies the opener, the Playbook, the class and whether a second bubble is composed.",
                                    "type": "string",
                                    "maxLength": 200
                                },
                                "inputs": {
                                    "description": "Opener slot values for this send, e.g. {\"checkInDate\": \"2026-10-14\"}.",
                                    "type": "object",
                                    "additionalProperties": {
                                        "type": [
                                            "string",
                                            "number",
                                            "boolean"
                                        ],
                                        "maxLength": 2000
                                    }
                                },
                                "formData": {
                                    "description": "What the intake form would have carried into the conversation.",
                                    "type": "object",
                                    "additionalProperties": {
                                        "type": [
                                            "string",
                                            "number",
                                            "boolean"
                                        ],
                                        "maxLength": 2000
                                    }
                                },
                                "campaign": {
                                    "description": "Record campaign attribution on this send (attribution only — the opener comes from the Outreach).",
                                    "type": "boolean"
                                }
                            }
                        },
                        "reminder": {
                            "type": "boolean"
                        },
                        "resume": {
                            "type": "object",
                            "additionalProperties": false,
                            "required": [
                                "activePlaybook"
                            ],
                            "properties": {
                                "activePlaybook": {
                                    "type": "string",
                                    "maxLength": 200
                                }
                            }
                        }
                    }
                },
                "history": {
                    "type": "array",
                    "maxItems": 40,
                    "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                            "role",
                            "content"
                        ],
                        "properties": {
                            "role": {
                                "type": "string",
                                "enum": [
                                    "user",
                                    "assistant"
                                ]
                            },
                            "content": {
                                "type": "string",
                                "maxLength": 4000
                            }
                        }
                    }
                },
                "clock": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "now": {
                            "type": "string"
                        },
                        "weekday": {
                            "type": "string",
                            "enum": [
                                "monday",
                                "tuesday",
                                "wednesday",
                                "thursday",
                                "friday",
                                "saturday",
                                "sunday"
                            ]
                        },
                        "time": {
                            "type": "string",
                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                        },
                        "timezone": {
                            "type": "string",
                            "maxLength": 100
                        }
                    }
                },
                "stubs": {
                    "type": "object",
                    "additionalProperties": true
                }
            }
        },
        "turns": {
            "type": "array",
            "minItems": 0,
            "maxItems": 40,
            "items": {
                "oneOf": [
                    {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 4000
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                            "chip"
                        ],
                        "properties": {
                            "chip": {
                                "type": "string",
                                "maxLength": 200
                            },
                            "fallback": {
                                "type": "string",
                                "maxLength": 4000
                            }
                        }
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                            "slot"
                        ],
                        "properties": {
                            "slot": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 50
                            },
                            "fallback": {
                                "type": "string",
                                "maxLength": 4000
                            }
                        }
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                            "confirm"
                        ],
                        "properties": {
                            "confirm": {
                                "type": "boolean"
                            },
                            "fallback": {
                                "type": "string",
                                "maxLength": 4000
                            }
                        }
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                            "system"
                        ],
                        "properties": {
                            "system": {
                                "type": "string",
                                "enum": [
                                    "optOut",
                                    "optIn",
                                    "subscribed",
                                    "unsubscribed"
                                ]
                            }
                        }
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                            "action"
                        ],
                        "properties": {
                            "action": {
                                "type": "string",
                                "enum": [
                                    "calendar",
                                    "dial",
                                    "url",
                                    "viewLocation"
                                ]
                            },
                            "label": {
                                "type": "string",
                                "maxLength": 200
                            }
                        }
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                            "media",
                            "url"
                        ],
                        "properties": {
                            "media": {
                                "type": "string",
                                "enum": [
                                    "image",
                                    "video"
                                ]
                            },
                            "url": {
                                "type": "string",
                                "maxLength": 2000
                            },
                            "text": {
                                "type": "string",
                                "maxLength": 4000
                            }
                        }
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                            "simulate"
                        ],
                        "properties": {
                            "simulate": {
                                "type": "object",
                                "additionalProperties": false,
                                "required": [
                                    "goal"
                                ],
                                "properties": {
                                    "goal": {
                                        "type": "string",
                                        "maxLength": 2000
                                    },
                                    "persona": {
                                        "type": "string",
                                        "maxLength": 2000
                                    },
                                    "knows": {
                                        "type": "array",
                                        "items": {
                                            "type": "string",
                                            "maxLength": 500
                                        },
                                        "maxItems": 20
                                    },
                                    "until": {
                                        "type": "string",
                                        "maxLength": 1000
                                    },
                                    "maxTurns": {
                                        "type": "integer",
                                        "minimum": 1,
                                        "maximum": 20
                                    }
                                }
                            }
                        }
                    }
                ]
            }
        },
        "expect": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "checks": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "finalReplyNonEmpty": {
                            "type": "boolean"
                        },
                        "pickerShown": {
                            "type": "boolean"
                        },
                        "appointmentCreated": {
                            "type": "boolean"
                        },
                        "activeAppointments": {
                            "type": "integer",
                            "minimum": 0
                        },
                        "outcomes": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        },
                        "activePlaybookAtEnd": {
                            "type": "string"
                        },
                        "personFields": {
                            "description": "Each named Person field equals the value (case-insensitive). Values are strings; a number or boolean (a typed People field such as `isCheckedIn: true`) is accepted and stored as its string.",
                            "type": "object",
                            "additionalProperties": {
                                "type": [
                                    "string",
                                    "number",
                                    "boolean"
                                ]
                            }
                        },
                        "chipsOnAnyTurn": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        },
                        "chipsOnLastMessage": {
                            "type": "boolean"
                        },
                        "textIncludes": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        },
                        "textExcludes": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        },
                        "textMatches": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        },
                        "toolsCalled": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "integer",
                                "minimum": 0
                            }
                        },
                        "toolsNotCalled": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        },
                        "noWarnings": {
                            "type": "boolean"
                        },
                        "maxModelCallsPerTurn": {
                            "type": "integer",
                            "minimum": 1
                        },
                        "maxTurnsToOutcome": {
                            "type": "integer",
                            "minimum": 1
                        },
                        "replyCount": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                                "min": {
                                    "type": "integer",
                                    "minimum": 0
                                },
                                "max": {
                                    "type": "integer",
                                    "minimum": 0
                                }
                            }
                        },
                        "noReplyTo": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "enum": [
                                    "optOut",
                                    "optIn",
                                    "subscribed",
                                    "unsubscribed"
                                ]
                            }
                        },
                        "partsOnLastTurn": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "enum": [
                                    "text",
                                    "card",
                                    "carousel",
                                    "showcase",
                                    "ask.time",
                                    "ask.choice",
                                    "confirm",
                                    "media",
                                    "chips"
                                ]
                            },
                            "maxItems": 9
                        }
                    }
                },
                "judge": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "criteria": {
                            "type": "array",
                            "maxItems": 20,
                            "items": {
                                "type": "object",
                                "additionalProperties": false,
                                "required": [
                                    "id",
                                    "text"
                                ],
                                "properties": {
                                    "id": {
                                        "type": "string",
                                        "pattern": "^[a-z0-9][a-z0-9-]{0,58}$"
                                    },
                                    "text": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 1000
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
