feat(ai): add requestMetadata support to BedrockOptions for cost allocation tagging (#2511)

Add an optional requestMetadata field to BedrockOptions that forwards
key-value pairs to the Bedrock Converse API ConverseStreamCommand. Tags
appear in AWS Cost Explorer split cost allocation data, enabling callers
to attribute inference costs to specific applications or contexts.

Changes:
- Add requestMetadata?: Record<string, string> to BedrockOptions with
  JSDoc documenting AWS constraints (max 50 pairs, key 64 chars, value
  256 chars, no aws: prefix)
- Pass requestMetadata to commandInput via conditional spread to avoid
  sending undefined when omitted
- Export BedrockOptions from package root (consistent with other
  provider option types)
- Add E2E tests: metadata forwarded to SDK payload, and omitted when
  not provided

closes #2510
This commit is contained in:
wjonaskr
2026-03-23 03:05:55 +09:00
committed by GitHub
parent b21b42d032
commit 3bcbae490c
4 changed files with 66 additions and 0 deletions

View File

@@ -2,6 +2,11 @@
## [Unreleased]
### Added
- Added `requestMetadata` option to `BedrockOptions` for AWS cost allocation tagging; key-value pairs are forwarded to the Bedrock Converse API `requestMetadata` field and appear in AWS Cost Explorer split cost allocation data.
- Exported `BedrockOptions` type from the package root entry point, consistent with other provider option types.
### Fixed
- Fixed OpenAI Responses replay for foreign tool-call item IDs by hashing foreign `function_call.id` values into bounded `fc_<hash>` IDs instead of preserving backend-specific normalized shapes that OpenAI Codex rejects.