I'm a little surprised to find there is no token counter and I'm curious what drives the decision not to include it.
As OP ~says, 4096 is not a massive context size. If tokens are a first-class constraint, a counter should be too.
Catch an error and trim is wasteful.
Apple should offer deterministic preflight.
Topic:
Machine Learning & AI
SubTopic:
Foundation Models