Expand description
The one history-reduction path.
A run previously reduced history twice: a message-count pass over
crate::uar::context::ContextStrategy followed by an independent
token-budget pass with its own strategy enum and its own tokenizer. The two
disagreed about what a token was, neither knew the system message was
pinned, and neither knew about tool-call pairs.
reduce_history is now the only way a run reduces history. It runs the
structural stage and the token-budget stage in order, from the single
operator-declared strategy, with the system message pinned out of reach of
both. Canonical tool groups are validated before reduction and must survive
byte-for-byte or the reduction returns an explicit overflow.
The operator-facing crate::uar::context::ContextStrategy remains the
only declared strategy. The internal
crate::uar::domain::context::ContextStrategy is derived from it here and
is not part of any persisted policy.
Structs§
- Reduce
Report - What
reduce_historydid to a run’s history.
Enums§
- Reduce
History Error - Why a history cannot be prepared within the requested reduction policy.
Constants§
- RESPONSE_
RESERVE_ TOKENS - Output tokens withheld from the model context for the response. This is the
reserve
reduce_historysubtracts when it derives the input allowance.
Functions§
- budget_
strategy_ for - Map the operator-declared strategy onto the token-budget stage’s strategy.
- canonical_
prose_ spans - Mark only canonical plain dialogue as reducible prose. Input includes the optional pinned system message; returned offsets exclude that message, as required by the structural summarizer. No content heuristic grants authority.
- liability_
message - Event text for a reduction failure. An overflow names the liabilities the
allowance already excludes: tool definitions plus world state
(
fixed_tokens, combined) and the response reserve. - reduce_
history - Reduce a run’s history once: lossless validation, structural stage, token budget, then protected-group verification, with the system message pinned.
- reduce_
history_ with_ input_ allowance - Reduce against a host-reviewed input allowance that already excludes output, reasoning, uncertainty and fixed request content. Counts used for trimming remain estimates; the destination driver recounts the complete final wire.
- reduce_
history_ with_ input_ allowance_ and_ auxiliary - Reduce with a distinct captured allowance for auxiliary model requests.
- reduce_
history_ with_ marked_ prose - Reduce history while permitting only explicitly host-marked prose ranges to enter summarization. Span indices address conversation history after the optional leading system message is removed.
- reserve_
fixed_ input_ tokens - Withhold tools and world state from an already reserved input allowance. No capacity is inferred here; the caller owns the destination contract.
- reserve_
fixed_ request_ tokens - The context limit to hand
reduce_historyonce request content that history cannot displace (world state and tool definitions) is withheld.reduce_historythen subtracts the response reserve itself. - search_
tools_ definition - OpenAI tool JSON of the
search_toolscontrol the orchestrator adds to the request whenever deferred MCP tools exist. Built from a scratch registry so admission counts exactly the descriptor the first request carries.Nonewhen the control cannot be built; the orchestrator then counts the actual request tools per step. - split_
assembly_ failure - Inverse of
tag_assembly_failure: the stable code and message, orNonefor an untagged contributor failure. - tag_
assembly_ failure - Carry a reduction failure’s stable code through
AssemblyError, which has no code field:"<code>: <liability message>". - tool_
definition_ tokens - Tokens the tool definitions occupy in a request, counted over the same OpenAI function-schema JSON the run attaches to every model call.