: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): route eval-report signal summaries through the ai-gateway (#93878)
Brandonca284ada2fff
diff --git a/posthog/temporal/ai_observability/eval_reports/emit_signal.py b/posthog/temporal/ai_observability/eval_reports/emit_signal.pyindex 1bfeda74b6b2..37a2a77aa052 100644--- a/posthog/temporal/ai_observability/eval_reports/emit_signal.py+++ b/posthog/temporal/ai_observability/eval_reports/emit_signal.py@@ -130,7 +130,12 @@ def _build_eval_report_signal_prompt(inputs: EmitEvalReportSignalInputs, contentasync def summarize_report_for_signal(inputs: EmitEvalReportSignalInputs, content: dict[str, Any]) -> EvalReportSignalSummary:- """Use the signals LLM to produce a signal-sized summary of a report run."""+ """Use the signals LLM to produce a signal-sized summary of a report run.++ `ai_product` is the Go-gateway opt-in. A call without it routes to the legacy Python+ gateway under the bare `signals` slug. This tag stays separate from the report agent's+ `aio_eval_reports`: a budget denial on one must not stop the other.+ """user_prompt = _build_eval_report_signal_prompt(inputs, content)def validate(text: str) -> EvalReportSignalSummary:@@ -144,6 +149,7 @@ async def summarize_report_for_signal(validate=validate,thinking=True,stage="eval_report_signal_summary",+ ai_product="aio_eval_reports_for_signals",)diff --git a/posthog/temporal/ai_observability/eval_reports/test/test_emit_signal.py b/posthog/temporal/ai_observability/eval_reports/test/test_emit_signal.pyindex 812ce159fa7c..558446433650 100644--- a/posthog/temporal/ai_observability/eval_reports/test/test_emit_signal.py+++ b/posthog/temporal/ai_observability/eval_reports/test/test_emit_signal.py@@ -12,6 +12,7 @@ from posthog.temporal.ai_observability.eval_reports.emit_signal import (EvalReportSignalSummary,_build_eval_report_signal_prompt,emit_eval_report_signal_activity,+ summarize_report_for_signal,)from products.signals.backend.models import SignalSourceConfig@@ -125,6 +126,23 @@ async def _setup_org_not_ai_approved(ateam):)+# `ai_product` is the Go-gateway opt-in. Dropping it reverts this site to the Python gateway+# and unattributes its spend, with no call failing to show it.+async def test_eval_report_summary_opts_in_as_aio_eval_reports_for_signals():+ summary = EvalReportSignalSummary(title="Pass rate dropped", description="d", significance=0.5)+ with patch(+ "posthog.temporal.ai_observability.eval_reports.emit_signal.call_llm",+ new=AsyncMock(return_value=summary),+ ) as summary_call:+ result = await summarize_report_for_signal(_make_inputs(team_id=1), _make_content())++ assert result is summary+ kwargs = summary_call.call_args.kwargs+ assert kwargs["ai_product"] == "aio_eval_reports_for_signals"+ assert kwargs["stage"] == "eval_report_signal_summary"++@pytest.mark.asyncio@pytest.mark.django_dbclass TestEmitEvalReportSignalActivity: