Releases: aenealabs/contexttrim
Releases · aenealabs/contexttrim
Release list
v0.1.0
Added
ContextManager— add/extend/clear messages,fit()to a token budget,total_tokens(), andlast_fit_report()FitReport—kept,dropped(each aDropped(message, reason)),tokens_used,tokens_budget,fits,num_dropped- Six pluggable strategies in
contexttrim.strategies:RecencyDrop— drop oldest firstMiddleDrop— drop from the middle ("lost in the middle"), preserving head and tailRoleWeighted— drop lowest-scored roles first; pinsystemImportanceWeighted— role weight × recency decay ÷ length penaltyToolResultMerge— merge/dedup adjacent tool results, then truncate the largest if still over budgetSemanticCluster— drop least topically-relevant messages via pure-Python TF-IDF cosine similarity
Strategybase class for writing custom strategies- Character-heuristic token counter by default (
default_token_counter), with an injectabletoken_counter - Zero external dependencies — pure Python stdlib (3.9+)
- 24 unit tests covering the manager, all six strategies, token counting, and no-mutation guarantees