feat: add cached token metrics support for Amazon Bedrock#641
Closed
poshinchen wants to merge 1 commit intostrands-agents:mainfrom
Closed
feat: add cached token metrics support for Amazon Bedrock#641poshinchen wants to merge 1 commit intostrands-agents:mainfrom
poshinchen wants to merge 1 commit intostrands-agents:mainfrom
Conversation
Unshure
reviewed
Aug 11, 2025
Member
Unshure
left a comment
There was a problem hiding this comment.
This import does not look correct, can you fix it?
d2125e3 to
f95803d
Compare
f95803d to
9662367
Compare
Member
|
In the referenced PR we have " Maintainers are allowed to edit this pull request." I think we should try to make edits there for one to keep everything in one place, but also to avoid community members feeling that they aren't given credit or the opportunity to contribute themselves. At the very least lets make sure oaltagar-aws gets some credit as a co-author |
| outputTokens=6, | ||
| totalTokens=9, | ||
| ) | ||
| exp_usage = Usage(inputTokens=3, outputTokens=6, totalTokens=9, cacheWriteInputTokens=30) |
Member
There was a problem hiding this comment.
nit: test including cacheWriteOutputToken?
| inputTokens: Number of tokens sent in the request to the model. | ||
| outputTokens: Number of tokens that the model generated for the request. | ||
| totalTokens: Total number of tokens (input + output). | ||
| cacheReadInputTokens: Number of tokens read from cache (optional). |
Member
There was a problem hiding this comment.
nit: comment saying when it is included or not?
|
|
||
| # Add cached token info if present | ||
| if summary["accumulated_usage"].get("cacheReadInputTokens"): | ||
| token_parts.append(f"cache_read={summary['accumulated_usage']['cacheReadInputTokens']}") |
Member
There was a problem hiding this comment.
nit: cache_write_in? are there other cache types potentially?
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.
Description
Add cached token metrics support for Amazon Bedrock to track cache read/write input tokens.
Taking over the pr with tests and some refinements
Related Issues
#529
Documentation PR
N/A
Type of Change
Update
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.