Expand description
PTL (prompt-too-long) retry helpers for compaction summarisation.
When the compactor asks the provider to summarise an older transcript
slice, that very request may itself exceed the provider’s context window.
This module provides best-effort escape hatches: drop the oldest message
groups (bounded by User/System boundaries) and retry up to
MAX_PTL_RETRIES times before giving up.
Constants§
- MAX_
PTL_ RETRIES - Maximum number of PTL retries before giving up and propagating the error.
Functions§
- estimate_
target_ from_ error - Best-effort token-gap parsing from an LLM error message.
- group_
by_ user_ boundary - Group
messagesinto segments each starting at aRole::UserorRole::Systemboundary. The first group always starts at index 0. - truncate_
head_ for_ retry - Drop the oldest groups from a to-summarise slice so the remaining slice fits within a target character budget, or by a fallback fraction.