Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#500 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@burrows99 đang làm issue này rồi.

Từ ngày 12/10/2026.

  • #517 của @burrows99 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
90/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
ai, frontend

Hướng nghiên cứu

Bắt đầu tại packages/elements/src/context.tsx, khoảng dòng 339 và 379, sau đó so sánh các trường LanguageModelUsage được tham chiếu với định nghĩa kiểu của ai 6 và ai 7. Chạy bản tái hiện TypeScript nghiêm ngặt được cung cấp hoặc kiểm tra kiểu của gói; hoàn thành khi Context biên dịch với cả hai phiên bản chính được hỗ trợ của ai mà không có các lỗi đã báo cáo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
2.5k
Fork
290
Merge trung bình
20 phút
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của vercel/ai-elements

Tất cả issue của vercel/ai-elements

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.