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

Aperta
#1,664 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@barhanc ci sta già lavorando.

Dal 27/11/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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

Lingua principale
TypeScript
Stelle
1.8k
Fork
102
Merge medio
2g 6h
PR unite (30g)
46

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di software-mansion/react-native-executorch

Tutte le issue di software-mansion/react-native-executorch

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.