Skip to content

Persist and restore session transcripts, and prewarm sessions #23

Closed

Description

@corasan

Why

A session lives only as long as its JS object. Chat apps cannot restore a conversation after the app restarts. The first request also pays a 1–2 s cold start that apps could hide.

Transcript is Codable, and LanguageModelSession(model:tools:transcript:) restores a session from it. prewarm(promptPrefix:) loads the model ahead of the first request.

Proposal

const saved = session.transcript          // JSON string (Transcript encoded with JSONEncoder)
await storage.set('chat', saved)

const restored = new LanguageModelSession({ transcript: await storage.get('chat'), tools })
session.prewarm('You are a travel assistant')
  • transcript getter returns the encoded transcript as an opaque JSON string. The format belongs to Apple, so the library does not promise a stable shape beyond "round-trips through new LanguageModelSession({ transcript })".
  • A restored session takes its instructions from the transcript. Passing both instructions and transcript is a type error.
  • prewarm(promptPrefix?) forwards to LanguageModelSession.prewarm(promptPrefix:).
  • An invalid transcript fails with INVALID_TRANSCRIPT.

Activity

  1. added a commit that references this issue on Oct 16, 2026
    07790d5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions