Skip to main content

format_compact_summary

Function format_compact_summary 

Source
pub fn format_compact_summary(raw: &str) -> String
Expand description

Strip the <analysis>…</analysis> drafting scratchpad from the model’s response and convert <summary>…</summary> into readable section headers. Returns the cleaned summary.

Processing steps:

  1. Remove the first <analysis>…</analysis> block (non-greedy).
  2. If <summary>…</summary> is present, replace the whole match with Summary:\n<content trimmed>.
  3. Collapse 3+ consecutive newlines to 2.
  4. Trim whitespace.
  5. If neither tag is present, return raw.trim() unchanged (graceful degradation for models that ignore the template).