chore(aibridge): add AWS PRM user-agent attribution for Bedrock calls#25221
Conversation
Adds middleware in withAWSBedrockOptions that appends the AWS Partner Revenue Measurement (PRM) attribution string to the User-Agent header on every Bedrock API call. This is the AI Bridge counterpart to the Terraform provisioner change merged in #23138. The middleware reads the existing User-Agent set by the Anthropic SDK, appends the PRM product code, and passes it through. Non-Bedrock requests are unaffected. Includes integration tests verifying: - Bedrock requests contain PRM attribution in User-Agent - Non-Bedrock Anthropic requests do not contain PRM attribution
There was a problem hiding this comment.
Pull request overview
Adds AWS Partner Revenue Measurement (PRM) user-agent attribution to AI Bridge’s AWS Bedrock requests so Bedrock traffic can be revenue-attributed similarly to Terraform-provisioned AWS calls.
Changes:
- Appends the AWS PRM attribution token to the
User-Agentfor Bedrock requests via an Anthropics SDK request middleware. - Extends integration tests to assert PRM attribution is present for Bedrock traffic and absent for non-Bedrock Anthropic traffic.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| aibridge/intercept/messages/base.go | Adds request middleware in withAWSBedrockOptions to append PRM attribution to the outgoing User-Agent. |
| aibridge/internal/integrationtest/bridge_test.go | Adds positive/negative integration assertions for PRM attribution presence/absence in upstream User-Agent. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@DevelopmentCats, can you also fix merge conflicts? |
|
@copilot resolve the merge conflicts in this pull request |
Resolved by merging |
|
All contributors have signed the CLA ✍️ ✅ |
|
@copilot can you reply I have read the CLA Document and I hereby sign the CLA |
|
I have read the CLA Document and I hereby sign the CLA. |
Adds middleware in
withAWSBedrockOptionsthat appends the AWS Partner Revenue Measurement (PRM) attribution string to the User-Agent header on every Bedrock API call made through AI Bridge.This is the AI Bridge counterpart to the Terraform provisioner change merged in #23138. Together, they ensure all AWS API calls made by Coder (both workspace infrastructure via Terraform and LLM inference via Bedrock) include PRM attribution.
How it works
bedrock.WithConfig(awsCfg)that reads the existingUser-Agentheader and appendssdk-ua-app-id/APN_1.1%2Fpc_cdfmjwn8i6u8l9fwz8h82e4w3%24option.WithMiddlewarerather thanoption.WithHeaderbecause the existing User-Agent (set by the Anthropic SDK) must be preserved and appended to, not replacedTests
TestAWSBedrockIntegrationverifies PRM attribution is present in the User-Agent on Bedrock requestsTestAnthropicMessagesverifies PRM attribution is absent on non-Bedrock requestsReferences
AWS_SDK_UA_APP_ID: chore(provisioner/terraform): preserve existing AWS_SDK_UA_APP_ID #24606 (open)coder/aibridgePR: feat: add AWS PRM user-agent attribution for Bedrock calls aibridge#224 (superseded by this PR since aibridge was moved into coder/coder via chore: move aibridge library code into coder repo #24190)Closes ECO-7