Skip to content

Record cache tokens for non-streaming Bedrock invoke responses - #169

Open
cedricfontaine wants to merge 3 commits into
Flared:mainfrom
cedricfontaine:patch-1
Open

cedricfontaine wants to merge 3 commits into
Flared:mainfrom
cedricfontaine:patch-1

Conversation

@cedricfontaine

Copy link
Copy Markdown

Non-streaming Bedrock InvokeModel responses only read token counts from
the x-amzn-bedrock-*-token-count headers, which carry no cache usage, so
cache read and cache creation tokens were never recorded for these
requests. Streaming responses were not affected.

The response body is now parsed with the existing Anthropic usage parser,
which reports cache reads and cache writes split by TTL. When the body has
no Anthropic usage block, the token counts fall back to the headers,
including the Bedrock cache read and cache write headers.

Lacuna now reads cache tokens from the response body. If the body doesn't have them, it falls back to the cache headers.
Lets the Bedrock file call it instead of copying the parser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant