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

Offen
#1,664 0 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@barhanc arbeitet bereits daran.

Seit 27.11.2026.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Beschreibung

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

Vorherrschende Sprache
TypeScript
Sterne
1.8k
Forks
102
Ø Merge
2 T. 6 Std.
Gemergte PRs (30 T.)
46

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus software-mansion/react-native-executorch

Alle Issues in software-mansion/react-native-executorch

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.