CommBus.Budget.Planner (CommBus v0.1.0)

Copy Markdown View Source

Simple helper for deriving section budgets and completion allowances.

Example

plan = CommBus.Budget.Planner.plan(total: 8000, completion: 1000)
# => %{total: 8000, completion: 1000, sections: %{system: 800, pre_history: 2400, history: 3200, post_history: 1600}}

Summary

Functions

Computes a budget plan that allocates tokens across prompt sections.

Functions

plan(opts)

@spec plan(keyword()) :: %{
  total: pos_integer(),
  completion: non_neg_integer(),
  sections: map()
}

Computes a budget plan that allocates tokens across prompt sections.

Subtracts the completion reserve from the total budget, then distributes the remainder across sections using the provided ratios (or defaults: system 10%, pre_history 30%, history 40%, post_history 20%).

Parameters

  • opts — Keyword list with:
    • :total (required) — Total token budget for the context window.
    • :completion — Tokens reserved for LLM completion (default: total ÷ 4).
    • :section_ratios — Map of section atoms to ratio floats.

Returns

A map with :total, :completion, and :sections (map of section → token count).