feat(stamphog): route PR review through the ai-gateway#3354
Merged
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
charlesvien
approved these changes
Jul 10, 2026
Member
|
exciting! |
Contributor
|
Reviews (1): Last reviewed commit: "feat(stamphog): route PR review through ..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Stamphog (the vendored PR-approval agent) calls Anthropic directly, so its LLM usage bypasses PostHog's ai-gateway and shows up as pre-gateway
stamphogtraffic on the cutover dashboards. This routes it through the gateway, matching the other migrated products.Changes
gateway.py: resolvesAI_GATEWAY_URL/AI_GATEWAY_API_KEY, points the Claude Agent SDK at the gateway viaANTHROPIC_*env, tagsaio_stamphog. Verbatim copy from the posthog monorepotools/pr-approval-agent.reviewer.pyuses the plain SDK query in gateway mode so the gateway's own$ai_generationis not double-counted; falls back to the traced query (then the plain query) when the gateway is not configured.AI_GATEWAY_URL/AI_GATEWAY_API_KEYfromSTAMPHOG_AI_GATEWAY_*secrets to the review step.Env-gated: both secrets set and valid routes through the gateway; unset or malformed falls back to direct Anthropic.
Not in this PR
phs_project secret).Rollout
Set repo/org secrets
STAMPHOG_AI_GATEWAY_URL(gateway URL ending in/v1) andSTAMPHOG_AI_GATEWAY_API_KEY(phs_project secret) to arm the cutover; until then it stays on direct Anthropic. Rollback: clear either secret.How did you test this?
pytest test_gateway.py test_reviewer_gateway.py(16 tests): gateway config validation and fallback,/v1stripping, theX-PostHog-Propertiesattribution blob, and the routing guard that selects the plain query in gateway mode so the gateway and traced paths never both emit. The live path (a real PR review through the gateway) needs the secrets populated in CI and has not run yet.Authored by Claude (Opus 4.8); requires human review.
Automatic notifications