Skip to content

chore(aibridge): add AWS PRM user-agent attribution for Bedrock calls (#25221)#26141

Merged
matifali merged 1 commit into
release/2.34from
backport/25221-to-2.34
Jun 8, 2026
Merged

chore(aibridge): add AWS PRM user-agent attribution for Bedrock calls (#25221)#26141
matifali merged 1 commit into
release/2.34from
backport/25221-to-2.34

Conversation

@github-actions
Copy link
Copy Markdown

@github-actions github-actions Bot commented Jun 8, 2026

Cherry-pick of #25221

Original PR: #25221 — chore(aibridge): add AWS PRM user-agent attribution for Bedrock calls
Merge commit: 094fe97
Requested by: @matifali

…#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>
(cherry picked from commit 094fe97)
@github-actions github-actions Bot requested a review from matifali June 8, 2026 17:15
@matifali matifali requested a review from f0ssel June 8, 2026 17:16
@matifali matifali merged commit 1117e43 into release/2.34 Jun 8, 2026
@matifali matifali deleted the backport/25221-to-2.34 branch June 8, 2026 17:21
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants