feat(agent): route selected products to the ai-gateway - #3659
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gyKxP2MuVuNRCK9uZt1Lr
|
😎 Merged successfully - details. |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
brandonleung
marked this pull request as ready for review
July 22, 2026 03:02
Contributor
|
Reviews (1): Last reviewed commit: "feat(agent): route selected products to ..." | Re-trigger Greptile |
…sertion Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gyKxP2MuVuNRCK9uZt1Lr
richardsolomou
approved these changes
Jul 27, 2026
richardsolomou
left a comment
Member
There was a problem hiding this comment.
would be worth testing exact 8,192-byte and 8,193-byte blobs so an off-by-one at the gateway limit cant slip through
Contributor
|
👋 Visual changes detected for this PR. Review and approve in PostHog Visual Review If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix. |
brandonleung
enabled auto-merge (squash)
July 28, 2026 21:21
Contributor
Author
|
/trunk merge |
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
Model calls from code sandboxes all go through the legacy Python
llm-gateway. We're migrating products to the new Goai-gatewayone at a time, so the agent-server needs to pick a gateway per request. The two gateways also take attribution differently: the old one wants a product slug in the URL plus per-property headers, the new one wants a single JSON header.Changes
Routing to the new gateway is opt-in via two env vars:
AI_GATEWAY_URLis the new gateway's address;AI_GATEWAY_PRODUCTSlists theai_productvalues that may use it. Both must be set. Unlisted products keep using the Python gateway.ai_product,ai_stage, andteam_idin oneX-PostHog-Propertiesheader, built by a newbuildPosthogPropertiesBlobhelper in@posthog/shared(enforces the gateway's 8KB / ASCII limits).ai_producttags (signals_scout, ...), matching the non-sandbox signals stages.How did you test this?
Unit tests cover the routing choice and the header builder (cap trimming, sanitization, unlisted products falling back).
tscandbiomeclean.Inert until the sandbox chart sets both env vars (PostHog/posthog#72770 plus a charts PR). Rollback: clear either one.