Add custom user agent configuration for Bedrock provider #5752

Open
opened 2026-02-16 17:56:25 -05:00 by yindo · 0 comments
Owner

Originally created by @alexef on GitHub (Jan 14, 2026).

Originally assigned to: @thdxr on GitHub.

Feature Request

OpenCode should automatically identify itself in the user agent string sent to LLM providers (especially AWS Bedrock) for better tracking and analytics.

Current Behavior

OpenCode uses the Vercel AI SDK which sets its own user agent:

ai-sdk/amazon-bedrock/3.0.73 ai-sdk/provider-utils/3.0.20 runtime/bun/1.3.5

This makes it impossible to:

  1. Distinguish OpenCode usage from other tools using the same AI SDK
  2. Track OpenCode version adoption across an organization
  3. Identify which tool/harness generated specific API calls in CloudTrail/CloudWatch logs

Requested Feature

OpenCode should automatically prepend its name and version to the user agent string:

Current:

ai-sdk/amazon-bedrock/3.0.73 ai-sdk/provider-utils/3.0.20 runtime/bun/1.3.5

Desired:

opencode/1.2.3 ai-sdk/amazon-bedrock/3.0.73 ai-sdk/provider-utils/3.0.20 runtime/bun/1.3.5

This should happen automatically without requiring user configuration. OpenCode already knows its version, it should just include it in the user agent.

Use Cases

  1. Enterprise tracking: Organizations want to track which AI coding tools are being used (opencode vs claude-cli vs cursor vs copilot)
  2. Version monitoring: Identify users on outdated versions for security/compliance
  3. Cost attribution: Correlate API costs with specific tools in CloudWatch metrics
  4. Usage analytics: Understand adoption patterns across teams

Comparison with Other Tools

Other AI coding tools properly identify themselves:

claude-cli:

claude-cli/2.1.7 (external, cli)

OpenCode should do the same:

opencode/1.2.3 ai-sdk/amazon-bedrock/3.0.73 ...

Implementation

This likely requires passing a custom user agent to the AI SDK provider initialization. The AI SDK supports custom headers/user agents - OpenCode just needs to set it automatically on behalf of the user.

Additional Context

This is particularly important for AWS Bedrock where CloudTrail captures user agent strings, enabling tracking and metrics via CloudWatch. Without proper identification, all OpenCode usage appears as generic AI SDK traffic, making it impossible to:

  • Track OpenCode adoption in an organization
  • Monitor which versions are in use
  • Attribute costs correctly
  • Generate usage analytics

This should not require user configuration - OpenCode knows its own version and should automatically identify itself, just like claude-cli and other tools do.

Originally created by @alexef on GitHub (Jan 14, 2026). Originally assigned to: @thdxr on GitHub. ## Feature Request OpenCode should automatically identify itself in the user agent string sent to LLM providers (especially AWS Bedrock) for better tracking and analytics. ## Current Behavior OpenCode uses the Vercel AI SDK which sets its own user agent: ``` ai-sdk/amazon-bedrock/3.0.73 ai-sdk/provider-utils/3.0.20 runtime/bun/1.3.5 ``` This makes it impossible to: 1. Distinguish OpenCode usage from other tools using the same AI SDK 2. Track OpenCode version adoption across an organization 3. Identify which tool/harness generated specific API calls in CloudTrail/CloudWatch logs ## Requested Feature OpenCode should **automatically** prepend its name and version to the user agent string: **Current:** ``` ai-sdk/amazon-bedrock/3.0.73 ai-sdk/provider-utils/3.0.20 runtime/bun/1.3.5 ``` **Desired:** ``` opencode/1.2.3 ai-sdk/amazon-bedrock/3.0.73 ai-sdk/provider-utils/3.0.20 runtime/bun/1.3.5 ``` This should happen **automatically** without requiring user configuration. OpenCode already knows its version, it should just include it in the user agent. ## Use Cases 1. **Enterprise tracking**: Organizations want to track which AI coding tools are being used (opencode vs claude-cli vs cursor vs copilot) 2. **Version monitoring**: Identify users on outdated versions for security/compliance 3. **Cost attribution**: Correlate API costs with specific tools in CloudWatch metrics 4. **Usage analytics**: Understand adoption patterns across teams ## Comparison with Other Tools Other AI coding tools properly identify themselves: **claude-cli:** ``` claude-cli/2.1.7 (external, cli) ``` **OpenCode should do the same:** ``` opencode/1.2.3 ai-sdk/amazon-bedrock/3.0.73 ... ``` ## Implementation This likely requires passing a custom user agent to the AI SDK provider initialization. The AI SDK supports custom headers/user agents - OpenCode just needs to set it automatically on behalf of the user. ## Additional Context This is particularly important for AWS Bedrock where CloudTrail captures user agent strings, enabling tracking and metrics via CloudWatch. Without proper identification, all OpenCode usage appears as generic AI SDK traffic, making it impossible to: - Track OpenCode adoption in an organization - Monitor which versions are in use - Attribute costs correctly - Generate usage analytics **This should not require user configuration** - OpenCode knows its own version and should automatically identify itself, just like claude-cli and other tools do.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#5752