: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(aio): tell agents how to get LLM judges running without a key (#128104)
Bernat Torreseefad89621a2
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex b4bc88312359..f469db887f81 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -1905,9 +1905,9 @@ snapshots:components-mcp-hint-toast--sql-execute--light:hash: v1.k794b7964.074a12be4bb4b4e8d0e96dfb2b204e18690ad62d12a402c5d32baf83aa923d58.Lm28qnogGZySU6YYFH4LxDZhNyMlrk5N3PwlwWa4CB0components-mcp-use-case-card--ai-observability-evaluations-create--dark:- hash: v1.k794b7964.5a1e361a3242cc8f8672541d005c98a6f1cda72443cb5601cdbcc4880fa1de4a.AYrcEOBeXQOHiHPLfv4Z-0wPzzoga_TWMjdq2oaRvRI+ hash: v1.k794b7964.937b1bd9fca1facf1588992cf7ad79eb12455c5c30455163f383f02fc3aea5fd.AoZo4BbPEVhhOhr1cGOHYOFg_OcSWMrqH5rcXW8blWYcomponents-mcp-use-case-card--ai-observability-evaluations-create--light:- hash: v1.k794b7964.41d3d7390ef9fae277a9a563fbfd5083e2537e7b1348b577c0f3fa54c8e73065.pRYc3leMTvb82ob3AI_-YrjV3bS-eF92RsXmtVErpmo+ hash: v1.k794b7964.7f1fe4358cb1f7a55ae13dee39888d7429ddec56f82fe61db9128e7631ee76f0.kVBmsSuAVFHUdgfuZX8JUuM3l5XHarGa8oYDA3rjv8gcomponents-mcp-use-case-card--dashboards-create--dark:hash: v1.k794b7964.882b81373f07d8e8ba905e72da374b487bbca22689cc1988da41a710976b8cdc.iILpg7P0SDKzpVtX6XOKCm5jRLBI83TF2NdsFrZBrFIcomponents-mcp-use-case-card--dashboards-create--light:diff --git a/frontend/src/lib/components/MCPHint/prompts.ts b/frontend/src/lib/components/MCPHint/prompts.tsindex 29783d7418d2..55c915d58458 100644--- a/frontend/src/lib/components/MCPHint/prompts.ts+++ b/frontend/src/lib/components/MCPHint/prompts.ts@@ -30,7 +30,7 @@ export type SurfacePrompts = {}const AI_OBSERVABILITY_EVALUATION_PROMPT =- "Use the connected PostHog MCP server and this project's AI observability data to inspect recent traces. Identify and rank real failure modes, with an example trace for each. Recommend one evaluation per failure mode, and say whether it should return pass/fail, a score, or categories. Ask which ones I want before creating anything. Create them disabled, test each on a few recent generations, and show me the results before enabling."+ "Use the connected PostHog MCP server and this project's AI observability data to inspect recent traces. Identify and rank real failure modes, with an example trace for each. Recommend one evaluation per failure mode, and say whether it should return pass/fail, a score, or categories. If this project has no AI provider key, still create the LLM judges and tell me how to add a key so they can run. Ask which ones I want before creating anything. Create them disabled, test each on a few recent generations, and show me the results before enabling."export const FALLBACK_PROMPTS: Record<SurfaceKey, SurfacePrompts> = {'feature_flags.create': {diff --git a/products/ai_observability/backend/api/evaluations.py b/products/ai_observability/backend/api/evaluations.pyindex a8f971a1d99f..4745c1940b89 100644--- a/products/ai_observability/backend/api/evaluations.py+++ b/products/ai_observability/backend/api/evaluations.py@@ -821,17 +821,18 @@ class EvaluationSerializer(UserAccessControlSerializerMixin, serializers.ModelSeconfig's active-key fallback, is already handled by `_validate_can_run`; this covers whatis left: a null config resolves via the team's active key, and anything else must add aprovider key of its own."""- add_key_message = "Add a provider API key to enable this evaluation."team = self.context["get_team"]()config = EvaluationConfig.objects.filter(team=team).first()explicit_config = self._effective_model_configuration(data)if explicit_config is not None:- raise serializers.ValidationError({"enabled": add_key_message})+ raise serializers.ValidationError(+ {"enabled": self._missing_key_message(team, explicit_config.get("provider"))}+ )active_key = config.active_provider_key if config else Noneif active_key is None:- raise serializers.ValidationError({"enabled": add_key_message})+ raise serializers.ValidationError({"enabled": self._missing_key_message(team, None)})if active_key.state != LLMProviderKey.State.OK:raise serializers.ValidationError(@@ -844,6 +845,22 @@ class EvaluationSerializer(UserAccessControlSerializerMixin, serializers.ModelSe})+ def _missing_key_message(self, team: Team, provider: str | None) -> str:+ """A team with a working key the eval isn't set to use needs to pick it, not add another one."""+ keys = LLMProviderKey.objects.filter(team=team, state=LLMProviderKey.State.OK)+ if provider:+ keys = keys.filter(provider=provider)+ if keys.exists():+ return (+ "This project has a working AI provider API key, but this evaluation isn't set to use it. "+ "Choose that key for the evaluation's model, or make it the project's active key, then enable the evaluation."+ )+ return (+ "LLM judges run on your own AI provider API key, and this project doesn't have a working one yet. "+ "A project admin can add one in Settings > AI observability > Bring your own key (BYOK), "+ "then enable this evaluation."+ )+def _effective_model_configuration(self, data: dict) -> dict[str, Any] | None:"""The explicit model configuration the evaluation will have after this update, or Nonewhen it defers to the team default (null config). Payload presence wins because an explicitdiff --git a/products/ai_observability/backend/api/test/test_evaluations.py b/products/ai_observability/backend/api/test/test_evaluations.pyindex d4a88f9e76e6..da7a5a003eba 100644--- a/products/ai_observability/backend/api/test/test_evaluations.py+++ b/products/ai_observability/backend/api/test/test_evaluations.py@@ -2177,11 +2177,15 @@ class TestEnableBlockingWhenKeyRequired(APIBaseTest):@parameterized.expand([- ("explicit_config", True),- ("null_config", False),+ ("explicit_config_no_key", True, False, "doesn't have a working one yet"),+ ("null_config_no_key", False, False, "doesn't have a working one yet"),+ ("explicit_config_unused_key", True, True, "isn't set to use it"),+ ("null_config_unused_key", False, True, "isn't set to use it"),])- def test_blocks_enabling_keyless_eval_without_key(self, _name, explicit_config):+ def test_blocks_enabling_keyless_eval_without_key(self, _name, explicit_config, has_unused_key, expected):+ if has_unused_key:+ self._create_active_key()eval_obj = (self._create_keyless_eval() if explicit_config else self._create_keyless_eval(model_configuration=None))@@ -2189,7 +2193,7 @@ class TestEnableBlockingWhenKeyRequired(APIBaseTest):response = self._enable(eval_obj)self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)- self.assertIn("Add a provider API key", str(response.data))+ self.assertIn(expected, str(response.data))eval_obj.refresh_from_db()self.assertFalse(eval_obj.enabled)@@ -2249,7 +2253,7 @@ class TestEnableBlockingWhenKeyRequired(APIBaseTest):)self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)- self.assertIn("Add a provider API key", str(response.data))+ self.assertIn("doesn't have a working one yet", str(response.data))self.assertEqual(Evaluation.objects.filter(name="Doomed Eval").count(), 0)def test_allows_enabling_hog_eval_without_key(self):diff --git a/products/ai_observability/mcp/tools.yaml b/products/ai_observability/mcp/tools.yamlindex 714c91bf3588..265d538ef646 100644--- a/products/ai_observability/mcp/tools.yaml+++ b/products/ai_observability/mcp/tools.yaml@@ -567,19 +567,23 @@ tools:title: Create evaluationdescription: >Create an evaluation. 'llm_judge': set evaluation_config.prompt and model_configuration with provider and- model; provider_key_id may be null when no key is pinned. 'hog': evaluation_config.source (Hog returning a- boolean, a finite number, or category keys). For 'hog' and 'llm_judge', choose output_type='boolean',- 'numeric', or 'categorical'; numeric output_config accepts min, max, step, allows_na, and passing_rule;- categorical output_config accepts options, selection_mode, allows_na, and passing_rule. 'sentiment':- output_type='sentiment', omit model_configuration, optional evaluation_config.source='user_messages'. To tag- or classify generations into labels (what taggers used to do), use output_type='categorical' with- selection_mode='multiple'. `target` accepts 'generation' (default), 'trace', or 'session'. A session target- runs once per `$ai_session_id` and defaults to the 'inactivity' settle strategy. Pass `enabled` as a boolean- (true to start scoring new $ai_generation events immediately, false to create it paused). To organize the- evaluation, pass a `directory_id` returned by llma-evaluation-directory-list. Omit `directory_id` or pass- null to keep it at the top level. Results are '$ai_evaluation' events. An evaluation only scores data that- arrives after it is enabled, so once it is enabled, offer the user a backfill over past data with- llma-evaluation-backfill-estimate.+ model; provider_key_id may be null when no key is pinned. An llm_judge runs on one of the team's own AI+ provider keys, and keys can't be added through MCP. Check llma-evaluation-config-get and+ llma-provider-key-list first: pin an ok-state key with provider_key_id when one exists. With no usable key,+ still create the judge with enabled=false, and tell the user it starts scoring once a project admin adds a+ key in Settings > AI observability > Bring your own key (BYOK) and enables it. 'hog':+ evaluation_config.source (Hog returning a boolean, a finite number, or category keys). For 'hog' and+ 'llm_judge', choose output_type='boolean', 'numeric', or 'categorical'; numeric output_config accepts min,+ max, step, allows_na, and passing_rule; categorical output_config accepts options, selection_mode,+ allows_na, and passing_rule. 'sentiment': output_type='sentiment', omit model_configuration, optional+ evaluation_config.source='user_messages'. To tag or classify generations into labels (what taggers used to+ do), use output_type='categorical' with selection_mode='multiple'. `target` accepts 'generation' (default),+ 'trace', or 'session'. A session target runs once per `$ai_session_id` and defaults to the 'inactivity'+ settle strategy. Pass `enabled` as a boolean (true to start scoring new $ai_generation events immediately,+ false to create it paused). To organize the evaluation, pass a `directory_id` returned by+ llma-evaluation-directory-list. Omit `directory_id` or pass null to keep it at the top level. Results are+ '$ai_evaluation' events. An evaluation only scores data that arrives after it is enabled, so once it is+ enabled, offer the user a backfill over past data with llma-evaluation-backfill-estimate.llma-evaluation-delete:operation: evaluations_destroyenabled: truediff --git a/products/ai_observability/skills/creating-online-evaluations/SKILL.md b/products/ai_observability/skills/creating-online-evaluations/SKILL.mdindex ea8530e49e46..28ca58194a14 100644--- a/products/ai_observability/skills/creating-online-evaluations/SKILL.md+++ b/products/ai_observability/skills/creating-online-evaluations/SKILL.md@@ -265,9 +265,15 @@ Prefer pinning the chosen key so a later team-wide active-key change does not chLeave `provider_key_id` as `null` to run on the team's active key; before enabling, confirm with`llma-evaluation-config-get` that the active key is usable and its provider matches.-No usable key does not block creation. Create the disabled draft with a valid `provider` and `model` for-the user to review. Do not spot-run or enable it, and ask the user to add or validate a key in the UI so it-can be enabled later.+No usable key does not block creating the judge. Keys cannot be added through MCP, so:++- If the team has an `ok` key that the judge isn't set to use, pin it with `provider_key_id` instead of asking+ for a new one.+- If the team has no usable key, still create the judge with `enabled: false`. Do not spot-run or enable it.+- Tell the user plainly that the judge starts scoring once a project admin adds a key in Settings > AI+ observability > Bring your own key (BYOK) and enables it. A judge left disabled with no word to the user+ never runs, so this message is part of the job, including when a create with `enabled: true` is rejected+ for a missing key and you retry it disabled.### 2.4 — Create it disableddiff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 27e305719f9b..434bcac0eb54 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -9038,7 +9038,7 @@}},"llma-evaluation-create": {- "description": "Create an evaluation. 'llm_judge': set evaluation_config.prompt and model_configuration with provider and model; provider_key_id may be null when no key is pinned. 'hog': evaluation_config.source (Hog returning a boolean, a finite number, or category keys). For 'hog' and 'llm_judge', choose output_type='boolean', 'numeric', or 'categorical'; numeric output_config accepts min, max, step, allows_na, and passing_rule; categorical output_config accepts options, selection_mode, allows_na, and passing_rule. 'sentiment': output_type='sentiment', omit model_configuration, optional evaluation_config.source='user_messages'. To tag or classify generations into labels (what taggers used to do), use output_type='categorical' with selection_mode='multiple'. `target` accepts 'generation' (default), 'trace', or 'session'. A session target runs once per `$ai_session_id` and defaults to the 'inactivity' settle strategy. Pass `enabled` as a boolean (true to start scoring new $ai_generation events immediately, false to create it paused). To organize the evaluation, pass a `directory_id` returned by llma-evaluation-directory-list. Omit `directory_id` or pass null to keep it at the top level. Results are '$ai_evaluation' events. An evaluation only scores data that arrives after it is enabled, so once it is enabled, offer the user a backfill over past data with llma-evaluation-backfill-estimate.",+ "description": "Create an evaluation. 'llm_judge': set evaluation_config.prompt and model_configuration with provider and model; provider_key_id may be null when no key is pinned. An llm_judge runs on one of the team's own AI provider keys, and keys can't be added through MCP. Check llma-evaluation-config-get and llma-provider-key-list first: pin an ok-state key with provider_key_id when one exists. With no usable key, still create the judge with enabled=false, and tell the user it starts scoring once a project admin adds a key in Settings > AI observability > Bring your own key (BYOK) and enables it. 'hog': evaluation_config.source (Hog returning a boolean, a finite number, or category keys). For 'hog' and 'llm_judge', choose output_type='boolean', 'numeric', or 'categorical'; numeric output_config accepts min, max, step, allows_na, and passing_rule; categorical output_config accepts options, selection_mode, allows_na, and passing_rule. 'sentiment': output_type='sentiment', omit model_configuration, optional evaluation_config.source='user_messages'. To tag or classify generations into labels (what taggers used to do), use output_type='categorical' with selection_mode='multiple'. `target` accepts 'generation' (default), 'trace', or 'session'. A session target runs once per `$ai_session_id` and defaults to the 'inactivity' settle strategy. Pass `enabled` as a boolean (true to start scoring new $ai_generation events immediately, false to create it paused). To organize the evaluation, pass a `directory_id` returned by llma-evaluation-directory-list. Omit `directory_id` or pass null to keep it at the top level. Results are '$ai_evaluation' events. An evaluation only scores data that arrives after it is enabled, so once it is enabled, offer the user a backfill over past data with llma-evaluation-backfill-estimate.","category": "AI observability","feature": "llm_analytics","summary": "Create evaluation",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 61182085e691..8eaef8eb5aa9 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -9304,7 +9304,7 @@}},"llma-evaluation-create": {- "description": "Create an evaluation. 'llm_judge': set evaluation_config.prompt and model_configuration with provider and model; provider_key_id may be null when no key is pinned. 'hog': evaluation_config.source (Hog returning a boolean, a finite number, or category keys). For 'hog' and 'llm_judge', choose output_type='boolean', 'numeric', or 'categorical'; numeric output_config accepts min, max, step, allows_na, and passing_rule; categorical output_config accepts options, selection_mode, allows_na, and passing_rule. 'sentiment': output_type='sentiment', omit model_configuration, optional evaluation_config.source='user_messages'. To tag or classify generations into labels (what taggers used to do), use output_type='categorical' with selection_mode='multiple'. `target` accepts 'generation' (default), 'trace', or 'session'. A session target runs once per `$ai_session_id` and defaults to the 'inactivity' settle strategy. Pass `enabled` as a boolean (true to start scoring new $ai_generation events immediately, false to create it paused). To organize the evaluation, pass a `directory_id` returned by llma-evaluation-directory-list. Omit `directory_id` or pass null to keep it at the top level. Results are '$ai_evaluation' events. An evaluation only scores data that arrives after it is enabled, so once it is enabled, offer the user a backfill over past data with llma-evaluation-backfill-estimate.",+ "description": "Create an evaluation. 'llm_judge': set evaluation_config.prompt and model_configuration with provider and model; provider_key_id may be null when no key is pinned. An llm_judge runs on one of the team's own AI provider keys, and keys can't be added through MCP. Check llma-evaluation-config-get and llma-provider-key-list first: pin an ok-state key with provider_key_id when one exists. With no usable key, still create the judge with enabled=false, and tell the user it starts scoring once a project admin adds a key in Settings > AI observability > Bring your own key (BYOK) and enables it. 'hog': evaluation_config.source (Hog returning a boolean, a finite number, or category keys). For 'hog' and 'llm_judge', choose output_type='boolean', 'numeric', or 'categorical'; numeric output_config accepts min, max, step, allows_na, and passing_rule; categorical output_config accepts options, selection_mode, allows_na, and passing_rule. 'sentiment': output_type='sentiment', omit model_configuration, optional evaluation_config.source='user_messages'. To tag or classify generations into labels (what taggers used to do), use output_type='categorical' with selection_mode='multiple'. `target` accepts 'generation' (default), 'trace', or 'session'. A session target runs once per `$ai_session_id` and defaults to the 'inactivity' settle strategy. Pass `enabled` as a boolean (true to start scoring new $ai_generation events immediately, false to create it paused). To organize the evaluation, pass a `directory_id` returned by llma-evaluation-directory-list. Omit `directory_id` or pass null to keep it at the top level. Results are '$ai_evaluation' events. An evaluation only scores data that arrives after it is enabled, so once it is enabled, offer the user a backfill over past data with llma-evaluation-backfill-estimate.","category": "AI observability","feature": "llm_analytics","summary": "Create evaluation",