Skip to main content

Module retry

Module retry 

Source
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 messages into segments each starting at a Role::User or Role::System boundary. 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.