Positional-bias mitigation (lost-in-the-middle): reorder so the most
important items sit at the beginning and end of the context, where models
attend most reliably (Anthropic’s ~18% middle drop vs 30-50% elsewhere,
fable §13). Keeps the first head and last tail items in place and
moves the middle to the end (least-attended region) preserving order.
Resolve ContextStrategy::Auto into a concrete strategy using the
caller’s model-specific effective context window (CH-05). Any other
strategy passes through unchanged — this is the seam a caller with real
model information (e.g. RunManager) should use before reaching
trim_count/apply_strategy/trim_with_summarization, which only
see DEFAULT_AUTO_CONTEXT_TOKENS if Auto reaches them unresolved.
Choose a context strategy tuned to a model’s effective context window
(CH-05, fable §13). Larger-context models get a proportionally larger
sliding window before summarisation kicks in; small-context models
summarise sooner. effective_context_tokens should be the usable
window (typically 50-80% of advertised), not the advertised maximum.
Apply a declared strategy while allowing the trusted host to identify the
only prose spans that summarization may replace. Span indices address
history, excluding the separately pinned system message.
Async counterpart of trim_history: runs LLM-backed summarization for
the strategies that need it, with the system message pinned out of reach.
Without explicit host marks, summarization leaves history unchanged.
Summarize only trusted-host-marked prose that is old enough for the
configured strategy. Unmarked messages stay in their original position.
Any missing driver or failed/cancelled/invalid/over-budget summary returns
the original message vector without a truncation fallback.
Compatibility entry point for callers without host-owned eligibility
metadata. Unknown content is protected by default, so summarizing strategies
leave it unchanged.