graflo.architecture.schema.context.budget¶
Budget accounting for schema context payloads.
Deliberately dependency-free: no tokenizer, no model. The estimate is a documented characters-per-token ratio over the same compact serialization the transport layer will send, and every result also reports the exact character count so a caller holding a real tokenizer can re-estimate without core changing.
Budget
¶
Bases: ConfigBaseModel
Caller-requested ceilings on a schema context payload.
Source code in graflo/architecture/schema/context/budget.py
BudgetAccounting
¶
Bases: ConfigBaseModel
What the budget actually cost, measured rather than assumed.
Source code in graflo/architecture/schema/context/budget.py
estimate_tokens(payload)
¶
Estimate token count for payload.
Runs over the compact serialization — estimating over a pretty-printed or defaults-included dump overcounts by a factor of two or more, which would make every budget silently pessimistic.
Source code in graflo/architecture/schema/context/budget.py
serialize_compact(payload)
¶
Serialize payload the way the transport layer will: compact and stable.