struct

Smith::Context::Budget

Inherits Struct < Value < Object

What a request costs and where the thresholds sit in it.

The whole point of this being a value rather than a bare max_tokens is that "should I act?" and "when do I stop?" are different questions. Answering both with one number is what made compaction fire every turn and reclaim nothing.

Constructors

new(max_tokens : Int32, compact_at : Float64 = DEFAULT_COMPACT_AT, compact_to : Float64 = DEFAULT_COMPACT_TO, overhead_tokens : Int32 = 0, ratio : Float64 = 1.0)
Source

Instance methods

allowance(limit : Int32) : Int32

The inverse: the largest raw history estimate whose charged cost still fits limit. The stages compare against this, so none of them has to redo the overhead-and-calibration arithmetic.

Source
charged(history_tokens : Int32) : Int32

What the request actually costs, given a raw estimate of the history. Every number compaction reports is this one, so "compacted to N tokens" describes the request rather than a fragment of it.

Source
max_tokens

The hard ceiling: what the provider will accept.

Source
overhead_tokens

Everything in the request that is not the message history: system prompt, project context, skills, tool definitions.

Source
ratio

Reported prompt tokens over estimated ones. The byte heuristic undercounts; this is how much.

Source
target_allowance
Source
target_tokens

What it compacts down to once it does.

Source
trigger_allowance
Source
trigger_tokens

Where compaction starts acting.

Source