Chat session: add `session.reset()` for stateless single-turn requests

Đang mở
#1,664 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

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

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

Từ ngày 27/11/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

feature request
Problem description

There is no way to clear a chat session. resetOnTurn: true sounds like it, but (as documented) it only forces full re-encoding: the session keeps the history and re-prefills all of it on every turn. Sending the same prompt four times gave 19, 45, 71 and 97 prefilled tokens. For independent single-turn requests (extraction, classification, benchmarks) the only way to get a clean context is to dispose and recreate the session.

Proposed solution

A session.reset() method that clears the history and KV cache back to initialMessages without reloading the model (react-native-litert-lm has resetConversation() for this), or an option that drops each turn from history after it completes. It would also help to state in the docs that resetOnTurn keeps and re-prefills the full history.

Alternative solutions

No response

Benefits to React Native ExecuTorch

Stateless requests are a common use of small on-device models, and recreating the session costs a model reload.

Additional context

No response

Ngôn ngữ chính
TypeScript
Star
1.8k
Fork
102
Merge trung bình
2 ngày 6 giờ
Pull request đã merge (30 ngày)
46

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 software-mansion/react-native-executorch

Tất cả issue của software-mansion/react-native-executorch

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.