Skip to content

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

Merged
DevelopmentCats merged 3 commits into
mainfrom
feat/aws-prm-bedrock-aibridge
May 28, 2026
Merged

chore(aibridge): add AWS PRM user-agent attribution for Bedrock calls#25221
DevelopmentCats merged 3 commits into
mainfrom
feat/aws-prm-bedrock-aibridge

Conversation

@DevelopmentCats
Copy link
Copy Markdown
Contributor

@DevelopmentCats DevelopmentCats commented May 12, 2026

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

Generated with Coder Agents

Closes ECO-7

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
Copilot AI review requested due to automatic review settings May 12, 2026 19:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-Agent for 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.

Comment thread aibridge/intercept/messages/base.go
Comment thread aibridge/intercept/messages/base.go
@github-actions github-actions Bot added the stale This issue is like stale bread. label May 27, 2026
@DevelopmentCats DevelopmentCats requested a review from matifali May 28, 2026 12:41
@matifali matifali requested review from dannykopping and pawbana May 28, 2026 14:49
Copy link
Copy Markdown
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM But lets also get a review from @pawbana

@matifali
Copy link
Copy Markdown
Member

@DevelopmentCats, can you also fix merge conflicts?

@matifali matifali changed the title feat(aibridge): add AWS PRM user-agent attribution for Bedrock calls chore(aibridge): add AWS PRM user-agent attribution for Bedrock calls May 28, 2026
@DevelopmentCats
Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Copy link
Copy Markdown
Contributor

Copilot AI commented May 28, 2026

@copilot resolve the merge conflicts in this pull request

Resolved by merging origin/main into this PR branch in commit fb018ad68, which clears the merge conflicts while preserving the Bedrock PRM attribution changes.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 28, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@DevelopmentCats
Copy link
Copy Markdown
Contributor Author

@copilot can you reply I have read the CLA Document and I hereby sign the CLA

Copy link
Copy Markdown
Contributor

Copilot AI commented May 28, 2026

I have read the CLA Document and I hereby sign the CLA.

cdrci2 added a commit to coder/cla that referenced this pull request May 28, 2026
@DevelopmentCats DevelopmentCats merged commit 094fe97 into main May 28, 2026
32 of 33 checks passed
@DevelopmentCats DevelopmentCats deleted the feat/aws-prm-bedrock-aibridge branch May 28, 2026 16:08
@github-actions github-actions Bot locked and limited conversation to collaborators May 28, 2026
@matifali matifali added cherry-pick and removed stale This issue is like stale bread. labels Jun 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants