Token budget management.
Summary
Functions
Selects entries that fit within a token budget using priority-based greedy selection.
Functions
@spec fit_budget([CommBus.Entry.t()], non_neg_integer()) :: [CommBus.Entry.t()]
Selects entries that fit within a token budget using priority-based greedy selection.
Entries are sorted by (priority, weight, id) in descending order, then
accumulated until the token limit is reached. Entries whose token_count
would exceed the remaining budget are skipped.
Parameters
entries— List of%CommBus.Entry{}structs withtoken_countpopulated.limit— Maximum number of tokens allowed.
Returns
A list of %CommBus.Entry{} structs that fit within the budget, preserving
the priority-based selection order.