SIGN IN SIGN UP

fix: preserve complete Amazon Bedrock Converse raw usage objects (#19694)

## Background

Amazon Bedrock Converse and ConverseStream dropped provider usage fields
from final-step usage.raw, including streaming totalTokens and
provider-specific metadata.

## Root Cause

Strict Zod usage schemas stripped unknown top-level and cache-detail
fields, while the streaming schema omitted totalTokens entirely. The
immutable reproduction, existing fixtures, and live Bedrock calls
confirmed data loss at the response parsing boundary.

## Summary

Added JSON-valued usage catchalls, preserved nested cache metadata,
validated optional streaming totalTokens, widened the internal raw usage
type, updated snapshots, and added a patch changeset.

## Testing

Added production-path doGenerate and real AWS event-stream doStream
regression tests covering complete raw usage preservation, normalized
counts, and known-field validation.

## End-to-end Validation

- `replay_original_reproduction`: completed successfully without the
original bug signal (`no-longer-reproduces`).
- `pnpm -C examples/ai-functions exec tsx -e "<direct Bedrock
doGenerate/doStream raw-usage probe>"`: live Converse and ConverseStream
calls both retained `totalTokens` and `serverToolUsage` in `usage.raw`.

## Related Issues

Fixes #19686

Closes #19687

---------

Co-authored-by: ai-sdk-factory <308175966+ai-sdk-factory@users.noreply.github.com>
Co-authored-by: gr2m <39992+gr2m@users.noreply.github.com>
A
ai-sdk-factory[bot] committed
fd49828bc4bb159017a6ad6927b8b1e11122f943
Parent: 3da2b7d
Committed by GitHub <noreply@github.com> on 8/26/2026, 4:59:57 PM