feat(conversation): add metrics and usage types and deserializers#697
Draft
pjkroker wants to merge 8 commits intoaws-amplify:mainfrom
Draft
feat(conversation): add metrics and usage types and deserializers#697pjkroker wants to merge 8 commits intoaws-amplify:mainfrom
pjkroker wants to merge 8 commits intoaws-amplify:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 814af54 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
4eb3a97 to
6f31842
Compare
6f31842 to
d1a7e9a
Compare
d1a7e9a to
0f5a822
Compare
added 2 commits
March 30, 2026 13:50
…assertions for metrics/usage
This was referenced Mar 30, 2026
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Streaming conversation responses from the Bedrock Converse API do not expose model usage or latency information. Consumers have no way to track token consumption or response latency for conversation turns.
Issue number: aws-amplify/amplify-backend#2355
Related PRs (all required for aws-amplify/amplify-backend#2355)
This feature spans 4 repositories. PRs should be merged in this order:
AmplifyAIMetrics/AmplifyAIUsageGraphQL types and updates resolversChanges
Adds
metricsandusagefields to conversation messages and stream events across the GraphQL schema, TypeScript types, and runtime deserializers.Specifically:
AmplifyAIMetricsGraphQL type (latencyMs: Int) added toConversationSchemaGraphQLTypes.tsAmplifyAIUsageGraphQL type (inputTokens,outputTokens,totalTokens) added toConversationSchemaGraphQLTypes.tsmetricsandusagefields added toAmplifyAIConversationMessageandAmplifyAIConversationMessageStreamPartConversationMessageTypeScript interface updated with optionalmetricsandusageConversationStreamEventtypes updated —metrics/usagepresent on turn-done events,neveron other event typesconvertItemToConversationMessage,conversationStreamEventDeserializers) pass throughmetricsandusagewhen presentCorresponding docs PR, if applicable:
Validation
yarn buildinpackages/data-schema— builds cleanlyyarn testinpackages/data-schema— all tests passconvertItemToConversationMessage(metrics/usage present and absent)conversationStreamEventDeserializers(turn-done with metrics/usage, text event without, error event)createOnStreamEventFunctiontests to includemetrics/usagein expected undefined fields2-expected-use/ai-conversation.tsfor list messages and turn-done stream events with metrics/usageChecklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.