feat: add AWS PRM user-agent attribution for Bedrock calls#224
Open
blinkagent[bot] wants to merge 3 commits into
Open
feat: add AWS PRM user-agent attribution for Bedrock calls#224blinkagent[bot] wants to merge 3 commits into
blinkagent[bot] wants to merge 3 commits into
Conversation
4a33e1e to
f83daa9
Compare
config.WithAppID has no effect because the Anthropic SDK sets User-Agent directly on the request, bypassing the AWS SDK user-agent builder. Replace it with an option.WithMiddleware that appends the APN token to the existing User-Agent header. Confirmed working via CloudTrail: "userAgent": "Anthropic/Go 1.19.0 sdk-ua-app-id/APN_1.1%2Fpc_cdfmjwn8i6u8l9fwz8h82e4w3%24"
|
Made some updates here, but I can confirm that this now properly appends our Vendor Tag to the outgoing requests to Bedrock. |
Adds two integration test assertions: - Positive: Bedrock requests include the PRM sdk-ua-app-id in User-Agent - Negative: Non-Bedrock Anthropic requests do not include PRM attribution
Collaborator
|
@DevelopmentCats do we still need this? |
|
@dannykopping Yes I am working on getting the final review and testing on this before we can merge it. but this is a part of our expectations for the AWS PRM Attribution. I am just less confident in this change since it is a bit more transformative, and I have not made many contributions to aibridge |
pawbana
reviewed
Apr 23, 2026
DevelopmentCats
approved these changes
May 12, 2026
pawbana
approved these changes
May 18, 2026
DevelopmentCats
added a commit
to coder/coder
that referenced
this pull request
May 28, 2026
…#25221) Adds middleware in `withAWSBedrockOptions` that 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 - A middleware is added before `bedrock.WithConfig(awsCfg)` that reads the existing `User-Agent` header and appends `sdk-ua-app-id/APN_1.1%2Fpc_cdfmjwn8i6u8l9fwz8h82e4w3%24` - Only affects Bedrock calls; OpenAI and direct Anthropic API calls are unaffected - Uses `option.WithMiddleware` rather than `option.WithHeader` because the existing User-Agent (set by the Anthropic SDK) must be preserved and appended to, not replaced ## Tests - **Positive**: `TestAWSBedrockIntegration` verifies PRM attribution is present in the User-Agent on Bedrock requests - **Negative**: `TestAnthropicMessages` verifies PRM attribution is absent on non-Bedrock requests ## References - Companion Terraform provisioner PR: #23138 (merged) - Backport: #24052 (merged) - Preserve existing `AWS_SDK_UA_APP_ID`: #24606 (open) - Original `coder/aibridge` PR: coder/aibridge#224 (superseded by this PR since aibridge was moved into coder/coder via #24190) - [AWS SDK Application ID docs](https://docs.aws.amazon.com/sdkref/latest/guide/feature-appid.html) - [AWS PRM Automated User Agent](https://prm.partner.aws.dev/automated-user-agent.html) (partner login required) > Generated with [Coder Agents](https://coder.com/agents) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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.
Adds
config.WithAppIDto the AWS SDK config used for Bedrock API calls, setting the AWS Partner Revenue Measurement (PRM) user-agent attribution on every Bedrock request.This is the AI Bridge counterpart to coder/coder#23138, which covers the Terraform provisioner path. Together, they ensure all AWS API calls made by Coder — both workspace infrastructure (Terraform) and LLM inference (Bedrock) — include PRM attribution in the user-agent header.
How it works
withAWSBedrockOptions()now passesconfig.WithAppID("APN_1.1/pc_cdfmjwn8i6u8l9fwz8h82e4w3$")toconfig.LoadDefaultConfigNotes
-ldflags -Xat build time, though it is a public identifier on the AWS Marketplace listing.References