: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 safety through the ai-gateway (#71950)
Brandoneb6c1d08465b
diff --git a/products/signals/backend/temporal/report_safety_judge.py b/products/signals/backend/temporal/report_safety_judge.pyindex a10aa82cf57b..c589c9dec9d5 100644--- a/products/signals/backend/temporal/report_safety_judge.py+++ b/products/signals/backend/temporal/report_safety_judge.py@@ -99,6 +99,7 @@ async def judge_report_safety(validate=validate,thinking=True,stage="report_safety_judge",+ ai_product="signals_safety",)diff --git a/products/signals/backend/temporal/safety_filter.py b/products/signals/backend/temporal/safety_filter.pyindex 0703ede9d614..a3efac7b49af 100644--- a/products/signals/backend/temporal/safety_filter.py+++ b/products/signals/backend/temporal/safety_filter.py@@ -201,6 +201,7 @@ async def safety_filter(user_prompt=description,validate=validate,stage="safety_filter",+ ai_product="signals_safety",)except EmptyLLMResponseError:return SafetyFilterJudgeResponse(diff --git a/products/signals/backend/test/test_safety_filter.py b/products/signals/backend/test/test_safety_filter.pyindex 4b1ea1f7288c..eae934177dbd 100644--- a/products/signals/backend/test/test_safety_filter.py+++ b/products/signals/backend/test/test_safety_filter.py@@ -25,8 +25,9 @@ MODULE_PATH = "products.signals.backend.temporal.safety_filter"async def test_safety_filter_selects_prompt_by_source(source_product, expected_prompt):captured: dict[str, str] = {}- async def fake_call_llm(*, team_id, system_prompt, user_prompt, validate, stage):+ async def fake_call_llm(*, team_id, system_prompt, user_prompt, validate, stage, ai_product, **_kwargs):captured["system_prompt"] = system_prompt+ captured["ai_product"] = ai_productreturn SafetyFilterJudgeResponse(safe=True)with patch(f"{MODULE_PATH}.call_llm", new=fake_call_llm):@@ -34,6 +35,7 @@ async def test_safety_filter_selects_prompt_by_source(source_product, expected_passert result.safe is Trueassert captured["system_prompt"] == expected_prompt+ assert captured["ai_product"] == "signals_safety"@pytest.mark.asyncio