Repository navigation
Conversation
…etails ContextReasoningUsage and ContextCacheUsage read usage.reasoningTokens and usage.cachedInputTokens. Both are deprecated in ai 6 and removed from LanguageModelUsage in ai 7, so on ai 7 the component fails to compile and the Reasoning and Cache rows never render. Read outputTokenDetails.reasoningTokens and inputTokenDetails.cacheReadTokens instead. They exist from ai 6.0.105, the lowest version the package allows. Fixes vercel#500
Contributor
|
@burrows99 is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
burrows99
marked this pull request as ready for review
October 12, 2026 13:40
This branch has not been deployed
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.
Fixes #500
ContextReasoningUsageandContextCacheUsagereadusage.reasoningTokensandusage.cachedInputTokens. Both are deprecated in ai 6 and removed fromLanguageModelUsagein ai 7, so on ai 7 the component fails to type-check (TS2339 x2), and at runtime the Reasoning and Cache rows never render because those fields are undefined.This reads
usage.outputTokenDetails.reasoningTokensandusage.inputTokenDetails.cacheReadTokensinstead. Both exist from ai 6.0.105 (the minimumpackages/elementsallows), so it works on both majors. Cost lines are unchanged.Changes
packages/elements/src/context.tsx: the two readspackages/elements/__tests__/context.test.tsx: reasoning/cache tests now pass the nested shape (fail on main, pass here)packages/examples/src/context.tsx: the example usage object uses the nested shapeVerification
Testworkflow (build + full test suite) passes on this branch: https://github.com/burrows99/ai-elements/actions/runs/38255687065 (run on my fork while upstream CI awaits first-contributor approval).pnpm exec vitest run __tests__/context.test.tsx: main 4 failed / 23 passed → 27 passed. Full suite: 958 passed.tsconsrc/context.tsxagainst ai@7.0.137 types: 2 errors on main → none.AI use: written with Claude Code; I reviewed every line and verified it with the commands above and the recording.
Evidence: a real AI SDK 7 chat app (
useChat+ astreamTextroute, with Conversation / Message / PromptInput / Context installed vianpx ai-elements add). The Context card reads the usagestreamTextreports on finish. The model is the AI SDK's ownMockLanguageModelV4(no provider key in my recording environment), reporting 3,000 reasoning and 3,072 cache-read tokens, whichstreamTextreturns in ai 7's nested shape. Left pane: whichcontext.tsxthe app is built from.Before (
context.tsxfrom main, byte-identical tonpx ai-elements add contexttoday): the card shows Input and Output only.video.mp4
After (this branch): Reasoning 3K and Cache 3.1K rows appear.
video.mp4