Send per-install id to the wpcom AI proxy - #4385
Open
gcsecsey wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Studio CLI’s WP.com AI proxy integration to send a per-install identifier (X-WPCOM-AI-Install-Id) derived from the existing shared anonymous analytics install UUID, enabling WP.com to apply per-install burst caps across both Anthropic and OpenAI proxy lanes.
Changes:
- Add
X-WPCOM-AI-Install-Idto the WP.com AI proxy headers for both Anthropic and OpenAI request paths. - Make the install-id lookup best-effort (failures omit the header rather than failing the AI request).
- Extend unit tests to cover inclusion and omission behavior for the new header.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/cli/ai/providers.ts | Resolves the shared analytics install UUID and conditionally attaches it as X-WPCOM-AI-Install-Id to WP.com AI proxy headers (Anthropic + OpenAI). |
| apps/cli/ai/tests/auth.test.ts | Updates and adds tests asserting the install-id header is included when available and omitted when the shared-config lookup fails. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
gcsecsey
marked this pull request as ready for review
July 30, 2026 16:23
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.
Related issues
How AI was used in this PR
I used Claude to locate the existing per-install identifier and the single place Studio attaches the AI proxy headers, write the change and tests, and verify the typecheck and the affected suites. I reviewed the identifier choice, the spoofability tradeoff, and the logic.
Proposed Changes
In 231063-ghe-Automattic/wpcom we added caps to curb Studio Code abuse where single users ran many parallel agent turns. This PR sends a
X-WPCOM-AI-Install-Idheader:Tradeoff worth calling out
The header is client-supplied, and Studio's bundle is not obfuscated, so it is trivially spoofable. It bounds accidental fan-out from a single install, not a determined abuser. The per-account cap is what holds when this value is rotated or absent.
Testing Instructions
npm test -- apps/cli/ai/tests/auth.test.tsX-WPCOM-AI-Install-Idset to the analyticsInstallId value in~/.studio/shared.json.Pre-merge Checklist