EDGE FDE
IntermediateBuild a context packer for on-device AI
Cut wasted tokens and wrong answers by packing only the memory, search hits, and tools the model needs right now.
Build a token-budgeted context assembler for LanguageModelSession / Dynamic Profiles.
Rank memory, search hits, and tools into a token budget, then hand that pack to a LanguageModelSession through Dynamic Profiles. iOS 27 and macOS 27 only.
Lessons
Key concepts
- Pack memory, search hits, and tools into a token budget for
LanguageModelSession. - Dynamic Profiles declare what the model sees. Your assembler picks the slices.
- One active Profile per turn on iOS 27 and macOS 27.
- Count with the same model that will answer, using
contextSizeandtokenCount(for:).
Takeaways
- You can fill a token budget and declare it as one Dynamic Profile.
- You can hand a packed context to
LanguageModelSession(profile:)without dumping the whole toolbox. - You can refuse an overfull pack and log what you left out.
Agent briefs
Related courses
Search private files on the phone · Route work to the right Apple model · Run an agent with a state machine · Stream tokens and measure speed