Skip to content

: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.

chore: change model for bk (#120897)

Alex V746d8fdf1401
diff --git a/products/business_knowledge/backend/safety.py b/products/business_knowledge/backend/safety.py
index bff384c0b968..f2330fd0a82a 100644
--- a/products/business_knowledge/backend/safety.py
+++ b/products/business_knowledge/backend/safety.py
@@ -44,7 +44,7 @@ from .models import SafetyVerdict
logger = structlog.get_logger(__name__)
-GEMINI_MODEL = "models/gemini-3-flash-preview"
+GEMINI_MODEL = "models/gemini-3.5-flash-lite"
LLM_CONCURRENCY_LIMIT = 10
LLM_MAX_ATTEMPTS = 3
LLM_CALL_TIMEOUT_SECONDS = 60
@@ -176,6 +176,8 @@ async def _classify_window(
config=types.GenerateContentConfig(
system_instruction=_SAFETY_SYSTEM_INSTRUCTION,
max_output_tokens=256,
+ # thinking_budget=0 is a 400 on this model. MINIMAL is the floor it accepts.
+ thinking_config=types.ThinkingConfig(thinking_level=types.ThinkingLevel.MINIMAL),
),
posthog_distinct_id=team_distinct_id(doc.team_id),
posthog_trace_id=str(doc.document_id),
diff --git a/products/business_knowledge/backend/tests/test_content_safety.py b/products/business_knowledge/backend/tests/test_content_safety.py
index 970303950653..b9ae07f1037f 100644
--- a/products/business_knowledge/backend/tests/test_content_safety.py
+++ b/products/business_knowledge/backend/tests/test_content_safety.py
@@ -7,6 +7,7 @@ from unittest.mock import AsyncMock, patch
from django.test import override_settings
from django.utils import timezone
+from google.genai import types
from parameterized import parameterized
from posthog.models.scoping import team_scope
@@ -252,6 +253,11 @@ class TestSafetyClassifier(BaseTest):
UUID("00000000-0000-0000-0000-000000000001"): SafetyVerdict.SAFE,
UUID("00000000-0000-0000-0000-000000000002"): SafetyVerdict.UNSAFE,
}
+ # thinking_budget=0 is a 400 on this model, so every window would fail closed.
+ call = mk.return_value.models.generate_content.call_args
+ assert call.kwargs["model"] == "models/gemini-3.5-flash-lite"
+ assert call.kwargs["config"].thinking_config.thinking_level == types.ThinkingLevel.MINIMAL
+ assert call.kwargs["config"].thinking_config.thinking_budget is None
@override_settings(GEMINI_API_KEY="test-key")
def test_classify_documents_fails_closed_on_error(self) -> None: