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.

feat(llm-gateway): add changelog bot to llm gateway routes (#73573)

Sarah Sanderscc799f66104c
diff --git a/services/llm-gateway/src/llm_gateway/config.py b/services/llm-gateway/src/llm_gateway/config.py
index 050ef2f04091..a1e7bf06215a 100644
--- a/services/llm-gateway/src/llm_gateway/config.py
+++ b/services/llm-gateway/src/llm_gateway/config.py
@@ -34,6 +34,7 @@ DEFAULT_PRODUCT_COST_LIMITS: dict[str, "ProductCostLimit"] = {
"custom_image_scans": ProductCostLimit(limit_usd=1000.0, window_seconds=86400),
"signals": ProductCostLimit(limit_usd=25000.0, window_seconds=86400),
"posthog_ai": ProductCostLimit(limit_usd=5000.0, window_seconds=86400),
+ "changelog_bot": ProductCostLimit(limit_usd=500.0, window_seconds=86400),
}
DEFAULT_USER_COST_LIMITS: dict[str, "UserCostLimit"] = {
diff --git a/services/llm-gateway/src/llm_gateway/products/config.py b/services/llm-gateway/src/llm_gateway/products/config.py
index fc876b2a5a95..42f76d65561b 100644
--- a/services/llm-gateway/src/llm_gateway/products/config.py
+++ b/services/llm-gateway/src/llm_gateway/products/config.py
@@ -30,6 +30,8 @@ class ProductConfig:
# To permit OAuth access, explicitly list the allowed application IDs.
allowed_application_ids: frozenset[str] | None = frozenset()
allowed_models: frozenset[str] | None = None # None = all allowed
+ # True = exact allowlist match, not startswith
+ exact_model_match: bool = False
allow_api_keys: bool = True
# Which customer credit bucket this product bills into. None = not billed: emitted
# $ai_generation events are tagged $ai_billable=false and the usage reporter
@@ -270,6 +272,14 @@ PRODUCTS: Final[dict[str, ProductConfig]] = {
allow_api_keys=True,
credit_bucket=CreditBucket.AI_CREDITS,
),
+ # changelog-bot. Exact-pinned to these two ids (the agent sends "openai/"-prefixed).
+ "changelog_bot": ProductConfig(
+ allowed_application_ids=None,
+ allowed_models=frozenset({"openai/gpt-5.6-terra", "openai/gpt-5.6-sol"}),
+ exact_model_match=True,
+ allow_api_keys=True,
+ credit_bucket=None,
+ ),
# Stamphog: the sandboxed PR reviewer (Sonnet, OAuth-only in practice) and the daily merged-PR
# digest summarization (Haiku, server-side via the shared key). Low volume, internal infra.
# The reviewer runs inside a sandbox over untrusted PR content, so it authenticates with a
@@ -327,6 +337,7 @@ def _model_matches_product_allowlist(
allowed_models: frozenset[str],
provider: str | None = None,
settings: object | None = None,
+ exact: bool = False,
) -> bool:
model_candidates = {model.lower()}
if provider == "bedrock":
@@ -334,11 +345,16 @@ def _model_matches_product_allowlist(
get_bedrock_model_access_candidates(model, region_name=get_bedrock_region_name(settings=settings))
)
- allowed_prefixes = tuple(allowed_model.lower() for allowed_model in allowed_models)
+ allowed_lower = tuple(allowed_model.lower() for allowed_model in allowed_models)
+ if exact:
+ # A variant like "<pinned>-pro" is a distinct, pricier model — reject it.
+ return any(candidate in allowed_lower for candidate in model_candidates)
+ # Default: prefix match, so Bedrock/agent ids with region+version suffixes
+ # (e.g. "claude-3-5-sonnet-20241022-v2:0") match a short pinned name.
return any(
model_candidate.startswith(allowed_prefix)
for model_candidate in model_candidates
- for allowed_prefix in allowed_prefixes
+ for allowed_prefix in allowed_lower
)
@@ -430,7 +446,9 @@ def check_product_access(
return False, f"Product '{product}' requires a server-minted credential"
if model and config.allowed_models is not None:
- if not _model_matches_product_allowlist(model, config.allowed_models, provider=provider, settings=settings):
+ if not _model_matches_product_allowlist(
+ model, config.allowed_models, provider=provider, settings=settings, exact=config.exact_model_match
+ ):
return False, f"Model '{model}' not allowed for product '{product}'"
return True, None
diff --git a/services/llm-gateway/tests/test_product_config.py b/services/llm-gateway/tests/test_product_config.py
index cb3bf30ef5ee..a1d18849dc82 100644
--- a/services/llm-gateway/tests/test_product_config.py
+++ b/services/llm-gateway/tests/test_product_config.py
@@ -99,6 +99,17 @@ class TestCheckProductAccess:
("posthog_ai", "oauth_access_token", POSTHOG_AI_US_APP_ID, "claude-sonnet-4-5", True, None),
("posthog_ai", "oauth_access_token", POSTHOG_AI_EU_APP_ID, "gpt-5.3-codex", True, None),
("posthog_ai", "oauth_access_token", POSTHOG_AI_DEV_APP_ID, "claude-3-opus", True, None),
+ # changelog_bot: shared-key auth, models pinned to the openai/-prefixed ids the curator
+ # sends verbatim. Exact-match only: bare ids (no prefix) AND variant suffixes must be
+ # rejected, or the cost pin doesn't hold.
+ ("changelog_bot", "personal_api_key", None, "openai/gpt-5.6-terra", True, None),
+ ("changelog_bot", "personal_api_key", None, "openai/gpt-5.6-sol", True, None),
+ ("changelog_bot", "personal_api_key", None, "gpt-5.6-terra", False, "not allowed"),
+ ("changelog_bot", "personal_api_key", None, "openai/gpt-5-mini", False, "not allowed"),
+ # exact_model_match: a pricier "-pro" variant of a pinned id must NOT slip through startswith.
+ ("changelog_bot", "personal_api_key", None, "openai/gpt-5.6-terra-pro", False, "not allowed"),
+ ("changelog_bot", "personal_api_key", None, "openai/gpt-5.6-sol-pro", False, "not allowed"),
+ ("changelog_bot", "oauth_access_token", "any-app-id", "openai/gpt-5.6-terra", False, "not authorized"),
# unknown product
("unknown", "personal_api_key", None, None, False, "Unknown product"),
],