: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(signals): use jeeves for bundled decisions (#111216)
Mikayla Thompson017310759e45
diff --git a/products/signals/backend/system_one_decision.py b/products/signals/backend/system_one_decision.pyindex a0d4989f9257..fdb362d51bb7 100644--- a/products/signals/backend/system_one_decision.py+++ b/products/signals/backend/system_one_decision.py@@ -30,7 +30,8 @@ from products.ml_inference.backend.facade.contracts import ()from products.ml_inference.backend.facade.enums import DecisionQuestionTypefrom products.signals.backend.system_one_prompts import (- DEFAULT_SYSTEM_ONE_MODEL,+ JEEVES_MODEL,+ JEVK_MODEL,SystemOnePrompt,model_experiment_prompt,)@@ -56,7 +57,7 @@ JEV_BUDGET = Budget(burst=2, per_hour=3600)JEV_TEAM_BUDGET = Budget(burst=1, per_hour=1800)SHADOW_MODEL_FLAG = "signals-system-one-shadow-model"SHADOW_MODEL_FLAG_TIMEOUT_SECONDS = 1.0-SHADOW_MODELS = {"jevk": DEFAULT_SYSTEM_ONE_MODEL, "jeeves": "posthog/hogference/jeeves-0.1"}+SHADOW_MODELS = {"jevk": JEVK_MODEL, "jeeves": JEEVES_MODEL}SAFETY_CATEGORIES = {"none": "No matching safety category",@@ -138,7 +139,7 @@ class _ShadowModelExperiment:async def _shadow_model_experiment(team_id: int, trace_id: str, prompt: SystemOnePrompt) -> _ShadowModelExperiment:- if prompt.source != "managed" or prompt.model != DEFAULT_SYSTEM_ONE_MODEL:+ if prompt.source != "managed" or prompt.model != JEVK_MODEL:return _ShadowModelExperiment(prompt=prompt)try:async with asyncio.timeout(SHADOW_MODEL_FLAG_TIMEOUT_SECONDS):diff --git a/products/signals/backend/system_one_prompts.py b/products/signals/backend/system_one_prompts.pyindex 6a67292f0864..4ce136c4f810 100644--- a/products/signals/backend/system_one_prompts.py+++ b/products/signals/backend/system_one_prompts.py@@ -15,8 +15,10 @@ logger = structlog.get_logger(__name__)PROMPT_LABEL = "production"PROMPT_REFRESH_SECONDS = 60-DEFAULT_SYSTEM_ONE_MODEL = "posthog/hogference/jevk5-fp8-0.2"-ALLOWED_SYSTEM_ONE_MODELS = {DEFAULT_SYSTEM_ONE_MODEL, "posthog/hogference/jeeves-0.1"}+JEVK_MODEL = "posthog/hogference/jevk5-fp8-0.2"+JEEVES_MODEL = "posthog/hogference/jeeves-0.1"+DEFAULT_SYSTEM_ONE_MODEL = JEEVES_MODEL+ALLOWED_SYSTEM_ONE_MODELS = {JEVK_MODEL, JEEVES_MODEL}SAFETY_RESPONSE_FIELDS = {"signals-signal-safety-system-one": ("safe", "threat_type", "explanation"),"signals-report-safety-system-one": ("choice", "explanation"),diff --git a/products/signals/backend/test/test_system_one_decision.py b/products/signals/backend/test/test_system_one_decision.pyindex d7e14a0ec568..7af362699d81 100644--- a/products/signals/backend/test/test_system_one_decision.py+++ b/products/signals/backend/test/test_system_one_decision.py@@ -35,7 +35,13 @@ from products.signals.backend.system_one_decision import (model_mode,run_model_decision,)-from products.signals.backend.system_one_prompts import DEFAULT_SYSTEM_ONE_MODEL, SystemOnePrompt, bundled_prompt+from products.signals.backend.system_one_prompts import (+ DEFAULT_SYSTEM_ONE_MODEL,+ JEEVES_MODEL,+ JEVK_MODEL,+ SystemOnePrompt,+ bundled_prompt,+)from products.signals.backend.temporal.safety_filter import SafetyFilterJudgeResponse, safety_filter@@ -179,7 +185,7 @@ async def test_shadow_disagreement_keeps_primary_result_and_records_usage() -> Npatch("products.signals.backend.system_one_decision.posthoganalytics.capture") as capture,patch("products.signals.backend.system_one_decision.decision_api.decide_when_available",- return_value=_actionability_result(),+ return_value=replace(_actionability_result(), model=JEEVES_MODEL),) as decide,):result = await _run_actionability(traditional=primary)@@ -191,7 +197,13 @@ async def test_shadow_disagreement_keeps_primary_result_and_records_usage() -> Nassert properties["system_one_verdict"] is Trueassert properties["deciding_provider"] == "traditional"assert properties["system_one_input_tokens"] == 1000- assert properties["system_one_estimated_cost_usd"] == pytest.approx(0.000042)+ assert properties["system_one_requested_model"] == JEEVES_MODEL+ assert properties["system_one_model"] == JEEVES_MODEL+ assert properties["system_one_prompt_source"] == "bundled"+ assert properties["system_one_model_experiment_status"] == "not_enrolled"+ assert properties["system_one_estimated_cost_usd"] is None+ assert decide.call_count == 1+ assert decide.call_args.args[0].model == JEEVES_MODELtrace_id = properties["signals_decision_id"]assert UUID(trace_id).version == 4assert properties["$ai_trace_id"] == trace_id@@ -205,9 +217,12 @@ async def test_shadow_disagreement_keeps_primary_result_and_records_usage() -> N@pytest.mark.parametrize("variant", ["jevk", "jeeves"])async def test_shadow_model_split_calls_one_model_and_keeps_sonnet_deciding(stage: str, variant: str) -> None:prompt = replace(- bundled_prompt("signals-actionability-issue", "policy", "question", 0.9), source="managed", version=2+ bundled_prompt("signals-actionability-issue", "policy", "question", 0.9),+ model=JEVK_MODEL,+ source="managed",+ version=2,)- model = DEFAULT_SYSTEM_ONE_MODEL if variant == "jevk" else "posthog/hogference/jeeves-0.1"+ model = JEVK_MODEL if variant == "jevk" else JEEVES_MODELselected = replace(prompt, model=model, version=2 if variant == "jevk" else 3)result = DecisionResult(model=model, answers={"actionable": NoulAnswer(probability=0.99)}, input_tokens=100)if stage != "actionability":@@ -255,7 +270,10 @@ async def test_shadow_model_split_calls_one_model_and_keeps_sonnet_deciding(stag@pytest.mark.parametrize("outcome", ["disabled", "invalid_payload", "prompt_unavailable", "flag_error"])async def test_unavailable_shadow_experiment_falls_back_to_one_jevk_call(outcome: str) -> None:prompt = replace(- bundled_prompt("signals-actionability-issue", "policy", "question", 0.9), source="managed", version=2+ bundled_prompt("signals-actionability-issue", "policy", "question", 0.9),+ model=JEVK_MODEL,+ source="managed",+ version=2,)flags = MagicMock()flags.get_flag.return_value = False if outcome == "disabled" else "jeeves"@@ -281,7 +299,7 @@ async def test_unavailable_shadow_experiment_falls_back_to_one_jevk_call(outcome):assert await _run_actionability(prompt=prompt, traditional=AsyncMock(return_value=False)) is Falseassert decide.call_count == 1- assert decide.call_args.args[0].model == DEFAULT_SYSTEM_ONE_MODEL+ assert decide.call_args.args[0].model == JEVK_MODELassert capture.call_args.kwargs["properties"]["system_one_model_experiment_status"] != "assigned"diff --git a/products/signals/backend/test/test_system_one_prompts.py b/products/signals/backend/test/test_system_one_prompts.pyindex 578f23f9d841..f84812b681d7 100644--- a/products/signals/backend/test/test_system_one_prompts.py+++ b/products/signals/backend/test/test_system_one_prompts.py@@ -8,6 +8,7 @@ from posthoganalytics.ai.prompts import PromptResultfrom products.signals.backend.system_one_prompts import (DEFAULT_SYSTEM_ONE_MODEL,+ JEVK_MODEL,SystemOnePrompt,_parse_prompt,_PromptCache,@@ -20,7 +21,8 @@ from products.signals.backend.temporal.report_safety_judge import REPORT_SAFETY_from products.signals.backend.temporal.safety_filter import SIGNAL_SAFETY_SYSTEM_ONE_PROMPT-def test_managed_prompt_keeps_policy_model_question_and_threshold_together() -> None:[email protected]("model", [JEVK_MODEL, DEFAULT_SYSTEM_ONE_MODEL])+def test_managed_prompt_keeps_policy_model_question_and_threshold_together(model: str) -> None:fallback = bundled_prompt("signals-actionability-issue", "old {description}", "old question", 0.85)policy = ("When in doubt, classify as ACTIONABLE.\n"@@ -32,7 +34,7 @@ def test_managed_prompt_keeps_policy_model_question_and_threshold_together() ->name=fallback.name,version=2,prompt=policy,- config={"model": DEFAULT_SYSTEM_ONE_MODEL, "question": "new question", "threshold": 0.91},+ config={"model": model, "question": "new question", "threshold": 0.91},)with (@@ -45,7 +47,7 @@ def test_managed_prompt_keeps_policy_model_question_and_threshold_together() ->assert managed is not Noneassert (managed.policy, managed.model, managed.question, managed.threshold, managed.version, managed.source) == (policy,- DEFAULT_SYSTEM_ONE_MODEL,+ model,"new question",0.91,2,@@ -185,7 +187,7 @@ def test_failed_refresh_reverts_a_managed_safety_prompt_to_bundled() -> None:@pytest.mark.parametrize("changed", [None, "policy", "question", "threshold", "model", "version", "source"])def test_model_experiment_requires_a_model_only_candidate(changed: str | None) -> None:- primary = replace(SIGNAL_SAFETY_SYSTEM_ONE_PROMPT, source="managed", version=2)+ primary = replace(SIGNAL_SAFETY_SYSTEM_ONE_PROMPT, model=JEVK_MODEL, source="managed", version=2)candidate = replace(primary, model="posthog/hogference/jeeves-0.1", version=3)if changed == "policy":candidate = replace(candidate, policy="different policy")