feat(agent): route selected products to the ai-gateway#3659
Open
brandonleung wants to merge 2 commits into
Open
feat(agent): route selected products to the ai-gateway#3659brandonleung wants to merge 2 commits into
brandonleung wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gyKxP2MuVuNRCK9uZt1Lr
|
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 |
|
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
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
The task-sandbox agent-server sends model calls to the Python
llm-gateway, whose URL carries a product slug and whose attribution rides in per-propertyx-posthog-property-*headers. The Go ai-gateway is slugless and reads a singleX-PostHog-PropertiesJSON blob. To migrate one product at a time, the server needs to pick the gateway per request and speak the right wire format for whichever it picks.Changes
resolveGatewayTargetselects the gateway from env:AI_GATEWAY_URLpicks the Go gateway,AI_GATEWAY_PRODUCTSlimits it to namedai_productvalues. Both must be set; an unlisted product, or a listed one with no URL, stays on the Python gateway. The two gateways run on separate hosts, so the base URL is the distinguishing signal.X-PostHog-Propertiesblob carryingai_product,ai_stage, andteam_id; the Python path is unchanged.buildPosthogPropertiesBlobin@posthog/shared: serializes the property set to a JSON blob, drops reserved$-prefixed keys, sanitizes keys and values to printable ASCII (Bun's fetch rejects non-ASCII header values), and drops the longest string values until the blob fits the gateway's 8192-byte cap so attribution keys survive a long task title.ai_producttags (signals_scout, …) matching the tags the non-sandbox signals stages already emit.Verification
buildPosthogPropertiesBlobandresolveGatewayTargetunit-tested, including byte-cap trimming (down to the boundary where every value overflows and nothing is sent), ASCII sanitization of keys and values, and the isolation cases (unlisted products and non-signals callers stay on the Python gateway). The 8192-byte cap matches the gateway's own> maxPropertiesLencheck on the header value. The existingconfigureEnvironmentsuite pins the unchanged Python path.tscandbiomeclean.Rollout
Behavior is unchanged until the sandbox sets
AI_GATEWAY_URLandAI_GATEWAY_PRODUCTS. This must deploy before the chart enables them. Rollback is clearing either value.