Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

19.6 KB
Raw Blame
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "description": "An evaluation that scores LLM generations, traces, or sessions.",
    "properties": {
        "conditions": {
            "description": "Trigger conditions that filter which events are evaluated. OR between condition sets, AND within each. Each set is {id, rollout_percentage, properties[]} — `rollout_percentage` (0-100, defaults to 100) is the sampling field the dispatcher reads.",
            "items": {
                "description": "A trigger condition set controlling which generations an evaluation runs on.",
                "properties": {
                    "id": {
                        "description": "Stable identifier for this condition set.",
                        "maxLength": 100,
                        "type": "string"
                    },
                    "properties": {
                        "description": "Property filters (event or person) that scope which generations match this condition set.",
                        "items": {
                            "additionalProperties": {},
                            "propertyNames": {
                                "type": "string"
                            },
                            "type": "object"
                        },
                        "type": "array"
                    },
                    "rollout_percentage": {
                        "default": 100,
                        "description": "Percentage (0-100) of matching events to sample for this evaluation. Defaults to 100.",
                        "maximum": 100,
                        "minimum": 0,
                        "type": "number"
                    }
                },
                "required": ["id"],
                "type": "object"
            },
            "type": "array"
        },
        "deleted": {
            "description": "Set to true to soft-delete the evaluation.",
            "type": "boolean"
        },
        "description": {
            "description": "Optional description of what this evaluation checks.",
            "type": "string"
        },
        "directory_id": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "description": "Directory containing the evaluation. Pass null to move the evaluation to the top level."
        },
        "enabled": {
            "description": "Whether the evaluation runs automatically on new $ai_generation events.",
            "type": "boolean"
        },
        "evaluation_config": {
            "anyOf": [
                {
                    "properties": {
                        "include_media": {
                            "description": "Set to false to judge text only.",
                            "type": "boolean"
                        },
                        "judge_method": {
                            "anyOf": [
                                {
                                    "enum": ["llm", "decision"],
                                    "type": "string"
                                },
                                {
                                    "type": "null"
                                }
                            ],
                            "description": "Judge method. Omit to keep the saved method; null restores automatic routing."
                        },
                        "prompt": {
                            "description": "Evaluation criteria for the LLM judge. Describe what makes a good vs bad response.",
                            "minLength": 1,
                            "type": "string"
                        },
                        "reasoning_level": {
                            "anyOf": [
                                {
                                    "enum": ["minimal", "low", "medium", "high"],
                                    "type": "string"
                                },
                                {
                                    "type": "null"
                                }
                            ],
                            "description": "How much the judge model reasons before it answers. Only Anthropic and OpenAI reasoning models with the 'llm' judge method support it. Omit to keep the saved level; null uses the model's default."
                        }
                    },
                    "required": ["prompt"],
                    "type": "object"
                },
                {
                    "properties": {
                        "source": {
                            "description": "Hog source code. Return a boolean, finite number, or category keys matching output_type. Categorical single selection accepts one key or a one-item list; multiple selection accepts a list, including []. Return null only for allowed N/A. Output settings determine which boolean counts as a failure.",
                            "minLength": 1,
                            "type": "string"
                        }
                    },
                    "required": ["source"],
                    "type": "object"
                },
                {
                    "properties": {
                        "source": {
                            "default": "user_messages",
                            "description": "Classify sentiment from user messages in the generation input. The classifier is trained on English, so labels are unreliable for other languages; use an 'llm_judge' evaluation for multilingual agents.",
                            "enum": ["user_messages"],
                            "type": "string"
                        }
                    },
                    "type": "object"
                }
            ],
            "description": "Configuration dict. For 'llm_judge': {prompt}; for 'hog': {source}; for 'sentiment': {source: 'user_messages'}."
        },
        "evaluation_type": {
            "description": "'llm_judge' uses an LLM to score outputs against a prompt; 'hog' runs deterministic Hog code; 'sentiment' classifies user-message sentiment (trained on English, so use 'llm_judge' for multilingual agents).\n\n* `llm_judge` - LLM as a judge\n* `hog` - Hog\n* `sentiment` - Sentiment analysis",
            "enum": ["llm_judge", "hog", "sentiment"],
            "type": "string"
        },
        "model_configuration": {
            "anyOf": [
                {
                    "description": "Nested serializer for model configuration.",
                    "properties": {
                        "model": {
                            "maxLength": 100,
                            "type": "string"
                        },
                        "provider": {
                            "description": "* `openai` - Openai\n* `anthropic` - Anthropic\n* `gemini` - Gemini\n* `openrouter` - Openrouter\n* `fireworks` - Fireworks\n* `azure_openai` - Azure OpenAI\n* `together_ai` - Together AI\n* `minimax` - MiniMax\n* `system_one` - System One\n* `openai_compatible` - OpenAI-compatible",
                            "enum": [
                                "openai",
                                "anthropic",
                                "gemini",
                                "openrouter",
                                "fireworks",
                                "azure_openai",
                                "together_ai",
                                "minimax",
                                "system_one",
                                "openai_compatible"
                            ],
                            "type": "string"
                        },
                        "provider_key_id": {
                            "anyOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "null"
                                }
                            ],
                            "description": "Optional team provider key to run this evaluation with; it must use the same provider. May be null when no key is pinned or after the selected key is removed."
                        },
                        "provider_key_name": {
                            "anyOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "null"
                                }
                            ]
                        }
                    },
                    "required": ["provider", "model"],
                    "type": "object"
                },
                {
                    "type": "null"
                }
            ],
            "description": "Provider and model for an llm_judge evaluation. Required when creating or switching to llm_judge. To add or replace a model, provide both provider and model. On an existing configured llm_judge, omit this field to keep the current model; null is rejected. When switching an llm_judge to hog or sentiment, set this field to null. Legacy llm_judge evaluations without a model remain editable without adding one. The nested provider_key_id may be null."
        },
        "name": {
            "description": "Name of the evaluation.",
            "maxLength": 400,
            "type": "string"
        },
        "output_config": {
            "description": "Output config. For 'boolean' output_type: {allows_na} to permit N/A results, and {true_is_failure} to declare that a true result means the evaluation found a problem. For boolean decision-model judges, decision_threshold is a probability from 0 to 1 (default 0.5). For 'numeric': only min/max/step, allows_na, and passing_rule {operator: 'gte'|'lte', threshold}. For 'categorical': options [{key, label}], selection_mode (single or multiple), allows_na, and optional passing_rule {categories: [key]}. Do not send true_is_failure for numeric or categorical output. For 'sentiment': {}.",
            "properties": {
                "allows_na": {
                    "description": "Whether the evaluation can return N/A for non-applicable generations.",
                    "type": "boolean"
                },
                "decision_threshold": {
                    "anyOf": [
                        {
                            "maximum": 1,
                            "minimum": 0,
                            "type": "number"
                        },
                        {
                            "type": "null"
                        }
                    ],
                    "description": "Boolean decision-model judges only. Minimum probability of true required for a true result, inclusive. Omit or set null to use 0.5. Applies to new runs; historical results are unchanged."
                },
                "max": {
                    "anyOf": [
                        {
                            "type": "number"
                        },
                        {
                            "type": "null"
                        }
                    ],
                    "description": "Inclusive maximum numeric score. Omit for no upper bound. Required for numeric decision models and must exceed min."
                },
                "min": {
                    "anyOf": [
                        {
                            "type": "number"
                        },
                        {
                            "type": "null"
                        }
                    ],
                    "description": "Inclusive minimum numeric score. Omit for no lower bound. Required for numeric decision models."
                },
                "options": {
                    "description": "Categorical output options. Keys identify stored results; labels are displayed to users.",
                    "items": {
                        "properties": {
                            "key": {
                                "description": "Stable category key.",
                                "maxLength": 128,
                                "minLength": 1,
                                "pattern": "^[a-z0-9]+(?:[_-][a-z0-9]+)*$",
                                "type": "string"
                            },
                            "label": {
                                "description": "Category display label.",
                                "maxLength": 256,
                                "minLength": 1,
                                "type": "string"
                            }
                        },
                        "required": ["key", "label"],
                        "type": "object"
                    },
                    "maxItems": 100,
                    "minItems": 1,
                    "type": "array"
                },
                "passing_rule": {
                    "anyOf": [
                        {
                            "properties": {
                                "operator": {
                                    "description": "Pass at or above (gte), or at or below (lte), the threshold.",
                                    "enum": ["gte", "lte"],
                                    "type": "string"
                                },
                                "threshold": {
                                    "description": "Finite passing threshold within any configured score bounds.",
                                    "type": "number"
                                }
                            },
                            "required": ["operator", "threshold"],
                            "type": "object"
                        },
                        {
                            "properties": {
                                "categories": {
                                    "description": "Passing category keys. With keys selected, results must be non-empty and contain only these keys. If no passing keys are selected, only an empty result passes.",
                                    "items": {
                                        "type": "string"
                                    },
                                    "type": "array"
                                }
                            },
                            "required": ["categories"],
                            "type": "object"
                        },
                        {
                            "type": "null"
                        }
                    ],
                    "description": "Optional numeric or categorical passing rule. Null removes the rule; historical results use the current rule."
                },
                "selection_mode": {
                    "description": "Select one category or multiple categories. Multiple selection allows an empty result. Defaults to single.",
                    "enum": ["single", "multiple"],
                    "type": "string"
                },
                "step": {
                    "anyOf": [
                        {
                            "exclusiveMinimum": 0,
                            "type": "number"
                        },
                        {
                            "type": "null"
                        }
                    ],
                    "description": "Optional positive input increment. Does not round evaluation results."
                },
                "true_is_failure": {
                    "description": "Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail.",
                    "type": "boolean"
                }
            },
            "type": "object"
        },
        "output_type": {
            "description": "Output format: 'boolean', 'numeric' for a finite score, 'categorical' for category keys, or 'sentiment' for sentiment analysis.\n\n* `boolean` - Boolean (Pass/Fail)\n* `numeric` - Numeric\n* `categorical` - Categorical\n* `sentiment` - Sentiment",
            "enum": ["boolean", "numeric", "categorical", "sentiment"],
            "type": "string"
        },
        "target": {
            "description": "What the evaluation runs on. 'generation' evaluates each matching $ai_generation event individually. 'trace' evaluates the whole trace once and 'session' the whole $ai_session_id session once: the first matching generation schedules a run that waits for the unit to settle, then evaluates all of its events together. Condition filters still match individual generations — a unit is evaluated when any of its generations matches, and sampling applies per unit. A 'session' evaluation only fires for generations that carry $ai_session_id. When and how the run fires is controlled by target_config's settle strategy.\n\n* `generation` - Generation\n* `trace` - Trace\n* `session` - Session",
            "enum": ["generation", "trace", "session"],
            "type": "string"
        },
        "target_config": {
            "description": "Target-specific config. Send {} or omit it for 'generation'. For 'trace' and 'session' targets: a settle config, either 'fixed_window' {window_seconds} or 'inactivity' {quiet_period_seconds, max_age_seconds}. Omit `strategy` to use the target's default. The server fills in any other field you omit, using per-target defaults, and the accepted bounds also depend on `target`.",
            "properties": {
                "max_age_seconds": {
                    "description": "inactivity only. Hard cap in seconds on the total wait from the first matching generation, even if the unit stays active. Must be at least quiet_period_seconds. The accepted range depends on `target`: 60–7200 for 'trace', 60–604800 for 'session'. The default also depends on `target`; see the field-level help_text.",
                    "maximum": 604800,
                    "minimum": 60,
                    "type": "number"
                },
                "quiet_period_seconds": {
                    "description": "inactivity only. Seconds without new activity before the unit counts as settled. The accepted range depends on `target`: 10–1800 for 'trace', 10–86400 for 'session'. The default also depends on `target`; see the field-level help_text.",
                    "maximum": 86400,
                    "minimum": 10,
                    "type": "number"
                },
                "strategy": {
                    "description": "'fixed_window' waits a fixed window after the first matching generation, then evaluates. 'inactivity' evaluates once the unit has had no new activity for the quiet period. Omit it to use the target's default: 'fixed_window' for 'trace', 'inactivity' for 'session'.",
                    "enum": ["fixed_window", "inactivity"],
                    "type": "string"
                },
                "window_seconds": {
                    "description": "fixed_window only. Seconds to wait after the first matching generation before evaluating the whole unit. Captured when the run is scheduled — editing it does not change runs already in flight. The accepted range depends on `target`: 10–7200 for 'trace', 10–604800 for 'session'. The default also depends on `target`; see the field-level help_text.",
                    "maximum": 604800,
                    "minimum": 10,
                    "type": "number"
                }
            },
            "type": "object"
        }
    },
    "required": ["name", "evaluation_type", "output_type"],
    "type": "object"
}