Skip to main content

detect_compression_failure

Function detect_compression_failure 

Source
pub fn detect_compression_failure(
    response: &str,
    had_compaction: bool,
) -> Option<String>
Expand description

Detect whether response contains signals of context loss after compaction.

Returns Some(reason) only when ALL of:

  1. had_compaction is true
  2. At least one uncertainty phrase matches
  3. At least one prior-context reference phrase also matches

This two-signal requirement minimizes false positives. Neither pattern set alone is reliable; together they are highly specific.

ยงReturns

  • None when had_compaction is false.
  • None when the response does not match both signal categories.
  • Some(reason) with a description string when context loss is detected.