: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(tasks): route custom image scans through GLM policy (#73111)
Alessandro Pogliaghif831b553abeb
diff --git a/products/tasks/backend/temporal/build_image/activities.py b/products/tasks/backend/temporal/build_image/activities.pyindex 79cae883faa0..0aa8b6d18cdb 100644--- a/products/tasks/backend/temporal/build_image/activities.py+++ b/products/tasks/backend/temporal/build_image/activities.py@@ -11,6 +11,8 @@ from temporalio import activityif TYPE_CHECKING:import modal+ from posthog.llm.gateway_client import Product+from posthog.temporal.common.utils import asyncifyfrom products.tasks.backend.logic.services.image_spec import (@@ -26,6 +28,7 @@ from products.tasks.backend.temporal.observability import log_activity_executionlogger = logging.getLogger(__name__)SCAN_JUDGE_MODEL = "@cf/zai-org/glm-5.2"+SCAN_JUDGE_PRODUCT: "Product" = "posthog_code"SCAN_JUDGE_SYSTEM_PROMPT = """You are a security judge reviewing a declarative sandbox image spec before it is built and published.@@ -108,7 +111,7 @@ def _judge_spec_safety(spec_yaml: str, team_id: int, repository: str = "") -> Scif repositoryelse "")- client = get_llm_client(product="django", team_id=team_id)+ client = get_llm_client(product=SCAN_JUDGE_PRODUCT, team_id=team_id)response = client.chat.completions.create(model=SCAN_JUDGE_MODEL,messages=[diff --git a/products/tasks/backend/temporal/build_image/test_activities.py b/products/tasks/backend/temporal/build_image/test_activities.pyindex 332fff4d0f7c..ec35a2ce51c9 100644--- a/products/tasks/backend/temporal/build_image/test_activities.py+++ b/products/tasks/backend/temporal/build_image/test_activities.py@@ -4,6 +4,7 @@ from parameterized import parameterizedfrom products.tasks.backend.temporal.build_image.activities import (SCAN_JUDGE_MODEL,+ SCAN_JUDGE_PRODUCT,_judge_spec_safety,_parse_scan_verdict,)@@ -36,7 +37,7 @@ def test_security_scan_uses_glm_json_output(mock_get_llm_client: MagicMock) -> Nassert result.passed is Trueassert result.findings == [{"severity": "low", "detail": "Pinned development tool"}]- mock_get_llm_client.assert_called_once_with(product="django", team_id=42)+ mock_get_llm_client.assert_called_once_with(product=SCAN_JUDGE_PRODUCT, team_id=42)request = mock_get_llm_client.return_value.chat.completions.create.call_args.kwargsassert request["model"] == SCAN_JUDGE_MODELassert request["response_format"] == {"type": "json_object"}