Documentation
¶
Overview ¶
Package contextpolicy turns Kram's context limits into one explicit plan. Fixed prompt/tool-schema cost, conversation history, response headroom and tool-output growth all draw from the same model window instead of being governed by unrelated constants that can collectively overcommit it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action int
Action is the cheapest intervention that can bring history under its share of the context window.
type Plan ¶
type Plan struct {
MaxTokens int
FixedTokens int
ResponseReserveTokens int
HistoryBudgetTokens int
}
Plan is one iteration's concrete allocation. FixedTokens includes the system/project/memory preamble, postscript and tool definitions.
func New ¶
New allocates one eighth of the model window to the answer, capped at 8k tokens. Everything left after fixed prompt cost is the history budget.
func (Plan) RemainingHistoryTokens ¶
RemainingHistoryTokens reports how much additional history can fit before the next iteration needs pruning/compaction.
func (Plan) ToolOutputBudgetChars ¶
ToolOutputBudgetChars converts the remaining token allocation using the same chars/4 approximation as compaction and caps it at the producer-level aggregate limit supplied by the agent loop.