Add custom user agent configuration for Bedrock provider
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:
- Distinguish OpenCode usage from other tools using the same AI SDK
- Track OpenCode version adoption across an organization
- 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
- Enterprise tracking: Organizations want to track which AI coding tools are being used (opencode vs claude-cli vs cursor vs copilot)
- Version monitoring: Identify users on outdated versions for security/compliance
- Cost attribution: Correlate API costs with specific tools in CloudWatch metrics
- 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.