feat: add AWS PRM user-agent attribution for Bedrock calls#224
feat: add AWS PRM user-agent attribution for Bedrock calls#224blinkagent[bot] wants to merge 3 commits intomainfrom
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
|
@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 |
| } | ||
|
|
||
| var out []option.RequestOption | ||
| out = append(out, option.WithMiddleware(func(req *http.Request, next option.MiddlewareNext) (*http.Response, error) { |
There was a problem hiding this comment.
If I understand correctly I think it could be simplified by using option.WithHeader:
if ua := req.Header.Get("User-Agent"); ua != "" {
out = append(out, option.WithHeader(...)
}
There was a problem hiding this comment.
I think you may be right here I will make the update, and test to verify it appends the same way as I have verified already in bedrock.
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