Token count preferring real usage over the char heuristic
Source:R/compaction.R
token_count_with_estimation.RdMirrors Claude Code tokenCountWithEstimation (src/utils/tokens.ts): use the
real token usage from the last API exchange when available, otherwise fall
back to the char/3.5 estimate. This makes the compaction trigger fire on
actual model token counts rather than a rough character approximation.
Arguments
- chat
An
ellmer::Chatobject.