: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
feat(signals): tag eval-fixture generation as signals_eval (#72769)
Brandond3617c92e0c7
diff --git a/products/signals/backend/test/test_llm.py b/products/signals/backend/test/test_llm.pyindex d45445f96810..f7bde62d034b 100644--- a/products/signals/backend/test/test_llm.py+++ b/products/signals/backend/test/test_llm.py@@ -3,7 +3,13 @@ from unittest.mock import AsyncMock, MagicMock, patchfrom django.test import override_settings+from products.signals.backend.temporal.emit_eval_signal import (+ EmitEvalSignalInputs,+ EvalSignalSummary,+ summarize_eval_for_signal,+)from products.signals.backend.temporal.llm import call_llm+from products.signals.eval.llm_gen.client import CanonicalSignal, CanonicalSignalBatch, generate_canonical_signalsMODULE_PATH = "products.signals.backend.temporal.llm"@@ -75,3 +81,44 @@ async def test_without_ai_product_stays_on_python_gateway_even_with_env_set():legacy.assert_called_once()gateway.assert_not_called()assert client.messages.create.call_args.kwargs["extra_headers"] == {"x-posthog-property-ai_stage": "match"}+++# `ai_product` is the opt-in switch, not just a label: dropping it from a call site silently+# reverts that site to the Python gateway and unattributes its spend, with no failing call to+# notice. Each site that opts in pins its own tag and stage.+++async def test_eval_fixture_generation_opts_in_as_signals_eval():+ batch = CanonicalSignalBatch(signals=[CanonicalSignal(title="a" * 10, body="b" * 20)])+ with patch("products.signals.eval.llm_gen.client.call_llm", new=AsyncMock(return_value=batch)) as generation_call:+ await generate_canonical_signals(team_id=1, system_prompt="s", user_prompt="u")++ kwargs = generation_call.call_args.kwargs+ assert kwargs["ai_product"] == "signals_eval"+ assert kwargs["stage"] == "eval_signal_generation"+++async def test_eval_signal_summary_opts_in_as_signals_eval():+ inputs = EmitEvalSignalInputs(+ team_id=1,+ evaluation_id="eval-1",+ evaluation_name="name",+ evaluation_prompt="prompt",+ event_uuid="event-1",+ event_type="generation",+ trace_id="trace-1",+ reasoning="reasoning",+ model="claude-sonnet-4-5",+ provider="anthropic",+ )+ summary = EvalSignalSummary(title="t", description="d", significance=0.5)+ with patch(+ "products.signals.backend.temporal.emit_eval_signal.call_llm", new=AsyncMock(return_value=summary)+ ) as summary_call:+ await summarize_eval_for_signal(inputs)++ kwargs = summary_call.call_args.kwargs+ assert kwargs["ai_product"] == "signals_eval"+ assert kwargs["stage"] == "eval_signal_summary"diff --git a/products/signals/eval/llm_gen/client.py b/products/signals/eval/llm_gen/client.pyindex 14a2f4832a3f..46b86292091c 100644--- a/products/signals/eval/llm_gen/client.py+++ b/products/signals/eval/llm_gen/client.py@@ -43,7 +43,8 @@ async def generate_canonical_signals(Reuses `call_llm` from products.signals.backend.temporal.llm so we get thesame retry-on-validation-failure behavior the rest of the pipeline uses.Model is controlled by the SIGNAL_MATCHING_LLM_MODEL env var (default- claude-sonnet-4-5). LLM cost is attributed to team_id via the gateway.+ claude-sonnet-4-5). LLM cost is attributed to team_id via the gateway and+ tagged `signals_eval`, alongside the eval summary stage."""batch = await call_llm(team_id=team_id,@@ -52,5 +53,6 @@ async def generate_canonical_signals(validate=_validator(CanonicalSignalBatch),temperature=temperature,stage="eval_signal_generation",+ ai_product="signals_eval",)return batch.signals