Context: ContextReasoningUsage and ContextCacheUsage don't compile with ai 7

オープン 初心者向け
#500 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@burrows99 がすでに取り組んでいます。

2026年10月12日 から。

  • #517 @burrows99 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
90/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
ai, frontend

調査の方向性

packages/elements/src/context.tsx の339行目と379行目付近から始め、参照されている LanguageModelUsage フィールドを ai 6 と ai 7 の型定義と比較してください。提供されている strict TypeScript の再現コード、またはパッケージの型チェックを実行してください。報告されたエラーなしで、サポート対象の ai の両方のメジャーバージョンに対して Context がコンパイルできれば完了です。

索引モデルが issue の本文から書いたものです。

説明

context.tsx reads usage.reasoningTokens and usage.cachedInputTokens. Both are deprecated in ai 6 and removed from LanguageModelUsage in ai 7, so a project on ai 7 that adds the Context component gets two type errors:

https://github.com/vercel/ai-elements/blob/6a9d5b1822ffb10bba4bd97175f01edd7d8651cd/packages/elements/src/context.tsx#L339
https://github.com/vercel/ai-elements/blob/6a9d5b1822ffb10bba4bd97175f01edd7d8651cd/packages/elements/src/context.tsx#L379

Repro, no app needed (npm i ai@<version> zod typescript, then npx tsc -p . with strict):

import type { LanguageModelUsage } from "ai";

declare const usage: LanguageModelUsage | undefined;

// what context.tsx reads today
const reasoning = usage?.reasoningTokens ?? 0;
const cacheReads = usage?.cachedInputTokens ?? 0;

// the nested fields
const reasoningNested = usage?.outputTokenDetails?.reasoningTokens ?? 0;
const cacheReadsNested = usage?.inputTokenDetails?.cacheReadTokens ?? 0;
[email protected]: no errors
[email protected]:
repro.ts(6,26): error TS2339: Property 'reasoningTokens' does not exist on type 'LanguageModelUsage'.
repro.ts(7,27): error TS2339: Property 'cachedInputTokens' does not exist on type 'LanguageModelUsage'.

The nested outputTokenDetails.reasoningTokens and inputTokenDetails.cacheReadTokens already exist in 6.0.105, the lowest version packages/elements allows, so switching to them works on both majors and the rest of the component (the tokenlens cost lines) stays as is. Happy to open a PR if that sounds right.

Node 26.0.0, TypeScript 5.9.3.

主要言語
TypeScript
スター
2.5k
フォーク
290
平均マージ
20分
マージ済み PR(30日)
3

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

vercel/ai-elements のほかの issue

vercel/ai-elements の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。