Feedback on Foundation Models context management wrapper

I’ve been experimenting with Foundation Models and built a small Swift package that wraps LanguageModelSession with simple context management.

The current approach checks the transcript token count using tokenCount(for:), compacts the transcript when it reaches a threshold, and retries once if exceededContextWindowSize is thrown.

I’d appreciate feedback on whether this is a sensible use of Foundation Models APIs, especially around rebuilding a session from a compacted Transcript.

GitHub: https://github.com/ricky-stone/FoundationContext

Feedback on Foundation Models context management wrapper
 
 
Q